diff --git a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java
index 47ac32369b..b75457d2f5 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java
@@ -136,7 +136,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_MAGE_PANEL_LAST_SIZE = "gamepanelLastSize";
// 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
public static final String KEY_TABLES_DIVIDER_LOCATION_1 = "tablePanelDividerLocation1";
diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPanel.form b/Mage.Client/src/main/java/mage/client/table/TablesPanel.form
index ca5aba8fe7..95f0723c2d 100644
--- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.form
+++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.form
@@ -151,7 +151,6 @@
-
@@ -180,7 +179,6 @@
-
@@ -209,7 +207,6 @@
-
@@ -229,7 +226,6 @@
-
@@ -249,7 +245,6 @@
-
@@ -268,7 +263,6 @@
-
@@ -295,7 +289,6 @@
-
@@ -312,7 +305,6 @@
-
@@ -328,7 +320,6 @@
-
@@ -346,7 +337,6 @@
-
@@ -362,7 +352,6 @@
-
@@ -380,7 +369,6 @@
-
@@ -397,7 +385,6 @@
-
@@ -413,7 +400,6 @@
-
diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java
index 817026eab3..74b26afb09 100644
--- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java
+++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java
@@ -132,6 +132,7 @@ public class TablesPanel extends javax.swing.JPanel {
activeTablesSorter = new MageTableRowSorter(tableModel);
tableTables.setRowSorter(activeTablesSorter);
+
TableTableModel.setColumnWidth(tableTables);
tableCompleted.setRowSorter(new MageTableRowSorter(matchesModel));
@@ -286,7 +287,7 @@ public class TablesPanel extends javax.swing.JPanel {
private void restoreSettings() {
// filter settings
- String formatSettings = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_FILTER_FORMATS, "");
+ String formatSettings = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_FILTER_SETTINGS, "");
int i = 0;
for (JToggleButton component : filterButtons) {
if (formatSettings.length() > i) {
@@ -300,12 +301,26 @@ public class TablesPanel extends javax.swing.JPanel {
}
private void saveSettings() {
- // Formats
+ // Filters
StringBuilder formatSettings = new StringBuilder();
for (JToggleButton component : filterButtons) {
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() {
@@ -1154,8 +1169,8 @@ class TableTableModel extends AbstractTableModel {
public static final int COLUMN_STATUS = 5;
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 static final int[] columnsWidth = {15, 120, 120, 180, 80, 120, 80, 60};
+ private final String[] columnNames = new String[]{"M/T","Deck Type", "Owner / Players", "Game Type", "Info", "Status", "Created / Started", "Action"};
+ private static final int[] defaultColumnsWidth = {35, 150, 120, 180, 80, 120, 80, 60};
private TableView[] tables = new TableView[0];
private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");;
@@ -1169,13 +1184,31 @@ class TableTableModel extends AbstractTableModel {
static public void setColumnWidth(JTable table) {
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
- int i = 0;
- for (int width : columnsWidth) {
- TableColumn column = table.getColumnModel().getColumn(i++);
- if (i == COLUMN_ICON) {
- column.setMinWidth(width);
- column.setMaxWidth(width);
+
+ // read the saved column width
+ String widthsString = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH, null);
+ int[] widths = null;
+ int length = 0;
+ 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.setPreferredWidth(width);
}