Search in sources :

Example 1 with RowFilter

use of javax.swing.RowFilter in project megameklab by MegaMek.

the class SpecializationView method filterSpecializations.

private void filterSpecializations() {
    RowFilter<SpecializationModel, Integer> filter = new RowFilter<SpecializationModel, Integer>() {

        @Override
        public boolean include(Entry<? extends SpecializationModel, ? extends Integer> entry) {
            SpecializationModel specModel = entry.getModel();
            TechAdvancement techAdvancement = specModel.getTechAdvancement(entry.getIdentifier());
            if ((1 << entry.getIdentifier() == Infantry.TAG_TROOPS) && TestInfantry.maxSecondaryWeapons(getInfantry()) < 2) {
                return false;
            }
            return (null != eSource.getTechManager()) && eSource.getTechManager().isLegal(techAdvancement);
        }
    };
    sorter.setRowFilter(filter);
}
Also used : RowFilter(javax.swing.RowFilter) TechAdvancement(megamek.common.TechAdvancement)

Example 2 with RowFilter

use of javax.swing.RowFilter in project wekapar by gems-uff.

the class PostprocessAssociationsPanel method buildMetricsFilter.

/**
 * Builds a {@link RowFilter} according to selected metrics minimum values.
 *
 * @return the row filter object
 */
private static RowFilter<? super TableModel, ? super Integer> buildMetricsFilter() {
    RowFilter<Object, Object> rowFilter = RowFilter.regexFilter(".*");
    List<RowFilter<Object, Object>> metricFilters = new ArrayList<RowFilter<Object, Object>>();
    List<RowFilter<Object, Object>> metricFilter;
    RowFilter<Object, Object> filterEqual;
    RowFilter<Object, Object> filterAfter;
    RulesTableColumnModel columnModel = (RulesTableColumnModel) table.getColumnModel();
    MetricSpinner spinner;
    String key;
    double value;
    int columnIndex;
    for (Map.Entry<String, JSpinner> entry : metricSpinnerMap.entrySet()) {
        metricFilter = new ArrayList<RowFilter<Object, Object>>();
        key = entry.getKey();
        spinner = (MetricSpinner) entry.getValue();
        value = (Double) spinner.getValue();
        if (columnModel.hasColumn(key)) {
            if (!spinner.isMinimumSelected()) {
                columnIndex = table.getColumnModel().getColumnIndex(key);
                filterEqual = RowFilter.numberFilter(ComparisonType.EQUAL, value, table.convertColumnIndexToModel(columnIndex));
                filterAfter = RowFilter.numberFilter(ComparisonType.AFTER, value, table.convertColumnIndexToModel(columnIndex));
                metricFilter.add(filterEqual);
                metricFilter.add(filterAfter);
                metricFilters.add(RowFilter.orFilter(metricFilter));
            }
        }
    }
    rowFilter = RowFilter.andFilter(metricFilters);
    return rowFilter;
}
Also used : ArrayList(java.util.ArrayList) Point(java.awt.Point) MetricSpinner(wekapar.MetricSpinner) RowFilter(javax.swing.RowFilter) JSpinner(javax.swing.JSpinner) RulesTableColumnModel(wekapar.table.RulesTableColumnModel) Map(java.util.Map) FilterMap(wekapar.FilterMap) HashMap(java.util.HashMap)

Example 3 with RowFilter

use of javax.swing.RowFilter in project dna by leifeld.

the class DocumentPanel method documentFilter.

public void documentFilter() {
    RowFilter<DocumentTableModel, Integer> documentFilter = new RowFilter<DocumentTableModel, Integer>() {

        public boolean include(Entry<? extends DocumentTableModel, ? extends Integer> entry) {
            DocumentTableModel dtm = entry.getModel();
            Document d = dtm.get(entry.getIdentifier());
            int documentId = d.getId();
            boolean[] b = Dna.data.getActiveDocumentPermissions(documentId);
            if (b[0] == true) {
                return true;
            }
            return false;
        }
    };
    sorter.setRowFilter(documentFilter);
}
Also used : DocumentTableModel(dna.renderer.DocumentTableModel) RowFilter(javax.swing.RowFilter) Document(dna.dataStructures.Document)

Example 4 with RowFilter

use of javax.swing.RowFilter in project gitblit by gitblit.

the class GitblitAuthority method filterUsers.

private void filterUsers(final String fragment) {
    table.clearSelection();
    userCertificatePanel.setUserCertificateModel(null);
    if (StringUtils.isEmpty(fragment)) {
        table.setRowSorter(defaultSorter);
        return;
    }
    RowFilter<UserCertificateTableModel, Object> containsFilter = new RowFilter<UserCertificateTableModel, Object>() {

        @Override
        public boolean include(Entry<? extends UserCertificateTableModel, ? extends Object> entry) {
            for (int i = entry.getValueCount() - 1; i >= 0; i--) {
                if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
                    return true;
                }
            }
            return false;
        }
    };
    TableRowSorter<UserCertificateTableModel> sorter = new TableRowSorter<UserCertificateTableModel>(tableModel);
    sorter.setRowFilter(containsFilter);
    table.setRowSorter(sorter);
}
Also used : RowFilter(javax.swing.RowFilter) Point(java.awt.Point) TableRowSorter(javax.swing.table.TableRowSorter)

Example 5 with RowFilter

use of javax.swing.RowFilter in project megameklab by MegaMek.

the class CISpecializationView method filterSpecializations.

private void filterSpecializations() {
    RowFilter<SpecializationModel, Integer> filter = new RowFilter<SpecializationModel, Integer>() {

        @Override
        public boolean include(Entry<? extends SpecializationModel, ? extends Integer> entry) {
            SpecializationModel specModel = entry.getModel();
            TechAdvancement techAdvancement = specModel.getTechAdvancement(entry.getIdentifier());
            if ((1 << entry.getIdentifier() == Infantry.TAG_TROOPS) && TestInfantry.maxSecondaryWeapons(getInfantry()) < 2) {
                return false;
            }
            return (null != eSource.getTechManager()) && eSource.getTechManager().isLegal(techAdvancement);
        }
    };
    sorter.setRowFilter(filter);
}
Also used : RowFilter(javax.swing.RowFilter) TechAdvancement(megamek.common.TechAdvancement)

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