Search in sources :

Example 11 with RowFilter

use of javax.swing.RowFilter in project omegat by omegat-org.

the class IssuesPanelController method updateFilter.

void updateFilter() {
    int[] selection = panel.typeList.getSelectedIndices();
    if (selection.length == 0) {
        return;
    }
    TypeListModel model = ((TypeListModel) panel.typeList.getModel());
    List<String> types = model.getTypesAt(selection);
    @SuppressWarnings("unchecked") TableRowSorter<IssuesTableModel> sorter = (TableRowSorter<IssuesTableModel>) panel.table.getRowSorter();
    sorter.setRowFilter(new RowFilter<IssuesTableModel, Integer>() {

        @Override
        public boolean include(RowFilter.Entry<? extends IssuesTableModel, ? extends Integer> entry) {
            return types.contains(ALL_TYPES) || types.contains(entry.getStringValue(IssueColumn.TYPE.index));
        }
    });
    int totalItems = panel.table.getModel().getRowCount();
    if (types.contains(ALL_TYPES)) {
        updateTitle(totalItems);
    } else {
        updateTitle((int) model.getCountAt(selection), totalItems);
    }
    panel.table.changeSelection(0, 0, false, false);
}
Also used : Point(java.awt.Point) RowFilter(javax.swing.RowFilter) TableRowSorter(javax.swing.table.TableRowSorter)

Aggregations

RowFilter (javax.swing.RowFilter)11 Point (java.awt.Point)4 TableRowSorter (javax.swing.table.TableRowSorter)4 TableModel (javax.swing.table.TableModel)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JButton (javax.swing.JButton)2 TechAdvancement (megamek.common.TechAdvancement)2 RulesTableColumnModel (wekapar.table.RulesTableColumnModel)2 BackgroundCommand (CCDD.CcddBackgroundCommand.BackgroundCommand)1 ValidateCellActionListener (CCDD.CcddClassesComponent.ValidateCellActionListener)1 FormBuilder (com.jgoodies.forms.builder.FormBuilder)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 AttributeVector (dna.dataStructures.AttributeVector)1 Document (dna.dataStructures.Document)1 AttributeTableModel (dna.renderer.AttributeTableModel)1 DocumentTableModel (dna.renderer.DocumentTableModel)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1