diff --git a/Mage.Client/pom.xml b/Mage.Client/pom.xml
index 35baf24109c..893201b5c1e 100644
--- a/Mage.Client/pom.xml
+++ b/Mage.Client/pom.xml
@@ -6,7 +6,7 @@
org.mage
mage-root
- 1.4.31
+ 1.4.32
org.mage
diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java b/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java
index 0e3121f61d9..c47059ed798 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java
@@ -51,6 +51,7 @@ public class NewTableDialog extends MageDialog {
this.spnNumWins.setModel(new SpinnerNumberModel(1, 1, 5, 1));
this.spnFreeMulligans.setModel(new SpinnerNumberModel(0, 0, 5, 1));
this.spnQuitRatio.setModel(new SpinnerNumberModel(100, 0, 100, 5));
+ this.spnMinimumRating.setModel(new SpinnerNumberModel(0, 0, 3000, 10));
this.spnEdhPowerLevel.setModel(new SpinnerNumberModel(100, 0, 100, 5));
MageFrame.getUI().addButton(MageComponents.NEW_TABLE_OK_BUTTON, btnOK);
}
@@ -102,8 +103,10 @@ public class NewTableDialog extends MageDialog {
btnPreviousConfiguration2 = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
lblQuitRatio = new javax.swing.JLabel();
+ lblMinimumRating = new javax.swing.JLabel();
lblEdhPowerLevel = new javax.swing.JLabel();
spnQuitRatio = new javax.swing.JSpinner();
+ spnMinimumRating = new javax.swing.JSpinner();
spnEdhPowerLevel = new javax.swing.JSpinner();
setTitle("New Table");
@@ -186,9 +189,11 @@ public class NewTableDialog extends MageDialog {
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
lblQuitRatio.setText("Allowed quit %");
+ lblMinimumRating.setText("Minimum rating");
lblEdhPowerLevel.setText("EDH power level");
spnQuitRatio.setToolTipText("Players with quit % more than this value can't join this table");
+ spnMinimumRating.setToolTipText("Players with rating less than this value can't join this table");
spnEdhPowerLevel.setToolTipText("Players with decks with a higher power level can't join this table");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
@@ -239,9 +244,10 @@ public class NewTableDialog extends MageDialog {
.addComponent(lblQuitRatio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(lblEdhPowerLevel)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(lblMinimumRating)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(spnEdhPowerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))))
+ .addComponent(spnMinimumRating, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
@@ -270,7 +276,11 @@ public class NewTableDialog extends MageDialog {
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNumWins)
- .addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(lblEdhPowerLevel)
+ .addComponent(spnEdhPowerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jSeparator2)
.addComponent(player1Panel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
@@ -297,14 +307,13 @@ public class NewTableDialog extends MageDialog {
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbDeckType)
+ .addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(chkRated)
.addComponent(lblQuitRatio)
- .addComponent(chkRated)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(lblEdhPowerLevel)
- .addComponent(chkRated)
- .addComponent(spnEdhPowerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(lblMinimumRating)
+ .addComponent(spnMinimumRating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@@ -326,6 +335,7 @@ public class NewTableDialog extends MageDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblSkillLevel)
.addComponent(lblNumWins)
+ .addComponent(lblEdhPowerLevel)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblRange)
.addComponent(lblAttack)))
@@ -334,7 +344,8 @@ public class NewTableDialog extends MageDialog {
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbAttackOption, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbSkillLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
+ .addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(spnEdhPowerLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -394,6 +405,7 @@ public class NewTableDialog extends MageDialog {
options.setFreeMulligans((Integer) this.spnFreeMulligans.getValue());
options.setPassword(this.txtPassword.getText());
options.setQuitRatio((Integer) this.spnQuitRatio.getValue());
+ options.setMinimumRating((Integer) this.spnMinimumRating.getValue());
options.setEdhPowerLevel((Integer) this.spnEdhPowerLevel.getValue());
String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> "");
options.setBannedUsers(IgnoreList.ignoreList(serverAddress));
@@ -695,6 +707,7 @@ public class NewTableDialog extends MageDialog {
}
this.spnQuitRatio.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO, "100")));
+ this.spnMinimumRating.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_MINIMUM_RATING + versionStr, "0")));
this.spnEdhPowerLevel.setValue(0);
}
@@ -729,6 +742,7 @@ public class NewTableDialog extends MageDialog {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SPECTATORS_ALLOWED + versionStr, options.isSpectatorsAllowed() ? "Yes" : "No");
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PLANECHASE + versionStr, options.isPlaneChase() ? "Yes" : "No");
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, Integer.toString(options.getQuitRatio()));
+ PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_MINIMUM_RATING + versionStr, Integer.toString(options.getMinimumRating()));
StringBuilder playerTypesString = new StringBuilder();
for (Object player : players) {
if (playerTypesString.length() > 0) {
@@ -770,6 +784,7 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JLabel lblNumWins;
private javax.swing.JLabel lblPassword;
private javax.swing.JLabel lblQuitRatio;
+ private javax.swing.JLabel lblMinimumRating;
private javax.swing.JLabel lblEdhPowerLevel;
private javax.swing.JLabel lblRange;
private javax.swing.JLabel lblSkillLevel;
@@ -779,6 +794,7 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JSpinner spnNumPlayers;
private javax.swing.JSpinner spnNumWins;
private javax.swing.JSpinner spnQuitRatio;
+ private javax.swing.JSpinner spnMinimumRating;
private javax.swing.JSpinner spnEdhPowerLevel;
private javax.swing.JTextField txtName;
private javax.swing.JTextField txtPassword;
diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java
index ee0d5aded56..fef9bdab407 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java
@@ -75,6 +75,7 @@ public class NewTournamentDialog extends MageDialog {
this.spnConstructTime.setModel(new SpinnerNumberModel(10, CONSTRUCTION_TIME_MIN, CONSTRUCTION_TIME_MAX, 2));
this.spnNumRounds.setModel(new SpinnerNumberModel(2, 2, 10, 1));
this.spnQuitRatio.setModel(new SpinnerNumberModel(100, 0, 100, 5));
+ this.spnMinimumRating.setModel(new SpinnerNumberModel(0, 0, 3000, 10));
}
public void showDialog(UUID roomId) {
@@ -165,6 +166,8 @@ public class NewTournamentDialog extends MageDialog {
pnlRandomPacks = new javax.swing.JPanel();
lblQuitRatio = new javax.swing.JLabel();
spnQuitRatio = new javax.swing.JSpinner();
+ lblMinimumRating = new javax.swing.JLabel();
+ spnMinimumRating = new javax.swing.JSpinner();
setTitle("New Tournament");
@@ -315,8 +318,10 @@ public class NewTournamentDialog extends MageDialog {
pnlRandomPacks.setLayout(new javax.swing.BoxLayout(pnlRandomPacks, javax.swing.BoxLayout.Y_AXIS));
lblQuitRatio.setText("Allowed quit %:");
+ lblMinimumRating.setText("Minimum rating:");
spnQuitRatio.setToolTipText("Players with quit % more than this value can't join this table");
+ spnMinimumRating.setToolTipText("Players with rating less than this value can't join this table");
spnNumSeats.setToolTipText("The number of seats for each duel. If more than 2, will set number of wins to 1");
spnNumPlayers.setToolTipText("The total number of players who will draft");
@@ -386,11 +391,15 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(lblNumWins)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblQuitRatio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(lblMinimumRating)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(spnMinimumRating, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(chkRated))
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
@@ -444,6 +453,8 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblQuitRatio)
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(lblMinimumRating)
+ .addComponent(spnMinimumRating, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(chkRated))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@@ -522,6 +533,7 @@ public class NewTournamentDialog extends MageDialog {
tOptions.setWatchingAllowed(cbAllowSpectators.isSelected());
tOptions.setPlaneChase(cbPlaneChase.isSelected());
tOptions.setQuitRatio((Integer) spnQuitRatio.getValue());
+ tOptions.setMinimumRating((Integer) spnMinimumRating.getValue());
for (TournamentPlayerPanel player : players) {
tOptions.getPlayerTypes().add((PlayerType) player.getPlayerType().getSelectedItem());
}
@@ -1065,6 +1077,7 @@ public class NewTournamentDialog extends MageDialog {
this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_FREE_MULLIGANS + versionStr, "0")));
this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_WINS + versionStr, "2")));
this.spnQuitRatio.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_QUIT_RATIO + versionStr, "100")));
+ this.spnMinimumRating.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_MINIMUM_RATING + versionStr, "0")));
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
activatePanelElements(tournamentType);
@@ -1150,6 +1163,7 @@ public class NewTournamentDialog extends MageDialog {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_FREE_MULLIGANS + versionStr, Integer.toString(tOptions.getMatchOptions().getFreeMulligans()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_WINS + versionStr, Integer.toString(tOptions.getMatchOptions().getWinsNeeded()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_QUIT_RATIO + versionStr, Integer.toString(tOptions.getQuitRatio()));
+ PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_MINIMUM_RATING + versionStr, Integer.toString(tOptions.getMinimumRating()));
if (tOptions.getTournamentType().startsWith("Sealed")) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_SEALED + versionStr, tOptions.getLimitedOptions().getSetCodes().toString());
@@ -1221,6 +1235,7 @@ public class NewTournamentDialog extends MageDialog {
private javax.swing.JLabel lblPassword;
private javax.swing.JLabel lblPlayer1;
private javax.swing.JLabel lblQuitRatio;
+ private javax.swing.JLabel lblMinimumRating;
private javax.swing.JLabel lblTournamentType;
private mage.client.table.NewPlayerPanel player1Panel;
private javax.swing.JPanel pnlDraftOptions;
@@ -1235,6 +1250,7 @@ public class NewTournamentDialog extends MageDialog {
private javax.swing.JSpinner spnNumRounds;
private javax.swing.JSpinner spnNumWins;
private javax.swing.JSpinner spnQuitRatio;
+ private javax.swing.JSpinner spnMinimumRating;
private javax.swing.JTextField txtName;
private javax.swing.JTextField txtPassword;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
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 4d595a005a8..5826d2c85b3 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java
@@ -222,6 +222,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_NEW_TABLE_NUMBER_PLAYERS = "newTableNumberPlayers";
public static final String KEY_NEW_TABLE_PLAYER_TYPES = "newTablePlayerTypes";
public static final String KEY_NEW_TABLE_QUIT_RATIO = "newTableQuitRatio";
+ public static final String KEY_NEW_TABLE_MINIMUM_RATING = "newTableMinimumRating";
public static final String KEY_NEW_TABLE_RATED = "newTableRated";
// pref setting for new tournament dialog
@@ -243,6 +244,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS = "newTournamentAllowRollbacks";
public static final String KEY_NEW_TOURNAMENT_DECK_FILE = "newTournamentDeckFile";
public static final String KEY_NEW_TOURNAMENT_QUIT_RATIO = "newTournamentQuitRatio";
+ public static final String KEY_NEW_TOURNAMENT_MINIMUM_RATING = "newTournamentMinimumRating";
public static final String KEY_NEW_TOURNAMENT_RATED = "newTournamentRated";
// pref setting for deck generator
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 30c5d8e4ac9..59963ff2999 100644
--- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java
+++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java
@@ -196,161 +196,162 @@
}
});*/
- // default sort by created date (last games from above)
- ArrayList list = new ArrayList();
- list.add(new RowSorter.SortKey(TableTableModel.COLUMN_CREATED, SortOrder.DESCENDING));
- activeTablesSorter.setSortKeys(list);
- TableUtil.setColumnWidthAndOrder(tableTables, DEFAULT_COLUMNS_WIDTH, KEY_TABLES_COLUMNS_WIDTH, KEY_TABLES_COLUMNS_ORDER);
+ // default sort by created date (last games from above)
+ ArrayList list = new ArrayList();
+ list.add(new RowSorter.SortKey(TableTableModel.COLUMN_CREATED, SortOrder.DESCENDING));
+ activeTablesSorter.setSortKeys(list);
- // 2. TABLE COMPLETED
- completedTablesSorter = new MageTableRowSorter(matchesModel);
- tableCompleted.setRowSorter(completedTablesSorter);
+ TableUtil.setColumnWidthAndOrder(tableTables, DEFAULT_COLUMNS_WIDTH, KEY_TABLES_COLUMNS_WIDTH, KEY_TABLES_COLUMNS_ORDER);
- // duration
- tableCompleted.getColumnModel().getColumn(MatchesTableModel.COLUMN_DURATION).setCellRenderer(durationCellRenderer);
- // start-end
- tableCompleted.getColumnModel().getColumn(MatchesTableModel.COLUMN_START).setCellRenderer(datetimeCellRenderer);
- tableCompleted.getColumnModel().getColumn(MatchesTableModel.COLUMN_END).setCellRenderer(datetimeCellRenderer);
- // default sort by ended date (last games from above)
- ArrayList list2 = new ArrayList();
- list2.add(new RowSorter.SortKey(MatchesTableModel.COLUMN_END, SortOrder.DESCENDING));
- completedTablesSorter.setSortKeys(list2);
+ // 2. TABLE COMPLETED
+ completedTablesSorter = new MageTableRowSorter(matchesModel);
+ tableCompleted.setRowSorter(completedTablesSorter);
- // 3. CHAT
- chatPanelMain.getUserChatPanel().useExtendedView(ChatPanelBasic.VIEW_MODE.NONE);
- chatPanelMain.getUserChatPanel().setBorder(null);
- chatPanelMain.getUserChatPanel().setChatType(ChatPanelBasic.ChatType.TABLES);
+ // duration
+ tableCompleted.getColumnModel().getColumn(MatchesTableModel.COLUMN_DURATION).setCellRenderer(durationCellRenderer);
+ // start-end
+ tableCompleted.getColumnModel().getColumn(MatchesTableModel.COLUMN_START).setCellRenderer(datetimeCellRenderer);
+ tableCompleted.getColumnModel().getColumn(MatchesTableModel.COLUMN_END).setCellRenderer(datetimeCellRenderer);
+ // default sort by ended date (last games from above)
+ ArrayList list2 = new ArrayList();
+ list2.add(new RowSorter.SortKey(MatchesTableModel.COLUMN_END, SortOrder.DESCENDING));
+ completedTablesSorter.setSortKeys(list2);
- // 4. BUTTONS
- filterButtons = new JToggleButton[]{btnStateWaiting, btnStateActive, btnStateFinished,
- btnTypeMatch, btnTypeTourneyConstructed, btnTypeTourneyLimited,
- btnFormatBlock, btnFormatStandard, btnFormatModern, btnFormatLegacy, btnFormatVintage, btnFormatCommander, btnFormatTinyLeader, btnFormatLimited, btnFormatOther,
- btnSkillBeginner, btnSkillCasual, btnSkillSerious, btnRated, btnUnrated, btnOpen, btnPassword};
+ // 3. CHAT
+ chatPanelMain.getUserChatPanel().useExtendedView(ChatPanelBasic.VIEW_MODE.NONE);
+ chatPanelMain.getUserChatPanel().setBorder(null);
+ chatPanelMain.getUserChatPanel().setChatType(ChatPanelBasic.ChatType.TABLES);
- JComponent[] components = new JComponent[]{chatPanelMain, jSplitPane1, jScrollPaneTablesActive, jScrollPaneTablesFinished, jPanelTop, jPanelTables};
- for (JComponent component : components) {
- component.setOpaque(false);
- }
+ // 4. BUTTONS
+ filterButtons = new JToggleButton[]{btnStateWaiting, btnStateActive, btnStateFinished,
+ btnTypeMatch, btnTypeTourneyConstructed, btnTypeTourneyLimited,
+ btnFormatBlock, btnFormatStandard, btnFormatModern, btnFormatLegacy, btnFormatVintage, btnFormatCommander, btnFormatTinyLeader, btnFormatLimited, btnFormatOther,
+ btnSkillBeginner, btnSkillCasual, btnSkillSerious, btnRated, btnUnrated, btnOpen, btnPassword};
- jScrollPaneTablesActive.getViewport().setBackground(new Color(255, 255, 255, 50));
- jScrollPaneTablesFinished.getViewport().setBackground(new Color(255, 255, 255, 50));
+ JComponent[] components = new JComponent[]{chatPanelMain, jSplitPane1, jScrollPaneTablesActive, jScrollPaneTablesFinished, jPanelTop, jPanelTables};
+ for (JComponent component : components) {
+ component.setOpaque(false);
+ }
- restoreFilters();
- setGUISize();
+ jScrollPaneTablesActive.getViewport().setBackground(new Color(255, 255, 255, 50));
+ jScrollPaneTablesFinished.getViewport().setBackground(new Color(255, 255, 255, 50));
- Action openTableAction;
- openTableAction = new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- int modelRow = Integer.valueOf(e.getActionCommand());
- UUID tableId = (UUID) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 3);
- UUID gameId = (UUID) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 2);
- String action = (String) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN);
- String deckType = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_DECK_TYPE);
- boolean isTournament = (Boolean) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 1);
- String owner = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_OWNER);
- String pwdColumn = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_PASSWORD);
- switch (action) {
- case "Join":
- if (owner.equals(SessionHandler.getUserName()) || owner.startsWith(SessionHandler.getUserName() + ',')) {
- try {
- JDesktopPane desktopPane = (JDesktopPane) MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
- JInternalFrame[] windows = desktopPane.getAllFramesInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
- for (JInternalFrame frame : windows) {
- if (frame.getTitle().equals("Waiting for players")) {
- frame.toFront();
- frame.setVisible(true);
- try {
- frame.setSelected(true);
- } catch (PropertyVetoException ve) {
- LOGGER.error(ve);
- }
- }
+ restoreFilters();
+ setGUISize();
- }
- } catch (InterruptedException ex) {
- LOGGER.error(ex);
- }
- return;
- }
- if (isTournament) {
- LOGGER.info("Joining tournament " + tableId);
- if (deckType.startsWith("Limited")) {
- if (TableTableModel.PASSWORD_VALUE_YES.equals(pwdColumn)) {
- joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
- } else {
- SessionHandler.joinTournamentTable(roomId, tableId, SessionHandler.getUserName(), PlayerType.HUMAN, 1, null, "");
- }
- } else {
- joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
- }
- } else {
- LOGGER.info("Joining table " + tableId);
- joinTableDialog.showDialog(roomId, tableId, false, false);
- }
- break;
- case "Remove":
- UserRequestMessage message = new UserRequestMessage("Removing table", "Are you sure you want to remove table?");
- message.setButton1("No", null);
- message.setButton2("Yes", PlayerAction.CLIENT_REMOVE_TABLE);
- MageFrame.getInstance().showUserRequestDialog(message);
- break;
- case "Show":
- if (isTournament) {
- LOGGER.info("Showing tournament table " + tableId);
- SessionHandler.watchTable(roomId, tableId);
- }
- break;
- case "Watch":
- if (!isTournament) {
- LOGGER.info("Watching table " + tableId);
- SessionHandler.watchTable(roomId, tableId);
- }
- break;
- case "Replay":
- LOGGER.info("Replaying game " + gameId);
- SessionHandler.replayGame(gameId);
- break;
- }
- }
- };
+ Action openTableAction;
+ openTableAction = new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ int modelRow = Integer.valueOf(e.getActionCommand());
+ UUID tableId = (UUID) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 3);
+ UUID gameId = (UUID) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 2);
+ String action = (String) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN);
+ String deckType = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_DECK_TYPE);
+ boolean isTournament = (Boolean) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 1);
+ String owner = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_OWNER);
+ String pwdColumn = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_PASSWORD);
+ switch (action) {
+ case "Join":
+ if (owner.equals(SessionHandler.getUserName()) || owner.startsWith(SessionHandler.getUserName() + ',')) {
+ try {
+ JDesktopPane desktopPane = (JDesktopPane) MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
+ JInternalFrame[] windows = desktopPane.getAllFramesInLayer(javax.swing.JLayeredPane.DEFAULT_LAYER);
+ for (JInternalFrame frame : windows) {
+ if (frame.getTitle().equals("Waiting for players")) {
+ frame.toFront();
+ frame.setVisible(true);
+ try {
+ frame.setSelected(true);
+ } catch (PropertyVetoException ve) {
+ LOGGER.error(ve);
+ }
+ }
- Action closedTableAction;
- closedTableAction = new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- int modelRow = Integer.valueOf(e.getActionCommand());
- String action = (String) matchesModel.getValueAt(modelRow, MatchesTableModel.COLUMN_ACTION);
- switch (action) {
- case "Replay":
- java.util.List gameList = matchesModel.getListofGames(modelRow);
- if (gameList != null && !gameList.isEmpty()) {
- if (gameList.size() == 1) {
- SessionHandler.replayGame(gameList.get(0));
- } else {
- gameChooser.show(gameList, MageFrame.getDesktop().getMousePosition());
- }
- }
- // MageFrame.getDesktop().showTournament(tournamentId);
- break;
- case "Show":
- if (matchesModel.isTournament(modelRow)) {
- LOGGER.info("Showing tournament table " + matchesModel.getTableId(modelRow));
- SessionHandler.watchTable(roomId, matchesModel.getTableId(modelRow));
- }
- break;
- }
- }
- };
+ }
+ } catch (InterruptedException ex) {
+ LOGGER.error(ex);
+ }
+ return;
+ }
+ if (isTournament) {
+ LOGGER.info("Joining tournament " + tableId);
+ if (deckType.startsWith("Limited")) {
+ if (TableTableModel.PASSWORD_VALUE_YES.equals(pwdColumn)) {
+ joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
+ } else {
+ SessionHandler.joinTournamentTable(roomId, tableId, SessionHandler.getUserName(), PlayerType.HUMAN, 1, null, "");
+ }
+ } else {
+ joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
+ }
+ } else {
+ LOGGER.info("Joining table " + tableId);
+ joinTableDialog.showDialog(roomId, tableId, false, false);
+ }
+ break;
+ case "Remove":
+ UserRequestMessage message = new UserRequestMessage("Removing table", "Are you sure you want to remove table?");
+ message.setButton1("No", null);
+ message.setButton2("Yes", PlayerAction.CLIENT_REMOVE_TABLE);
+ MageFrame.getInstance().showUserRequestDialog(message);
+ break;
+ case "Show":
+ if (isTournament) {
+ LOGGER.info("Showing tournament table " + tableId);
+ SessionHandler.watchTable(roomId, tableId);
+ }
+ break;
+ case "Watch":
+ if (!isTournament) {
+ LOGGER.info("Watching table " + tableId);
+ SessionHandler.watchTable(roomId, tableId);
+ }
+ break;
+ case "Replay":
+ LOGGER.info("Replaying game " + gameId);
+ SessionHandler.replayGame(gameId);
+ break;
+ }
+ }
+ };
- // !!!! adds action buttons to the table panel (don't delete this)
- actionButton1 = new ButtonColumn(tableTables, openTableAction, tableTables.convertColumnIndexToView(TableTableModel.ACTION_COLUMN));
- actionButton2 = new ButtonColumn(tableCompleted, closedTableAction, tableCompleted.convertColumnIndexToView(MatchesTableModel.COLUMN_ACTION));
- // !!!!
- addTableDoubleClickListener(tableTables, openTableAction);
- addTableDoubleClickListener(tableCompleted, closedTableAction);
- }
+ Action closedTableAction;
+ closedTableAction = new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ int modelRow = Integer.valueOf(e.getActionCommand());
+ String action = (String) matchesModel.getValueAt(modelRow, MatchesTableModel.COLUMN_ACTION);
+ switch (action) {
+ case "Replay":
+ java.util.List gameList = matchesModel.getListofGames(modelRow);
+ if (gameList != null && !gameList.isEmpty()) {
+ if (gameList.size() == 1) {
+ SessionHandler.replayGame(gameList.get(0));
+ } else {
+ gameChooser.show(gameList, MageFrame.getDesktop().getMousePosition());
+ }
+ }
+ // MageFrame.getDesktop().showTournament(tournamentId);
+ break;
+ case "Show":
+ if (matchesModel.isTournament(modelRow)) {
+ LOGGER.info("Showing tournament table " + matchesModel.getTableId(modelRow));
+ SessionHandler.watchTable(roomId, matchesModel.getTableId(modelRow));
+ }
+ break;
+ }
+ }
+ };
+
+ // !!!! adds action buttons to the table panel (don't delete this)
+ actionButton1 = new ButtonColumn(tableTables, openTableAction, tableTables.convertColumnIndexToView(TableTableModel.ACTION_COLUMN));
+ actionButton2 = new ButtonColumn(tableCompleted, closedTableAction, tableCompleted.convertColumnIndexToView(MatchesTableModel.COLUMN_ACTION));
+ // !!!!
+ addTableDoubleClickListener(tableTables, openTableAction);
+ addTableDoubleClickListener(tableCompleted, closedTableAction);
+ }
private void addTableDoubleClickListener(JTable table, Action action) {
table.addMouseListener(new MouseAdapter() {
@@ -369,1437 +370,1441 @@
});
}
- public void cleanUp() {
- saveGuiSettings();
- chatPanelMain.cleanUp();
- }
+ public void cleanUp() {
+ saveGuiSettings();
+ chatPanelMain.cleanUp();
+ }
- public void changeGUISize() {
- chatPanelMain.changeGUISize();
- actionButton1.changeGUISize();
- actionButton2.changeGUISize();
- setGUISize();
- }
+ public void changeGUISize() {
+ chatPanelMain.changeGUISize();
+ actionButton1.changeGUISize();
+ actionButton2.changeGUISize();
+ setGUISize();
+ }
- private void setGUISize() {
- tableTables.getTableHeader().setFont(GUISizeHelper.tableFont);
- tableTables.setFont(GUISizeHelper.tableFont);
- tableTables.setRowHeight(GUISizeHelper.getTableRowHeight());
+ private void setGUISize() {
+ tableTables.getTableHeader().setFont(GUISizeHelper.tableFont);
+ tableTables.setFont(GUISizeHelper.tableFont);
+ tableTables.setRowHeight(GUISizeHelper.getTableRowHeight());
- tableCompleted.getTableHeader().setFont(GUISizeHelper.tableFont);
- tableCompleted.setFont(GUISizeHelper.tableFont);
- tableCompleted.setRowHeight(GUISizeHelper.getTableRowHeight());
+ tableCompleted.getTableHeader().setFont(GUISizeHelper.tableFont);
+ tableCompleted.setFont(GUISizeHelper.tableFont);
+ tableCompleted.setRowHeight(GUISizeHelper.getTableRowHeight());
- jSplitPane1.setDividerSize(GUISizeHelper.dividerBarSize);
- jSplitPaneTables.setDividerSize(GUISizeHelper.dividerBarSize);
- jScrollPaneTablesActive.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
- jScrollPaneTablesActive.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
+ jSplitPane1.setDividerSize(GUISizeHelper.dividerBarSize);
+ jSplitPaneTables.setDividerSize(GUISizeHelper.dividerBarSize);
+ jScrollPaneTablesActive.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
+ jScrollPaneTablesActive.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
- ImageIcon icon = new javax.swing.ImageIcon(getClass().getResource("/buttons/state_waiting.png"));
- Image img = icon.getImage();
- Image newimg = img.getScaledInstance(GUISizeHelper.menuFont.getSize(), GUISizeHelper.menuFont.getSize(), java.awt.Image.SCALE_SMOOTH);
- btnStateWaiting.setIcon(new ImageIcon(newimg));
+ ImageIcon icon = new javax.swing.ImageIcon(getClass().getResource("/buttons/state_waiting.png"));
+ Image img = icon.getImage();
+ Image newimg = img.getScaledInstance(GUISizeHelper.menuFont.getSize(), GUISizeHelper.menuFont.getSize(), java.awt.Image.SCALE_SMOOTH);
+ btnStateWaiting.setIcon(new ImageIcon(newimg));
- icon = new javax.swing.ImageIcon(getClass().getResource("/buttons/state_active.png"));
- img = icon.getImage();
- newimg = img.getScaledInstance(GUISizeHelper.menuFont.getSize(), GUISizeHelper.menuFont.getSize(), java.awt.Image.SCALE_SMOOTH);
- btnStateActive.setIcon(new ImageIcon(newimg));
+ icon = new javax.swing.ImageIcon(getClass().getResource("/buttons/state_active.png"));
+ img = icon.getImage();
+ newimg = img.getScaledInstance(GUISizeHelper.menuFont.getSize(), GUISizeHelper.menuFont.getSize(), java.awt.Image.SCALE_SMOOTH);
+ btnStateActive.setIcon(new ImageIcon(newimg));
- icon = new javax.swing.ImageIcon(getClass().getResource("/buttons/state_finished.png"));
- img = icon.getImage();
- newimg = img.getScaledInstance(GUISizeHelper.menuFont.getSize(), GUISizeHelper.menuFont.getSize(), java.awt.Image.SCALE_SMOOTH);
- btnStateFinished.setIcon(new ImageIcon(newimg));
+ icon = new javax.swing.ImageIcon(getClass().getResource("/buttons/state_finished.png"));
+ img = icon.getImage();
+ newimg = img.getScaledInstance(GUISizeHelper.menuFont.getSize(), GUISizeHelper.menuFont.getSize(), java.awt.Image.SCALE_SMOOTH);
+ btnStateFinished.setIcon(new ImageIcon(newimg));
- int iconSize = 48 + GUISizeHelper.menuFont.getSize() * 2 - 15;
- icon = new javax.swing.ImageIcon(getClass().getResource("/buttons/match_new.png"));
- img = icon.getImage();
- newimg = img.getScaledInstance(iconSize, iconSize, java.awt.Image.SCALE_SMOOTH);
- btnNewTable.setIcon(new ImageIcon(newimg));
+ int iconSize = 48 + GUISizeHelper.menuFont.getSize() * 2 - 15;
+ icon = new javax.swing.ImageIcon(getClass().getResource("/buttons/match_new.png"));
+ img = icon.getImage();
+ newimg = img.getScaledInstance(iconSize, iconSize, java.awt.Image.SCALE_SMOOTH);
+ btnNewTable.setIcon(new ImageIcon(newimg));
- icon = new javax.swing.ImageIcon(getClass().getResource("/buttons/tourney_new.png"));
- img = icon.getImage();
- newimg = img.getScaledInstance(iconSize, iconSize, java.awt.Image.SCALE_SMOOTH);
- btnNewTournament.setIcon(new ImageIcon(newimg));
+ icon = new javax.swing.ImageIcon(getClass().getResource("/buttons/tourney_new.png"));
+ img = icon.getImage();
+ newimg = img.getScaledInstance(iconSize, iconSize, java.awt.Image.SCALE_SMOOTH);
+ btnNewTournament.setIcon(new ImageIcon(newimg));
- for (JToggleButton component : filterButtons) {
- component.setFont(GUISizeHelper.menuFont);
- }
- Dimension newDimension = new Dimension((int) jPanelBottom.getPreferredSize().getWidth(), GUISizeHelper.menuFont.getSize() + 28);
- jPanelBottom.setMinimumSize(newDimension);
- jPanelBottom.setPreferredSize(newDimension);
- jButtonFooterNext.setFont(GUISizeHelper.menuFont);
- jLabelFooterLabel.setFont(new Font(GUISizeHelper.menuFont.getName(), Font.BOLD, GUISizeHelper.menuFont.getSize()));
- jLabelFooterText.setFont(GUISizeHelper.menuFont);
- }
+ for (JToggleButton component : filterButtons) {
+ component.setFont(GUISizeHelper.menuFont);
+ }
+ Dimension newDimension = new Dimension((int) jPanelBottom.getPreferredSize().getWidth(), GUISizeHelper.menuFont.getSize() + 28);
+ jPanelBottom.setMinimumSize(newDimension);
+ jPanelBottom.setPreferredSize(newDimension);
+ jButtonFooterNext.setFont(GUISizeHelper.menuFont);
+ jLabelFooterLabel.setFont(new Font(GUISizeHelper.menuFont.getName(), Font.BOLD, GUISizeHelper.menuFont.getSize()));
+ jLabelFooterText.setFont(GUISizeHelper.menuFont);
+ }
- private void saveDividerLocations() {
- // save divider locations and divider saveDividerLocations
- GuiDisplayUtil.saveCurrentBoundsToPrefs();
- GuiDisplayUtil.saveDividerLocationToPrefs(KEY_TABLES_DIVIDER_LOCATION_1, this.jSplitPane1.getDividerLocation());
- GuiDisplayUtil.saveDividerLocationToPrefs(KEY_TABLES_DIVIDER_LOCATION_2, this.jSplitPaneTables.getDividerLocation());
- GuiDisplayUtil.saveDividerLocationToPrefs(KEY_TABLES_DIVIDER_LOCATION_3, chatPanelMain.getSplitDividerLocation());
- }
+ private void saveDividerLocations() {
+ // save divider locations and divider saveDividerLocations
+ GuiDisplayUtil.saveCurrentBoundsToPrefs();
+ GuiDisplayUtil.saveDividerLocationToPrefs(KEY_TABLES_DIVIDER_LOCATION_1, this.jSplitPane1.getDividerLocation());
+ GuiDisplayUtil.saveDividerLocationToPrefs(KEY_TABLES_DIVIDER_LOCATION_2, this.jSplitPaneTables.getDividerLocation());
+ GuiDisplayUtil.saveDividerLocationToPrefs(KEY_TABLES_DIVIDER_LOCATION_3, chatPanelMain.getSplitDividerLocation());
+ }
- private void restoreFilters() {
- TableUtil.setActiveFilters(KEY_TABLES_FILTER_SETTINGS, filterButtons);
- setTableFilter();
- }
+ private void restoreFilters() {
+ TableUtil.setActiveFilters(KEY_TABLES_FILTER_SETTINGS, filterButtons);
+ setTableFilter();
+ }
- private void saveGuiSettings() {
- TableUtil.saveActiveFiltersToPrefs(KEY_TABLES_FILTER_SETTINGS, filterButtons);
- TableUtil.saveColumnWidthAndOrderToPrefs(tableTables, KEY_TABLES_COLUMNS_WIDTH, KEY_TABLES_COLUMNS_ORDER);
- }
+ private void saveGuiSettings() {
+ TableUtil.saveActiveFiltersToPrefs(KEY_TABLES_FILTER_SETTINGS, filterButtons);
+ TableUtil.saveColumnWidthAndOrderToPrefs(tableTables, KEY_TABLES_COLUMNS_WIDTH, KEY_TABLES_COLUMNS_ORDER);
+ }
- private void restoreDividers() {
- Rectangle currentBounds = MageFrame.getDesktop().getBounds();
- if (currentBounds != null) {
- String firstDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_1, null);
- String tableDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_2, null);
- String chatDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_3, null);
- GuiDisplayUtil.restoreDividerLocations(currentBounds, firstDivider, jSplitPane1);
- GuiDisplayUtil.restoreDividerLocations(currentBounds, tableDivider, jSplitPaneTables);
- GuiDisplayUtil.restoreDividerLocations(currentBounds, chatDivider, chatPanelMain);
- }
- }
+ private void restoreDividers() {
+ Rectangle currentBounds = MageFrame.getDesktop().getBounds();
+ if (currentBounds != null) {
+ String firstDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_1, null);
+ String tableDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_2, null);
+ String chatDivider = PreferencesDialog.getCachedValue(KEY_TABLES_DIVIDER_LOCATION_3, null);
+ GuiDisplayUtil.restoreDividerLocations(currentBounds, firstDivider, jSplitPane1);
+ GuiDisplayUtil.restoreDividerLocations(currentBounds, tableDivider, jSplitPaneTables);
+ GuiDisplayUtil.restoreDividerLocations(currentBounds, chatDivider, chatPanelMain);
+ }
+ }
- public Map getUIComponents() {
- Map components = new HashMap<>();
+ public Map getUIComponents() {
+ Map components = new HashMap<>();
- components.put("jScrollPane1", jScrollPaneTablesActive);
- components.put("jScrollPane1ViewPort", jScrollPaneTablesActive.getViewport());
- components.put("jPanel1", jPanelTop);
- components.put("tablesPanel", this);
+ components.put("jScrollPane1", jScrollPaneTablesActive);
+ components.put("jScrollPane1ViewPort", jScrollPaneTablesActive.getViewport());
+ components.put("jPanel1", jPanelTop);
+ components.put("tablesPanel", this);
- return components;
- }
+ return components;
+ }
- public void updateTables(Collection tables) {
- try {
- tableModel.loadData(tables);
- this.tableTables.repaint();
- } catch (MageRemoteException ex) {
- hideTables();
- }
- }
+ public void updateTables(Collection tables) {
+ try {
+ tableModel.loadData(tables);
+ this.tableTables.repaint();
+ } catch (MageRemoteException ex) {
+ hideTables();
+ }
+ }
- public void updateMatches(Collection matches) {
- try {
- matchesModel.loadData(matches);
- this.tableCompleted.repaint();
- } catch (MageRemoteException ex) {
- hideTables();
- }
- }
+ public void updateMatches(Collection matches) {
+ try {
+ matchesModel.loadData(matches);
+ this.tableCompleted.repaint();
+ } catch (MageRemoteException ex) {
+ hideTables();
+ }
+ }
- public void startTasks() {
- if (SessionHandler.getSession() != null) {
- if (updateTablesTask == null || updateTablesTask.isDone()) {
- updateTablesTask = new UpdateTablesTask(roomId, this);
- updateTablesTask.execute();
- }
- if (updatePlayersTask == null || updatePlayersTask.isDone()) {
- updatePlayersTask = new UpdatePlayersTask(roomId, this.chatPanelMain);
- updatePlayersTask.execute();
- }
- if (this.btnStateFinished.isSelected()) {
- if (updateMatchesTask == null || updateMatchesTask.isDone()) {
- updateMatchesTask = new UpdateMatchesTask(roomId, this);
- updateMatchesTask.execute();
- }
- } else if (updateMatchesTask != null) {
- updateMatchesTask.cancel(true);
- }
- }
- }
+ public void startTasks() {
+ if (SessionHandler.getSession() != null) {
+ if (updateTablesTask == null || updateTablesTask.isDone()) {
+ updateTablesTask = new UpdateTablesTask(roomId, this);
+ updateTablesTask.execute();
+ }
+ if (updatePlayersTask == null || updatePlayersTask.isDone()) {
+ updatePlayersTask = new UpdatePlayersTask(roomId, this.chatPanelMain);
+ updatePlayersTask.execute();
+ }
+ if (this.btnStateFinished.isSelected()) {
+ if (updateMatchesTask == null || updateMatchesTask.isDone()) {
+ updateMatchesTask = new UpdateMatchesTask(roomId, this);
+ updateMatchesTask.execute();
+ }
+ } else if (updateMatchesTask != null) {
+ updateMatchesTask.cancel(true);
+ }
+ }
+ }
- public void stopTasks() {
- if (updateTablesTask != null) {
- updateTablesTask.cancel(true);
- }
- if (updatePlayersTask != null) {
- updatePlayersTask.cancel(true);
- }
- if (updateMatchesTask != null) {
- updateMatchesTask.cancel(true);
- }
- }
+ public void stopTasks() {
+ if (updateTablesTask != null) {
+ updateTablesTask.cancel(true);
+ }
+ if (updatePlayersTask != null) {
+ updatePlayersTask.cancel(true);
+ }
+ if (updateMatchesTask != null) {
+ updateMatchesTask.cancel(true);
+ }
+ }
- public void showTables(UUID roomId) {
- this.roomId = roomId;
- UUID chatRoomId = null;
- if (SessionHandler.getSession() != null) {
- btnQuickStart.setVisible(SessionHandler.isTestMode());
- gameChooser.init();
- chatRoomId = SessionHandler.getRoomChatId(roomId).orElse(null);
- }
- if (newTableDialog == null) {
- newTableDialog = new NewTableDialog();
- MageFrame.getDesktop().add(newTableDialog, JLayeredPane.MODAL_LAYER);
- }
- if (newTournamentDialog == null) {
- newTournamentDialog = new NewTournamentDialog();
- MageFrame.getDesktop().add(newTournamentDialog, JLayeredPane.MODAL_LAYER);
- }
- if (joinTableDialog == null) {
- joinTableDialog = new JoinTableDialog();
- MageFrame.getDesktop().add(joinTableDialog, JLayeredPane.MODAL_LAYER);
- }
- if (chatRoomId != null) {
- this.chatPanelMain.getUserChatPanel().connect(chatRoomId);
- startTasks();
- this.setVisible(true);
- this.repaint();
- } else {
- hideTables();
- }
- //tableModel.setSession(session);
+ public void showTables(UUID roomId) {
+ this.roomId = roomId;
+ UUID chatRoomId = null;
+ if (SessionHandler.getSession() != null) {
+ btnQuickStart.setVisible(SessionHandler.isTestMode());
+ gameChooser.init();
+ chatRoomId = SessionHandler.getRoomChatId(roomId).orElse(null);
+ }
+ if (newTableDialog == null) {
+ newTableDialog = new NewTableDialog();
+ MageFrame.getDesktop().add(newTableDialog, JLayeredPane.MODAL_LAYER);
+ }
+ if (newTournamentDialog == null) {
+ newTournamentDialog = new NewTournamentDialog();
+ MageFrame.getDesktop().add(newTournamentDialog, JLayeredPane.MODAL_LAYER);
+ }
+ if (joinTableDialog == null) {
+ joinTableDialog = new JoinTableDialog();
+ MageFrame.getDesktop().add(joinTableDialog, JLayeredPane.MODAL_LAYER);
+ }
+ if (chatRoomId != null) {
+ this.chatPanelMain.getUserChatPanel().connect(chatRoomId);
+ startTasks();
+ this.setVisible(true);
+ this.repaint();
+ } else {
+ hideTables();
+ }
+ //tableModel.setSession(session);
- reloadMessages();
+ reloadMessages();
- MageFrame.getUI().addButton(MageComponents.NEW_GAME_BUTTON, btnNewTable);
+ MageFrame.getUI().addButton(MageComponents.NEW_GAME_BUTTON, btnNewTable);
- // divider locations have to be set with delay else values set are overwritten with system defaults
- Executors.newSingleThreadScheduledExecutor().schedule(() -> restoreDividers(), 300, TimeUnit.MILLISECONDS);
+ // divider locations have to be set with delay else values set are overwritten with system defaults
+ Executors.newSingleThreadScheduledExecutor().schedule(() -> restoreDividers(), 300, TimeUnit.MILLISECONDS);
- }
+ }
- protected void reloadMessages() {
- // reload server messages
- java.util.List serverMessages = SessionHandler.getServerMessages();
- synchronized (this) {
- this.messages = serverMessages;
- this.currentMessage = 0;
- }
- if (serverMessages.isEmpty()) {
- this.jPanelBottom.setVisible(false);
- } else {
- this.jPanelBottom.setVisible(true);
- URLHandler.RemoveMouseAdapter(jLabelFooterText);
- URLHandler.handleMessage(serverMessages.get(0), this.jLabelFooterText);
- this.jButtonFooterNext.setVisible(serverMessages.size() > 1);
- }
- }
+ protected void reloadMessages() {
+ // reload server messages
+ java.util.List serverMessages = SessionHandler.getServerMessages();
+ synchronized (this) {
+ this.messages = serverMessages;
+ this.currentMessage = 0;
+ }
+ if (serverMessages.isEmpty()) {
+ this.jPanelBottom.setVisible(false);
+ } else {
+ this.jPanelBottom.setVisible(true);
+ URLHandler.RemoveMouseAdapter(jLabelFooterText);
+ URLHandler.handleMessage(serverMessages.get(0), this.jLabelFooterText);
+ this.jButtonFooterNext.setVisible(serverMessages.size() > 1);
+ }
+ }
- public void hideTables() {
- this.saveDividerLocations();
- for (Component component : MageFrame.getDesktop().getComponents()) {
- if (component instanceof TableWaitingDialog) {
- ((TableWaitingDialog) component).closeDialog();
- }
- }
- stopTasks();
- this.chatPanelMain.getUserChatPanel().disconnect();
+ public void hideTables() {
+ this.saveDividerLocations();
+ for (Component component : MageFrame.getDesktop().getComponents()) {
+ if (component instanceof TableWaitingDialog) {
+ ((TableWaitingDialog) component).closeDialog();
+ }
+ }
+ stopTasks();
+ this.chatPanelMain.getUserChatPanel().disconnect();
- Component c = this.getParent();
- while (c != null && !(c instanceof TablesPane)) {
- c = c.getParent();
- }
- if (c != null) {
- ((TablesPane) c).hideFrame();
- }
- }
+ Component c = this.getParent();
+ while (c != null && !(c instanceof TablesPane)) {
+ c = c.getParent();
+ }
+ if (c != null) {
+ ((TablesPane) c).hideFrame();
+ }
+ }
- public ChatPanelBasic getChatPanel() {
- return chatPanelMain.getUserChatPanel();
- }
+ public ChatPanelBasic getChatPanel() {
+ return chatPanelMain.getUserChatPanel();
+ }
- public void setTableFilter() {
- // state
- java.util.List> stateFilterList = new ArrayList<>();
- if (btnStateWaiting.isSelected()) {
- stateFilterList.add(RowFilter.regexFilter("Waiting", TableTableModel.COLUMN_STATUS));
- }
- if (btnStateActive.isSelected()) {
- stateFilterList.add(RowFilter.regexFilter("Dueling|Constructing|Drafting|Sideboard", TableTableModel.COLUMN_STATUS));
- }
+ public void setTableFilter() {
+ // state
+ java.util.List> stateFilterList = new ArrayList<>();
+ if (btnStateWaiting.isSelected()) {
+ stateFilterList.add(RowFilter.regexFilter("Waiting", TableTableModel.COLUMN_STATUS));
+ }
+ if (btnStateActive.isSelected()) {
+ stateFilterList.add(RowFilter.regexFilter("Dueling|Constructing|Drafting|Sideboard", TableTableModel.COLUMN_STATUS));
+ }
- // type
- java.util.List> typeFilterList = new ArrayList<>();
- if (btnTypeMatch.isSelected()) {
- typeFilterList.add(RowFilter.regexFilter("Two|Commander|Free|Tiny|Momir", TableTableModel.COLUMN_GAME_TYPE));
- }
- if (btnTypeTourneyConstructed.isSelected()) {
- typeFilterList.add(RowFilter.regexFilter("Constructed", TableTableModel.COLUMN_GAME_TYPE));
- }
- if (btnTypeTourneyLimited.isSelected()) {
- typeFilterList.add(RowFilter.regexFilter("Booster|Sealed", TableTableModel.COLUMN_GAME_TYPE));
- }
+ // type
+ java.util.List> typeFilterList = new ArrayList<>();
+ if (btnTypeMatch.isSelected()) {
+ typeFilterList.add(RowFilter.regexFilter("Two|Commander|Free|Tiny|Momir", TableTableModel.COLUMN_GAME_TYPE));
+ }
+ if (btnTypeTourneyConstructed.isSelected()) {
+ typeFilterList.add(RowFilter.regexFilter("Constructed", TableTableModel.COLUMN_GAME_TYPE));
+ }
+ if (btnTypeTourneyLimited.isSelected()) {
+ typeFilterList.add(RowFilter.regexFilter("Booster|Sealed", TableTableModel.COLUMN_GAME_TYPE));
+ }
- // format
- java.util.List> formatFilterList = new ArrayList<>();
- if (btnFormatBlock.isSelected()) {
- formatFilterList.add(RowFilter.regexFilter("^Constructed.*Block", TableTableModel.COLUMN_DECK_TYPE));
- }
- if (btnFormatStandard.isSelected()) {
- formatFilterList.add(RowFilter.regexFilter("^Constructed - Standard", TableTableModel.COLUMN_DECK_TYPE));
- }
- if (btnFormatModern.isSelected()) {
- formatFilterList.add(RowFilter.regexFilter("^Constructed - Modern", TableTableModel.COLUMN_DECK_TYPE));
- }
- if (btnFormatLegacy.isSelected()) {
- formatFilterList.add(RowFilter.regexFilter("^Constructed - Legacy", TableTableModel.COLUMN_DECK_TYPE));
- }
- if (btnFormatVintage.isSelected()) {
- formatFilterList.add(RowFilter.regexFilter("^Constructed - Vintage", TableTableModel.COLUMN_DECK_TYPE));
- }
- if (btnFormatCommander.isSelected()) {
- formatFilterList.add(RowFilter.regexFilter("^Commander|^Duel Commander|^Penny Dreadful Commander|^Freeform Commander|^MTGO 1v1 Commander|^Duel Brawl|^Brawl", TableTableModel.COLUMN_DECK_TYPE));
- }
- if (btnFormatTinyLeader.isSelected()) {
- formatFilterList.add(RowFilter.regexFilter("^Tiny", TableTableModel.COLUMN_DECK_TYPE));
- }
- if (btnFormatLimited.isSelected()) {
- formatFilterList.add(RowFilter.regexFilter("^Limited", TableTableModel.COLUMN_DECK_TYPE));
- }
- if (btnFormatOther.isSelected()) {
- formatFilterList.add(RowFilter.regexFilter("^Momir Basic|^Constructed - Pauper|^Constructed - Frontier|^Constructed - Extended|^Constructed - Eternal|^Constructed - Historical|^Constructed - Super|^Constructed - Freeform|^Australian Highlander|^Canadian Highlander|^Constructed - Old", TableTableModel.COLUMN_DECK_TYPE));
- }
+ // format
+ java.util.List> formatFilterList = new ArrayList<>();
+ if (btnFormatBlock.isSelected()) {
+ formatFilterList.add(RowFilter.regexFilter("^Constructed.*Block", TableTableModel.COLUMN_DECK_TYPE));
+ }
+ if (btnFormatStandard.isSelected()) {
+ formatFilterList.add(RowFilter.regexFilter("^Constructed - Standard", TableTableModel.COLUMN_DECK_TYPE));
+ }
+ if (btnFormatModern.isSelected()) {
+ formatFilterList.add(RowFilter.regexFilter("^Constructed - Modern", TableTableModel.COLUMN_DECK_TYPE));
+ }
+ if (btnFormatLegacy.isSelected()) {
+ formatFilterList.add(RowFilter.regexFilter("^Constructed - Legacy", TableTableModel.COLUMN_DECK_TYPE));
+ }
+ if (btnFormatVintage.isSelected()) {
+ formatFilterList.add(RowFilter.regexFilter("^Constructed - Vintage", TableTableModel.COLUMN_DECK_TYPE));
+ }
+ if (btnFormatCommander.isSelected()) {
+ formatFilterList.add(RowFilter.regexFilter("^Commander|^Duel Commander|^Penny Dreadful Commander|^Freeform Commander|^MTGO 1v1 Commander|^Duel Brawl|^Brawl", TableTableModel.COLUMN_DECK_TYPE));
+ }
+ if (btnFormatTinyLeader.isSelected()) {
+ formatFilterList.add(RowFilter.regexFilter("^Tiny", TableTableModel.COLUMN_DECK_TYPE));
+ }
+ if (btnFormatLimited.isSelected()) {
+ formatFilterList.add(RowFilter.regexFilter("^Limited", TableTableModel.COLUMN_DECK_TYPE));
+ }
+ if (btnFormatOther.isSelected()) {
+ formatFilterList.add(RowFilter.regexFilter("^Momir Basic|^Constructed - Pauper|^Constructed - Frontier|^Constructed - Extended|^Constructed - Eternal|^Constructed - Historical|^Constructed - Super|^Constructed - Freeform|^Australian Highlander|^Canadian Highlander|^Constructed - Old", TableTableModel.COLUMN_DECK_TYPE));
+ }
- // skill
- java.util.List> skillFilterList = new ArrayList<>();
- if (btnSkillBeginner.isSelected()) {
- skillFilterList.add(RowFilter.regexFilter(this.tableModel.getSkillLevelAsCode(SkillLevel.BEGINNER, true), TableTableModel.COLUMN_SKILL));
- }
+ // skill
+ java.util.List> skillFilterList = new ArrayList<>();
+ if (btnSkillBeginner.isSelected()) {
+ skillFilterList.add(RowFilter.regexFilter(this.tableModel.getSkillLevelAsCode(SkillLevel.BEGINNER, true), TableTableModel.COLUMN_SKILL));
+ }
if (btnSkillCasual.isSelected()) {
- skillFilterList.add(RowFilter.regexFilter(this.tableModel.getSkillLevelAsCode(SkillLevel.CASUAL, true), TableTableModel.COLUMN_SKILL));
- }
- if (btnSkillSerious.isSelected()) {
- skillFilterList.add(RowFilter.regexFilter(this.tableModel.getSkillLevelAsCode(SkillLevel.SERIOUS, true), TableTableModel.COLUMN_SKILL));
- }
-
- String ratedMark = TableTableModel.RATED_VALUE_YES;
- java.util.List> ratingFilterList = new ArrayList<>();
- if (btnRated.isSelected()) {
- // yes word
- ratingFilterList.add(RowFilter.regexFilter("^" + ratedMark, TableTableModel.COLUMN_RATING));
- }
- if (btnUnrated.isSelected()) {
- // not yes word, see https://stackoverflow.com/a/406408/1276632
- ratingFilterList.add(RowFilter.regexFilter("^((?!" + ratedMark + ").)*$", TableTableModel.COLUMN_RATING));
- }
-
- // Password
- String passwordMark = TableTableModel.PASSWORD_VALUE_YES;
- java.util.List> passwordFilterList = new ArrayList<>();
- if (btnPassword.isSelected()) {
- // yes
- passwordFilterList.add(RowFilter.regexFilter("^" + passwordMark, TableTableModel.COLUMN_PASSWORD));
- }
- if (btnOpen.isSelected()) {
- // no
- passwordFilterList.add(RowFilter.regexFilter("^((?!" + passwordMark + ").)*$", TableTableModel.COLUMN_PASSWORD));
- }
-
- // Hide games of ignored players
- java.util.List> ignoreListFilterList = new ArrayList<>();
- String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> "");
- final Set ignoreListCopy = IgnoreList.ignoreList(serverAddress);
- if (!ignoreListCopy.isEmpty()) {
- ignoreListFilterList.add(new RowFilter