From 7ba051871d631531c9545cd3aabbb1908d04fdc4 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 29 Jul 2017 20:22:07 +0200 Subject: [PATCH] * Fixed minor bug that the tables list was not cleared if no active table did exist. --- .../java/mage/client/table/TablesPanel.form | 2 +- .../java/mage/client/table/TablesPanel.java | 69 +++++++++---------- 2 files changed, 34 insertions(+), 37 deletions(-) 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 30e1a8e228..b764e01770 100644 --- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.form +++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.form @@ -39,7 +39,7 @@ - + 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 d9aad35135..4e14af9262 100644 --- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java +++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java @@ -33,12 +33,28 @@ */ package mage.client.table; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.beans.PropertyVetoException; +import java.io.File; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.concurrent.CancellationException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import javax.swing.*; +import javax.swing.table.AbstractTableModel; import mage.cards.decks.importer.DeckImporterUtil; import mage.client.MageFrame; import mage.client.SessionHandler; import mage.client.chat.ChatPanelBasic; import mage.client.components.MageComponents; import mage.client.dialog.*; +import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_ORDER; +import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH; +import static mage.client.table.TablesPanel.PASSWORDED; import mage.client.util.ButtonColumn; import mage.client.util.GUISizeHelper; import mage.client.util.IgnoreList; @@ -55,25 +71,6 @@ import mage.view.TableView; import mage.view.UserRequestMessage; import org.apache.log4j.Logger; -import javax.swing.*; -import javax.swing.table.AbstractTableModel; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.beans.PropertyVetoException; -import java.io.File; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.List; -import java.util.concurrent.CancellationException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_ORDER; -import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH; -import static mage.client.table.TablesPanel.PASSWORDED; - /** * * @author BetaSteward_at_googlemail.com @@ -94,7 +91,7 @@ public class TablesPanel extends javax.swing.JPanel { private NewTableDialog newTableDialog; private NewTournamentDialog newTournamentDialog; private final GameChooser gameChooser; - private List messages; + private java.util.List messages; private int currentMessage; private final MageTableRowSorter activeTablesSorter; @@ -231,7 +228,7 @@ public class TablesPanel extends javax.swing.JPanel { String action = (String) matchesModel.getValueAt(modelRow, MatchesTableModel.ACTION_COLUMN); switch (action) { case "Replay": - List gameList = matchesModel.getListofGames(modelRow); + java.util.List gameList = matchesModel.getListofGames(modelRow); if (gameList != null && !gameList.isEmpty()) { if (gameList.size() == 1) { SessionHandler.replayGame(gameList.get(0)); @@ -486,7 +483,7 @@ public class TablesPanel extends javax.swing.JPanel { protected void reloadMessages() { // reload server messages - List serverMessages = SessionHandler.getServerMessages(); + java.util.List serverMessages = SessionHandler.getServerMessages(); synchronized (this) { this.messages = serverMessages; this.currentMessage = 0; @@ -525,7 +522,7 @@ public class TablesPanel extends javax.swing.JPanel { public void setTableFilter() { // state - List> stateFilterList = new ArrayList<>(); + java.util.List> stateFilterList = new ArrayList<>(); if (btnStateWaiting.isSelected()) { stateFilterList.add(RowFilter.regexFilter("Waiting", TableTableModel.COLUMN_STATUS)); } @@ -534,7 +531,7 @@ public class TablesPanel extends javax.swing.JPanel { } // type - List> typeFilterList = new ArrayList<>(); + java.util.List> typeFilterList = new ArrayList<>(); if (btnTypeMatch.isSelected()) { typeFilterList.add(RowFilter.regexFilter("Two|Commander|Free|Tiny|Momir", TableTableModel.COLUMN_GAME_TYPE)); } @@ -546,7 +543,7 @@ public class TablesPanel extends javax.swing.JPanel { } // format - List> formatFilterList = new ArrayList<>(); + java.util.List> formatFilterList = new ArrayList<>(); if (btnFormatBlock.isSelected()) { formatFilterList.add(RowFilter.regexFilter("^Constructed.*Block", TableTableModel.COLUMN_DECK_TYPE)); } @@ -575,7 +572,7 @@ public class TablesPanel extends javax.swing.JPanel { 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)); } - List> skillFilterList = new ArrayList<>(); + java.util.List> skillFilterList = new ArrayList<>(); if (btnSkillBeginner.isSelected()) { skillFilterList.add(RowFilter.regexFilter(SkillLevel.BEGINNER.toString(), TableTableModel.COLUMN_SKILL)); } @@ -586,7 +583,7 @@ public class TablesPanel extends javax.swing.JPanel { skillFilterList.add(RowFilter.regexFilter(SkillLevel.SERIOUS.toString(), TableTableModel.COLUMN_SKILL)); } - List> ratingFilterList = new ArrayList<>(); + java.util.List> ratingFilterList = new ArrayList<>(); if (btnRated.isSelected()) { ratingFilterList.add(RowFilter.regexFilter("^Rated", TableTableModel.COLUMN_RATING)); } @@ -595,7 +592,7 @@ public class TablesPanel extends javax.swing.JPanel { } // Password - List> passwordFilterList = new ArrayList<>(); + java.util.List> passwordFilterList = new ArrayList<>(); if (btnOpen.isSelected()) { passwordFilterList.add(RowFilter.regexFilter("^$", TableTableModel.COLUMN_PASSWORD)); } @@ -604,7 +601,7 @@ public class TablesPanel extends javax.swing.JPanel { } // Hide games of ignored players - List> ignoreListFilterList = new ArrayList<>(); + java.util.List> ignoreListFilterList = new ArrayList<>(); String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> ""); final Set ignoreListCopy = IgnoreList.ignoreList(serverAddress); if (!ignoreListCopy.isEmpty()) { @@ -622,7 +619,7 @@ public class TablesPanel extends javax.swing.JPanel { || passwordFilterList.isEmpty()) { // no selection activeTablesSorter.setRowFilter(RowFilter.regexFilter("Nothing", TableTableModel.COLUMN_SKILL)); } else { - List> filterList = new ArrayList<>(); + java.util.List> filterList = new ArrayList<>(); if (stateFilterList.size() > 1) { filterList.add(RowFilter.orFilter(stateFilterList)); @@ -1418,7 +1415,7 @@ class UpdateTablesTask extends SwingWorker> { protected Void doInBackground() throws Exception { while (!isCancelled()) { Collection tables = SessionHandler.getTables(roomId); - if (!tables.isEmpty()) { + if (tables != null) { this.publish(tables); } TimeUnit.SECONDS.sleep(3); @@ -1427,7 +1424,7 @@ class UpdateTablesTask extends SwingWorker> { } @Override - protected void process(List> view) { + protected void process(java.util.List> view) { panel.updateTables(view.get(0)); count++; if (count > 60) { @@ -1471,7 +1468,7 @@ class UpdatePlayersTask extends SwingWorker> { } @Override - protected void process(List> roomUserInfo) { + protected void process(java.util.List> roomUserInfo) { chat.setRoomUserInfo(roomUserInfo); } @@ -1549,7 +1546,7 @@ class MatchesTableModel extends AbstractTableModel { return ""; } - public List getListofGames(int row) { + public java.util.List getListofGames(int row) { return matches[row].getGames(); } @@ -1613,7 +1610,7 @@ class UpdateMatchesTask extends SwingWorker> { } @Override - protected void process(List> view) { + protected void process(java.util.List> view) { panel.updateMatches(view.get(0)); } @@ -1635,7 +1632,7 @@ class GameChooser extends JPopupMenu { } - public void show(List games, Point p) { + public void show(java.util.List games, Point p) { if (p == null) { return; }