From 8ee6c054cd4b2d81144d2d3e11a9169b96bf64ab Mon Sep 17 00:00:00 2001 From: GrayedFox Date: Sun, 20 May 2018 17:25:57 +0200 Subject: [PATCH 1/6] ignore Atom build config and logs --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 3d7e99c65e..84a1b82bba 100644 --- a/.gitignore +++ b/.gitignore @@ -140,3 +140,7 @@ client_secrets.json dependency-reduced-pom.xml mage-bundle /Mage.Client/game-*.json + +# build-tools config and log files when building client/server with Atom +.build-tools.cson +build-output.log From 06392f510c4ab28523aa2b6ef9a0c5669915366f Mon Sep 17 00:00:00 2001 From: GrayedFox Date: Sun, 20 May 2018 18:33:06 +0200 Subject: [PATCH 2/6] refactor code reorder import statemets tableSeats renamed to jTableSeats to follow naming scheme setGUISize called sooner (as it is in PlayersChatPanel.java) --- .../client/dialog/TableWaitingDialog.form | 2 +- .../client/dialog/TableWaitingDialog.java | 57 ++++++++++--------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.form b/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.form index be222cd34b..bc3776f1f5 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.form +++ b/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.form @@ -111,7 +111,7 @@ - + diff --git a/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java b/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java index a6e523cfcc..60eb9d080e 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java @@ -43,13 +43,13 @@ import java.util.concurrent.TimeUnit; import javax.swing.Icon; import javax.swing.SwingWorker; import javax.swing.table.AbstractTableModel; +import org.apache.log4j.Logger; + import mage.client.MageFrame; import mage.client.SessionHandler; import mage.client.chat.ChatPanelBasic; import mage.client.components.MageComponents; import mage.client.components.tray.MageTray; -import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_ORDER; -import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH; import mage.client.util.GUISizeHelper; import mage.client.util.audio.AudioManager; import mage.client.util.gui.TableUtil; @@ -58,7 +58,9 @@ import mage.players.PlayerType; import mage.remote.Session; import mage.view.SeatView; import mage.view.TableView; -import org.apache.log4j.Logger; + +import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_ORDER; +import static mage.client.dialog.PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH; /** * @author BetaSteward_at_googlemail.com @@ -66,7 +68,7 @@ import org.apache.log4j.Logger; public class TableWaitingDialog extends MageDialog { private static final Logger LOGGER = Logger.getLogger(TableWaitingDialog.class); - private static final int[] DEFAULT_COLUMS_WIDTH = {20, 50, 100, 100, 100}; + private static final int[] DEFAULT_COLUMNS_WIDTH = {20, 50, 100, 100, 100}; private UUID tableId; private UUID roomId; @@ -89,12 +91,13 @@ public class TableWaitingDialog extends MageDialog { this.setSize(prefWidth, prefHeight); } - chatPanel.useExtendedView(ChatPanelBasic.VIEW_MODE.NONE); - tableSeats.createDefaultColumnsFromModel(); - TableUtil.setColumnWidthAndOrder(tableSeats, DEFAULT_COLUMS_WIDTH, KEY_TABLE_WAITING_COLUMNS_WIDTH, KEY_TABLE_WAITING_COLUMNS_ORDER); - tableSeats.setDefaultRenderer(Icon.class, new CountryCellRenderer()); setGUISize(); + chatPanel.useExtendedView(ChatPanelBasic.VIEW_MODE.NONE); + jTableSeats.createDefaultColumnsFromModel(); + TableUtil.setColumnWidthAndOrder(jTableSeats, DEFAULT_COLUMNS_WIDTH, KEY_TABLE_WAITING_COLUMNS_WIDTH, KEY_TABLE_WAITING_COLUMNS_ORDER); + jTableSeats.setDefaultRenderer(Icon.class, new CountryCellRenderer()); + MageFrame.getUI().addButton(MageComponents.TABLE_WAITING_START_BUTTON, btnStart); } @@ -104,9 +107,9 @@ public class TableWaitingDialog extends MageDialog { } private void setGUISize() { - tableSeats.getTableHeader().setFont(GUISizeHelper.tableFont); - tableSeats.setFont(GUISizeHelper.tableFont); - tableSeats.setRowHeight(GUISizeHelper.getTableRowHeight()); + jTableSeats.getTableHeader().setFont(GUISizeHelper.tableFont); + jTableSeats.setFont(GUISizeHelper.tableFont); + jTableSeats.setRowHeight(GUISizeHelper.getTableRowHeight()); jSplitPane1.setDividerSize(GUISizeHelper.dividerBarSize); jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0)); @@ -131,14 +134,14 @@ public class TableWaitingDialog extends MageDialog { closeDialog(); return; } - int row = this.tableSeats.getSelectedRow(); + int row = this.jTableSeats.getSelectedRow(); if (getTitle().equals("Waiting for players")) { this.title = getTitle() + " - " + table.getDeckType() + " / " + table.getGameType(); this.repaint(); } tableWaitModel.loadData(table); - this.tableSeats.repaint(); - this.tableSeats.getSelectionModel().setSelectionInterval(row, row); + this.jTableSeats.repaint(); + this.jTableSeats.getSelectionModel().setSelectionInterval(row, row); } else { closeDialog(); } @@ -177,12 +180,12 @@ public class TableWaitingDialog extends MageDialog { if (updateTask != null) { updateTask.cancel(true); } + this.chatPanel.disconnect(); MageFrame.getUI().removeButton(MageComponents.TABLE_WAITING_START_BUTTON); this.removeDialog(); - TableUtil.saveColumnWidthAndOrderToPrefs(tableSeats, KEY_TABLE_WAITING_COLUMNS_WIDTH, KEY_TABLE_WAITING_COLUMNS_ORDER); - PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLE_WAITING_WIDTH, Integer.toString(getWidth())); - PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLE_WAITING_HEIGHT, Integer.toString(getHeight())); + TableUtil.saveColumnWidthAndOrderToPrefs(jTableSeats, KEY_TABLE_WAITING_COLUMNS_WIDTH, KEY_TABLE_WAITING_COLUMNS_ORDER); + PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH, Integer.toString(getWidth())); } /** @@ -200,7 +203,7 @@ public class TableWaitingDialog extends MageDialog { btnStart = new javax.swing.JButton(); jSplitPane1 = new javax.swing.JSplitPane(); jScrollPane1 = new javax.swing.JScrollPane(); - tableSeats = new javax.swing.JTable(); + jTableSeats = new javax.swing.JTable(); chatPanel = new mage.client.chat.ChatPanelBasic(); setResizable(true); @@ -226,9 +229,9 @@ public class TableWaitingDialog extends MageDialog { jSplitPane1.setResizeWeight(1.0); jSplitPane1.setToolTipText(""); - tableSeats.setModel(tableWaitModel); - tableSeats.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - jScrollPane1.setViewportView(tableSeats); + jTableSeats.setModel(tableWaitModel); + jTableSeats.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + jScrollPane1.setViewportView(jTableSeats); jSplitPane1.setLeftComponent(jScrollPane1); jSplitPane1.setRightComponent(chatPanel); @@ -288,19 +291,19 @@ public class TableWaitingDialog extends MageDialog { }//GEN-LAST:event_btnCancelActionPerformed private void btnMoveDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveDownActionPerformed - int row = this.tableSeats.getSelectedRow(); - if (row < this.tableSeats.getRowCount() - 1) { + int row = this.jTableSeats.getSelectedRow(); + if (row < this.jTableSeats.getRowCount() - 1) { SessionHandler.swapSeats(roomId, tableId, row, row + 1); - this.tableSeats.getSelectionModel().setSelectionInterval(row + 1, row + 1); + this.jTableSeats.getSelectionModel().setSelectionInterval(row + 1, row + 1); } }//GEN-LAST:event_btnMoveDownActionPerformed private void btnMoveUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveUpActionPerformed - int row = this.tableSeats.getSelectedRow(); + int row = this.jTableSeats.getSelectedRow(); if (row > 0) { SessionHandler.swapSeats(roomId, tableId, row, row - 1); - this.tableSeats.getSelectionModel().setSelectionInterval(row - 1, row - 1); + this.jTableSeats.getSelectionModel().setSelectionInterval(row - 1, row - 1); } }//GEN-LAST:event_btnMoveUpActionPerformed @@ -312,7 +315,7 @@ public class TableWaitingDialog extends MageDialog { private mage.client.chat.ChatPanelBasic chatPanel; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSplitPane jSplitPane1; - private javax.swing.JTable tableSeats; + private javax.swing.JTable jTableSeats; // End of variables declaration//GEN-END:variables } From a3e433f7bd9feda462e1af36c29b70fb11600d24 Mon Sep 17 00:00:00 2001 From: GrayedFox Date: Sun, 20 May 2018 19:25:31 +0200 Subject: [PATCH 3/6] remove offending line setting width incorrectly (was always 1647) --- .../src/main/java/mage/client/dialog/TableWaitingDialog.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java b/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java index 60eb9d080e..c3567f83a4 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/TableWaitingDialog.java @@ -185,7 +185,6 @@ public class TableWaitingDialog extends MageDialog { MageFrame.getUI().removeButton(MageComponents.TABLE_WAITING_START_BUTTON); this.removeDialog(); TableUtil.saveColumnWidthAndOrderToPrefs(jTableSeats, KEY_TABLE_WAITING_COLUMNS_WIDTH, KEY_TABLE_WAITING_COLUMNS_ORDER); - PreferencesDialog.saveValue(PreferencesDialog.KEY_TABLE_WAITING_COLUMNS_WIDTH, Integer.toString(getWidth())); } /** From 0fe129f817dd8a88126ca4e474e7ff4e6c480348 Mon Sep 17 00:00:00 2001 From: GrayedFox Date: Sun, 20 May 2018 20:12:22 +0200 Subject: [PATCH 4/6] remove todo (column wodth and sort order persists through restarts) --- Mage.Client/src/main/java/mage/client/table/TablesPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f7560511b6..36f1e52002 100644 --- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java +++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java @@ -192,7 +192,7 @@ public class TablesPanel extends javax.swing.JPanel { activeTablesSorter.setSortKeys(list); TableUtil.setColumnWidthAndOrder(tableTables, DEFAULT_COLUMNS_WIDTH, - PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH, PreferencesDialog.KEY_TABLES_COLUMNS_ORDER); // TODO: is sort order save and restore after app restart/window open? + PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH, PreferencesDialog.KEY_TABLES_COLUMNS_ORDER); // 2. TABLE COMPLETED completedTablesSorter = new MageTableRowSorter(matchesModel); From d65344158faea76b37d7b8daf10d7d4d0ed8ca1d Mon Sep 17 00:00:00 2001 From: GrayedFox Date: Sun, 20 May 2018 21:07:28 +0200 Subject: [PATCH 5/6] add logging for restoring/saving column width and order (remove later) --- .../src/main/java/mage/client/util/gui/TableUtil.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Mage.Client/src/main/java/mage/client/util/gui/TableUtil.java b/Mage.Client/src/main/java/mage/client/util/gui/TableUtil.java index 7bf6d5b1ae..61f502f18a 100644 --- a/Mage.Client/src/main/java/mage/client/util/gui/TableUtil.java +++ b/Mage.Client/src/main/java/mage/client/util/gui/TableUtil.java @@ -5,8 +5,10 @@ */ package mage.client.util.gui; +import java.util.Arrays; import javax.swing.JTable; import javax.swing.table.TableColumn; +import org.apache.log4j.Logger; import mage.client.dialog.PreferencesDialog; /** @@ -22,11 +24,15 @@ public final class TableUtil { * @param widthPrefKey * @param orderPrefKey */ + + private static final Logger LOGGER = Logger.getLogger(TableUtil.class); + static public void setColumnWidthAndOrder(JTable table, int[] defaultColumnsWidth, String widthPrefKey, String orderPrefKey) { table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // set the column width from saved value or defaults int[] widths = getIntArrayFromString(PreferencesDialog.getCachedValue(widthPrefKey, null)); + LOGGER.info("loading stored widths: " + Arrays.toString(widths)); int i = 0; for (int width : defaultColumnsWidth) { if (widths != null && widths.length > i) { @@ -43,6 +49,7 @@ public final class TableUtil { // set the column order int[] order = getIntArrayFromString(PreferencesDialog.getCachedValue(orderPrefKey, null)); + LOGGER.info("loading column order: " + Arrays.toString(order)); if (order != null && order.length == table.getColumnCount()) { for (int j = 0; j < table.getColumnCount(); j++) { table.moveColumn(table.convertColumnIndexToView(order[j]), j); @@ -70,6 +77,8 @@ public final class TableUtil { PreferencesDialog.saveValue(widthPrefKey, columnWidthSettings.toString()); PreferencesDialog.saveValue(orderPrefKey, columnOrderSettings.toString()); + LOGGER.info("saving column widths: " + columnWidthSettings.toString()); + LOGGER.info("saving column order: " + columnOrderSettings.toString()); } public static int[] getIntArrayFromString(String stringData) { From f1f2a80f4f72be9650e210db6d469b35b7d94325 Mon Sep 17 00:00:00 2001 From: GrayedFox Date: Sun, 20 May 2018 21:07:28 +0200 Subject: [PATCH 6/6] add logging for restoring/saving column width and order (remove later) --- .../src/main/java/mage/client/util/gui/TableUtil.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Mage.Client/src/main/java/mage/client/util/gui/TableUtil.java b/Mage.Client/src/main/java/mage/client/util/gui/TableUtil.java index 7bf6d5b1ae..61f502f18a 100644 --- a/Mage.Client/src/main/java/mage/client/util/gui/TableUtil.java +++ b/Mage.Client/src/main/java/mage/client/util/gui/TableUtil.java @@ -5,8 +5,10 @@ */ package mage.client.util.gui; +import java.util.Arrays; import javax.swing.JTable; import javax.swing.table.TableColumn; +import org.apache.log4j.Logger; import mage.client.dialog.PreferencesDialog; /** @@ -22,11 +24,15 @@ public final class TableUtil { * @param widthPrefKey * @param orderPrefKey */ + + private static final Logger LOGGER = Logger.getLogger(TableUtil.class); + static public void setColumnWidthAndOrder(JTable table, int[] defaultColumnsWidth, String widthPrefKey, String orderPrefKey) { table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // set the column width from saved value or defaults int[] widths = getIntArrayFromString(PreferencesDialog.getCachedValue(widthPrefKey, null)); + LOGGER.info("loading stored widths: " + Arrays.toString(widths)); int i = 0; for (int width : defaultColumnsWidth) { if (widths != null && widths.length > i) { @@ -43,6 +49,7 @@ public final class TableUtil { // set the column order int[] order = getIntArrayFromString(PreferencesDialog.getCachedValue(orderPrefKey, null)); + LOGGER.info("loading column order: " + Arrays.toString(order)); if (order != null && order.length == table.getColumnCount()) { for (int j = 0; j < table.getColumnCount(); j++) { table.moveColumn(table.convertColumnIndexToView(order[j]), j); @@ -70,6 +77,8 @@ public final class TableUtil { PreferencesDialog.saveValue(widthPrefKey, columnWidthSettings.toString()); PreferencesDialog.saveValue(orderPrefKey, columnOrderSettings.toString()); + LOGGER.info("saving column widths: " + columnWidthSettings.toString()); + LOGGER.info("saving column order: " + columnOrderSettings.toString()); } public static int[] getIntArrayFromString(String stringData) {