mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
Added save/restore of column width of active tables.
This commit is contained in:
parent
4e0929e3f2
commit
987a62448e
3 changed files with 46 additions and 26 deletions
|
@ -136,7 +136,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
public static final String KEY_MAGE_PANEL_LAST_SIZE = "gamepanelLastSize";
|
public static final String KEY_MAGE_PANEL_LAST_SIZE = "gamepanelLastSize";
|
||||||
|
|
||||||
// pref settings of table settings and filtering
|
// pref settings of table settings and filtering
|
||||||
public static final String KEY_TABLES_FILTER_FORMATS = "tablePanelFilterFormats";
|
public static final String KEY_TABLES_FILTER_SETTINGS = "tablePanelFilterSettings";
|
||||||
|
public static final String KEY_TABLES_COLUMNS_WIDTH = "tablePanelColumnWidth";
|
||||||
|
|
||||||
// positions of divider bars
|
// positions of divider bars
|
||||||
public static final String KEY_TABLES_DIVIDER_LOCATION_1 = "tablePanelDividerLocation1";
|
public static final String KEY_TABLES_DIVIDER_LOCATION_1 = "tablePanelDividerLocation1";
|
||||||
|
|
|
@ -151,7 +151,6 @@
|
||||||
<Dimension value="[23, 23]"/>
|
<Dimension value="[23, 23]"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
@ -180,7 +179,6 @@
|
||||||
<Dimension value="[23, 23]"/>
|
<Dimension value="[23, 23]"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
@ -209,7 +207,6 @@
|
||||||
<Dimension value="[23, 23]"/>
|
<Dimension value="[23, 23]"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
@ -229,7 +226,6 @@
|
||||||
<Property name="focusable" type="boolean" value="false"/>
|
<Property name="focusable" type="boolean" value="false"/>
|
||||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
@ -249,7 +245,6 @@
|
||||||
<Dimension value="[115, 25]"/>
|
<Dimension value="[115, 25]"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
|
@ -268,7 +263,6 @@
|
||||||
<Dimension value="[90, 25]"/>
|
<Dimension value="[90, 25]"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
|
@ -295,7 +289,6 @@
|
||||||
<Property name="focusable" type="boolean" value="false"/>
|
<Property name="focusable" type="boolean" value="false"/>
|
||||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
@ -312,7 +305,6 @@
|
||||||
<Property name="focusable" type="boolean" value="false"/>
|
<Property name="focusable" type="boolean" value="false"/>
|
||||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
@ -328,7 +320,6 @@
|
||||||
<Property name="focusPainted" type="boolean" value="false"/>
|
<Property name="focusPainted" type="boolean" value="false"/>
|
||||||
<Property name="focusable" type="boolean" value="false"/>
|
<Property name="focusable" type="boolean" value="false"/>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
|
@ -346,7 +337,6 @@
|
||||||
<Property name="focusable" type="boolean" value="false"/>
|
<Property name="focusable" type="boolean" value="false"/>
|
||||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
@ -362,7 +352,6 @@
|
||||||
<Property name="focusPainted" type="boolean" value="false"/>
|
<Property name="focusPainted" type="boolean" value="false"/>
|
||||||
<Property name="focusable" type="boolean" value="false"/>
|
<Property name="focusable" type="boolean" value="false"/>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
|
@ -380,7 +369,6 @@
|
||||||
<Property name="focusable" type="boolean" value="false"/>
|
<Property name="focusable" type="boolean" value="false"/>
|
||||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
@ -397,7 +385,6 @@
|
||||||
<Property name="focusable" type="boolean" value="false"/>
|
<Property name="focusable" type="boolean" value="false"/>
|
||||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
@ -413,7 +400,6 @@
|
||||||
<Property name="focusPainted" type="boolean" value="false"/>
|
<Property name="focusPainted" type="boolean" value="false"/>
|
||||||
<Property name="focusable" type="boolean" value="false"/>
|
<Property name="focusable" type="boolean" value="false"/>
|
||||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||||
<Property name="rolloverEnabled" type="boolean" value="false"/>
|
|
||||||
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
<Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
|
|
|
@ -132,6 +132,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
activeTablesSorter = new MageTableRowSorter(tableModel);
|
activeTablesSorter = new MageTableRowSorter(tableModel);
|
||||||
tableTables.setRowSorter(activeTablesSorter);
|
tableTables.setRowSorter(activeTablesSorter);
|
||||||
|
|
||||||
TableTableModel.setColumnWidth(tableTables);
|
TableTableModel.setColumnWidth(tableTables);
|
||||||
|
|
||||||
tableCompleted.setRowSorter(new MageTableRowSorter(matchesModel));
|
tableCompleted.setRowSorter(new MageTableRowSorter(matchesModel));
|
||||||
|
@ -286,7 +287,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
private void restoreSettings() {
|
private void restoreSettings() {
|
||||||
// filter settings
|
// filter settings
|
||||||
String formatSettings = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_FILTER_FORMATS, "");
|
String formatSettings = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_FILTER_SETTINGS, "");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (JToggleButton component : filterButtons) {
|
for (JToggleButton component : filterButtons) {
|
||||||
if (formatSettings.length() > i) {
|
if (formatSettings.length() > i) {
|
||||||
|
@ -300,12 +301,26 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveSettings() {
|
private void saveSettings() {
|
||||||
// Formats
|
// Filters
|
||||||
StringBuilder formatSettings = new StringBuilder();
|
StringBuilder formatSettings = new StringBuilder();
|
||||||
for (JToggleButton component : filterButtons) {
|
for (JToggleButton component : filterButtons) {
|
||||||
formatSettings.append(component.isSelected() ? "x":"-");
|
formatSettings.append(component.isSelected() ? "x":"-");
|
||||||
}
|
}
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLES_FILTER_FORMATS, formatSettings.toString());
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLES_FILTER_SETTINGS, formatSettings.toString());
|
||||||
|
|
||||||
|
// Column width
|
||||||
|
StringBuilder columnWidthSettings = new StringBuilder();
|
||||||
|
boolean firstValue = true;
|
||||||
|
for (int i = 0; i < tableTables.getColumnModel().getColumnCount(); i++) {
|
||||||
|
TableColumn column = tableTables.getColumnModel().getColumn(tableTables.convertColumnIndexToView(i));
|
||||||
|
if (!firstValue) {
|
||||||
|
columnWidthSettings.append(",");
|
||||||
|
} else {
|
||||||
|
firstValue = false;
|
||||||
|
}
|
||||||
|
columnWidthSettings.append(column.getWidth());
|
||||||
|
}
|
||||||
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH, columnWidthSettings.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreDividerLocations() {
|
private void restoreDividerLocations() {
|
||||||
|
@ -1154,8 +1169,8 @@ class TableTableModel extends AbstractTableModel {
|
||||||
public static final int COLUMN_STATUS = 5;
|
public static final int COLUMN_STATUS = 5;
|
||||||
public static final int ACTION_COLUMN = 7; // column the action is located (starting with 0)
|
public static final int ACTION_COLUMN = 7; // column the action is located (starting with 0)
|
||||||
|
|
||||||
private final String[] columnNames = new String[]{"Typ","Deck Type", "Owner / Players", "Game Type", "Info", "Status", "Created / Started", "Action"};
|
private final String[] columnNames = new String[]{"M/T","Deck Type", "Owner / Players", "Game Type", "Info", "Status", "Created / Started", "Action"};
|
||||||
private static final int[] columnsWidth = {15, 120, 120, 180, 80, 120, 80, 60};
|
private static final int[] defaultColumnsWidth = {35, 150, 120, 180, 80, 120, 80, 60};
|
||||||
|
|
||||||
private TableView[] tables = new TableView[0];
|
private TableView[] tables = new TableView[0];
|
||||||
private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");;
|
private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");;
|
||||||
|
@ -1169,13 +1184,31 @@ class TableTableModel extends AbstractTableModel {
|
||||||
|
|
||||||
static public void setColumnWidth(JTable table) {
|
static public void setColumnWidth(JTable table) {
|
||||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||||
int i = 0;
|
|
||||||
for (int width : columnsWidth) {
|
// read the saved column width
|
||||||
TableColumn column = table.getColumnModel().getColumn(i++);
|
String widthsString = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH, null);
|
||||||
if (i == COLUMN_ICON) {
|
int[] widths = null;
|
||||||
column.setMinWidth(width);
|
int length = 0;
|
||||||
column.setMaxWidth(width);
|
if (widthsString != null && !widthsString.isEmpty()) {
|
||||||
|
String[] items = widthsString.split(",");
|
||||||
|
length = items.length;
|
||||||
|
widths = new int[length];
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
try {
|
||||||
|
widths[i] = Integer.parseInt(items[i]);
|
||||||
|
if (widths[i] > 500) {
|
||||||
|
widths[i] = 300;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException nfe) {}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// set the column width from saved value or defaults
|
||||||
|
int i = 0;
|
||||||
|
for (int width : defaultColumnsWidth) {
|
||||||
|
if (length > i) {
|
||||||
|
width = widths[i];
|
||||||
|
}
|
||||||
|
TableColumn column = table.getColumnModel().getColumn(i++);
|
||||||
column.setWidth(width);
|
column.setWidth(width);
|
||||||
column.setPreferredWidth(width);
|
column.setPreferredWidth(width);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue