* Fixed minor bug that the tables list was not cleared if no active table did exist.

This commit is contained in:
LevelX2 2017-07-29 20:22:07 +02:00
parent 6530b404c8
commit 7ba051871d
2 changed files with 34 additions and 37 deletions

View file

@ -39,7 +39,7 @@
<Component id="btnNewTournament" min="-2" max="-2" attributes="0"/> <Component id="btnNewTournament" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0"> <Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="filterBar1" pref="491" max="32767" attributes="0"/> <Component id="filterBar1" max="32767" attributes="0"/>
<Component id="filterBar2" max="32767" attributes="0"/> <Component id="filterBar2" max="32767" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>

View file

@ -33,12 +33,28 @@
*/ */
package mage.client.table; 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.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.SessionHandler; import mage.client.SessionHandler;
import mage.client.chat.ChatPanelBasic; import mage.client.chat.ChatPanelBasic;
import mage.client.components.MageComponents; import mage.client.components.MageComponents;
import mage.client.dialog.*; 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.ButtonColumn;
import mage.client.util.GUISizeHelper; import mage.client.util.GUISizeHelper;
import mage.client.util.IgnoreList; import mage.client.util.IgnoreList;
@ -55,25 +71,6 @@ import mage.view.TableView;
import mage.view.UserRequestMessage; import mage.view.UserRequestMessage;
import org.apache.log4j.Logger; 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 * @author BetaSteward_at_googlemail.com
@ -94,7 +91,7 @@ public class TablesPanel extends javax.swing.JPanel {
private NewTableDialog newTableDialog; private NewTableDialog newTableDialog;
private NewTournamentDialog newTournamentDialog; private NewTournamentDialog newTournamentDialog;
private final GameChooser gameChooser; private final GameChooser gameChooser;
private List<String> messages; private java.util.List<String> messages;
private int currentMessage; private int currentMessage;
private final MageTableRowSorter activeTablesSorter; private final MageTableRowSorter activeTablesSorter;
@ -231,7 +228,7 @@ public class TablesPanel extends javax.swing.JPanel {
String action = (String) matchesModel.getValueAt(modelRow, MatchesTableModel.ACTION_COLUMN); String action = (String) matchesModel.getValueAt(modelRow, MatchesTableModel.ACTION_COLUMN);
switch (action) { switch (action) {
case "Replay": case "Replay":
List<UUID> gameList = matchesModel.getListofGames(modelRow); java.util.List<UUID> gameList = matchesModel.getListofGames(modelRow);
if (gameList != null && !gameList.isEmpty()) { if (gameList != null && !gameList.isEmpty()) {
if (gameList.size() == 1) { if (gameList.size() == 1) {
SessionHandler.replayGame(gameList.get(0)); SessionHandler.replayGame(gameList.get(0));
@ -486,7 +483,7 @@ public class TablesPanel extends javax.swing.JPanel {
protected void reloadMessages() { protected void reloadMessages() {
// reload server messages // reload server messages
List<String> serverMessages = SessionHandler.getServerMessages(); java.util.List<String> serverMessages = SessionHandler.getServerMessages();
synchronized (this) { synchronized (this) {
this.messages = serverMessages; this.messages = serverMessages;
this.currentMessage = 0; this.currentMessage = 0;
@ -525,7 +522,7 @@ public class TablesPanel extends javax.swing.JPanel {
public void setTableFilter() { public void setTableFilter() {
// state // state
List<RowFilter<Object, Object>> stateFilterList = new ArrayList<>(); java.util.List<RowFilter<Object, Object>> stateFilterList = new ArrayList<>();
if (btnStateWaiting.isSelected()) { if (btnStateWaiting.isSelected()) {
stateFilterList.add(RowFilter.regexFilter("Waiting", TableTableModel.COLUMN_STATUS)); stateFilterList.add(RowFilter.regexFilter("Waiting", TableTableModel.COLUMN_STATUS));
} }
@ -534,7 +531,7 @@ public class TablesPanel extends javax.swing.JPanel {
} }
// type // type
List<RowFilter<Object, Object>> typeFilterList = new ArrayList<>(); java.util.List<RowFilter<Object, Object>> typeFilterList = new ArrayList<>();
if (btnTypeMatch.isSelected()) { if (btnTypeMatch.isSelected()) {
typeFilterList.add(RowFilter.regexFilter("Two|Commander|Free|Tiny|Momir", TableTableModel.COLUMN_GAME_TYPE)); 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 // format
List<RowFilter<Object, Object>> formatFilterList = new ArrayList<>(); java.util.List<RowFilter<Object, Object>> formatFilterList = new ArrayList<>();
if (btnFormatBlock.isSelected()) { if (btnFormatBlock.isSelected()) {
formatFilterList.add(RowFilter.regexFilter("^Constructed.*Block", TableTableModel.COLUMN_DECK_TYPE)); 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)); 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<RowFilter<Object, Object>> skillFilterList = new ArrayList<>(); java.util.List<RowFilter<Object, Object>> skillFilterList = new ArrayList<>();
if (btnSkillBeginner.isSelected()) { if (btnSkillBeginner.isSelected()) {
skillFilterList.add(RowFilter.regexFilter(SkillLevel.BEGINNER.toString(), TableTableModel.COLUMN_SKILL)); 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)); skillFilterList.add(RowFilter.regexFilter(SkillLevel.SERIOUS.toString(), TableTableModel.COLUMN_SKILL));
} }
List<RowFilter<Object, Object>> ratingFilterList = new ArrayList<>(); java.util.List<RowFilter<Object, Object>> ratingFilterList = new ArrayList<>();
if (btnRated.isSelected()) { if (btnRated.isSelected()) {
ratingFilterList.add(RowFilter.regexFilter("^Rated", TableTableModel.COLUMN_RATING)); ratingFilterList.add(RowFilter.regexFilter("^Rated", TableTableModel.COLUMN_RATING));
} }
@ -595,7 +592,7 @@ public class TablesPanel extends javax.swing.JPanel {
} }
// Password // Password
List<RowFilter<Object, Object>> passwordFilterList = new ArrayList<>(); java.util.List<RowFilter<Object, Object>> passwordFilterList = new ArrayList<>();
if (btnOpen.isSelected()) { if (btnOpen.isSelected()) {
passwordFilterList.add(RowFilter.regexFilter("^$", TableTableModel.COLUMN_PASSWORD)); passwordFilterList.add(RowFilter.regexFilter("^$", TableTableModel.COLUMN_PASSWORD));
} }
@ -604,7 +601,7 @@ public class TablesPanel extends javax.swing.JPanel {
} }
// Hide games of ignored players // Hide games of ignored players
List<RowFilter<Object, Object>> ignoreListFilterList = new ArrayList<>(); java.util.List<RowFilter<Object, Object>> ignoreListFilterList = new ArrayList<>();
String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> ""); String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> "");
final Set<String> ignoreListCopy = IgnoreList.ignoreList(serverAddress); final Set<String> ignoreListCopy = IgnoreList.ignoreList(serverAddress);
if (!ignoreListCopy.isEmpty()) { if (!ignoreListCopy.isEmpty()) {
@ -622,7 +619,7 @@ public class TablesPanel extends javax.swing.JPanel {
|| passwordFilterList.isEmpty()) { // no selection || passwordFilterList.isEmpty()) { // no selection
activeTablesSorter.setRowFilter(RowFilter.regexFilter("Nothing", TableTableModel.COLUMN_SKILL)); activeTablesSorter.setRowFilter(RowFilter.regexFilter("Nothing", TableTableModel.COLUMN_SKILL));
} else { } else {
List<RowFilter<Object, Object>> filterList = new ArrayList<>(); java.util.List<RowFilter<Object, Object>> filterList = new ArrayList<>();
if (stateFilterList.size() > 1) { if (stateFilterList.size() > 1) {
filterList.add(RowFilter.orFilter(stateFilterList)); filterList.add(RowFilter.orFilter(stateFilterList));
@ -1418,7 +1415,7 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
protected Void doInBackground() throws Exception { protected Void doInBackground() throws Exception {
while (!isCancelled()) { while (!isCancelled()) {
Collection<TableView> tables = SessionHandler.getTables(roomId); Collection<TableView> tables = SessionHandler.getTables(roomId);
if (!tables.isEmpty()) { if (tables != null) {
this.publish(tables); this.publish(tables);
} }
TimeUnit.SECONDS.sleep(3); TimeUnit.SECONDS.sleep(3);
@ -1427,7 +1424,7 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
} }
@Override @Override
protected void process(List<Collection<TableView>> view) { protected void process(java.util.List<Collection<TableView>> view) {
panel.updateTables(view.get(0)); panel.updateTables(view.get(0));
count++; count++;
if (count > 60) { if (count > 60) {
@ -1471,7 +1468,7 @@ class UpdatePlayersTask extends SwingWorker<Void, Collection<RoomUsersView>> {
} }
@Override @Override
protected void process(List<Collection<RoomUsersView>> roomUserInfo) { protected void process(java.util.List<Collection<RoomUsersView>> roomUserInfo) {
chat.setRoomUserInfo(roomUserInfo); chat.setRoomUserInfo(roomUserInfo);
} }
@ -1549,7 +1546,7 @@ class MatchesTableModel extends AbstractTableModel {
return ""; return "";
} }
public List<UUID> getListofGames(int row) { public java.util.List<UUID> getListofGames(int row) {
return matches[row].getGames(); return matches[row].getGames();
} }
@ -1613,7 +1610,7 @@ class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
} }
@Override @Override
protected void process(List<Collection<MatchView>> view) { protected void process(java.util.List<Collection<MatchView>> view) {
panel.updateMatches(view.get(0)); panel.updateMatches(view.get(0));
} }
@ -1635,7 +1632,7 @@ class GameChooser extends JPopupMenu {
} }
public void show(List<UUID> games, Point p) { public void show(java.util.List<UUID> games, Point p) {
if (p == null) { if (p == null) {
return; return;
} }