Started adding a simple filter to list of open tables.

This commit is contained in:
LevelX2 2015-04-23 17:51:05 +02:00
parent 2157c63160
commit c285fc6c4d
2 changed files with 56 additions and 9 deletions

View file

@ -53,7 +53,9 @@
<Component id="btnQuickStart" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkShowCompleted" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="434" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbStatusFilter" min="-2" pref="140" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -66,6 +68,7 @@
<Component id="btnQuickStart" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnNewTournament" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkShowCompleted" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbStatusFilter" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="16" max="32767" attributes="0"/>
</Group>
@ -107,6 +110,22 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkShowCompletedActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JComboBox" name="cbStatusFilter">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="2">
<StringItem index="0" value="All tables"/>
<StringItem index="1" value="Waiting for players"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbStatusFilterActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value=""/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel2">

View file

@ -61,12 +61,14 @@ import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.RowFilter;
import javax.swing.SwingWorker;
import javax.swing.table.AbstractTableModel;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.client.chat.ChatPanel;
import mage.client.components.MageComponents;
import mage.client.deckeditor.table.TableModel;
import mage.client.dialog.JoinTableDialog;
import mage.client.dialog.NewTableDialog;
import mage.client.dialog.NewTournamentDialog;
@ -107,7 +109,8 @@ public class TablesPanel extends javax.swing.JPanel {
private Session session;
private List<String> messages;
private int currentMessage;
private MageTableRowSorter activeTablesSorter;
/** Creates new form TablesPanel */
public TablesPanel() {
@ -119,10 +122,11 @@ public class TablesPanel extends javax.swing.JPanel {
tableModel.setSession(session);
chkShowCompleted.setVisible(true);
tableTables.createDefaultColumnsFromModel();
tableTables.setRowSorter(new MageTableRowSorter(tableModel));
activeTablesSorter = new MageTableRowSorter(tableModel);
tableTables.setRowSorter(activeTablesSorter);
tableCompleted.setRowSorter(new MageTableRowSorter(matchesModel));
chatPanel.useExtendedView(ChatPanel.VIEW_MODE.NONE);
@ -442,7 +446,15 @@ public class TablesPanel extends javax.swing.JPanel {
return this.chatPanel;
}
private void activeTablesFilter() {
if (cbStatusFilter.getSelectedItem().toString().equals("All tables")) {
activeTablesSorter.setRowFilter(null);
} else {
activeTablesSorter.setRowFilter(RowFilter.regexFilter("Waiting for players", 4));
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
@ -457,6 +469,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnQuickStart = new javax.swing.JButton();
btnNewTournament = new javax.swing.JButton();
chkShowCompleted = new javax.swing.JCheckBox();
cbStatusFilter = new javax.swing.JComboBox();
jPanel2 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
@ -500,6 +513,13 @@ public class TablesPanel extends javax.swing.JPanel {
}
});
cbStatusFilter.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All tables", "Waiting for players" }));
cbStatusFilter.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbStatusFilterActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
@ -513,7 +533,9 @@ public class TablesPanel extends javax.swing.JPanel {
.addComponent(btnQuickStart)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkShowCompleted)
.addContainerGap(434, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbStatusFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -523,7 +545,8 @@ public class TablesPanel extends javax.swing.JPanel {
.addComponent(btnNewTable)
.addComponent(btnQuickStart)
.addComponent(btnNewTournament)
.addComponent(chkShowCompleted))
.addComponent(chkShowCompleted)
.addComponent(cbStatusFilter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(16, Short.MAX_VALUE))
);
@ -689,16 +712,21 @@ private void chkShowCompletedActionPerformed(java.awt.event.ActionEvent evt) {//
this.startTasks();
}//GEN-LAST:event_chkShowCompletedActionPerformed
private void cbStatusFilterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbStatusFilterActionPerformed
activeTablesFilter();
}//GEN-LAST:event_cbStatusFilterActionPerformed
private void handleError(Exception ex) {
logger.fatal("Error loading deck: ", ex);
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error loading deck.", "Error", JOptionPane.ERROR_MESSAGE);
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnNewTable;
private javax.swing.JButton btnNewTournament;
private javax.swing.JButton btnQuickStart;
private javax.swing.JComboBox cbStatusFilter;
private mage.client.chat.ChatPanel chatPanel;
private javax.swing.JCheckBox chkShowCompleted;
private javax.swing.JButton jButton1;