Java 类javax.swing.RowFilter.Entry 实例源码

项目:swingx    文件:ListSortUITest.java   
/**
 * Issue #1536-swingx: AIOOB on restoring selection with filter
 * Reopened: overfixed - the removeIndexInterval _does_ take 
 * the endIndex instead of length.
 * 
 */
@Test
public void testSelectionWithFilterXListRemove() {
    JXList table = new JXList(ascendingListModel, true);
    // set selection somewhere below the filtered (which is 0)
    int selected = 1;
    table.setSelectionInterval(selected, selected);
    // exclude rows based on identifier (here: first item
    final RowFilter filter = new RowFilters.GeneralFilter() {

        List excludes = Arrays.asList(0);
        @Override
        protected boolean include(
                Entry<? extends Object, ? extends Object> entry,
                int index) {
            return !excludes.contains(entry.getIdentifier());
        }

    };
    table.setRowFilter(filter);
    assertEquals("sanity: filtered selection", selected - 1, table.getSelectedIndex());
    // remove last row
    ascendingListModel.remove(ascendingListModel.getSize() - 1);
    assertEquals("filtered selection unchanged", selected - 1, table.getSelectedIndex());
    assertFalse(table.isSelectionEmpty());
}
项目:dwoss    文件:DossierTableView.java   
private RowFilter setDependantRowFilter(final FilterType type) {
    RowFilter<DossierTableModel, Integer> filter = new RowFilter<DossierTableModel, Integer>() {
        @Override
        public boolean include(Entry<? extends DossierTableModel, ? extends Integer> entry) {
            Dossier dos = entry.getModel().getDossier(entry.getIdentifier());
            switch (type) {
                case SALES_CLOSED:
                    return !dos.isLegacy() && dos.getCrucialDirective() == Document.Directive.NONE;
                case SALES_OPEN:
                    return !dos.isLegacy() && dos.getId() > 0 && dos.getCrucialDirective() != Document.Directive.NONE;
                case ACCOUNTANCY_CLOSED:
                    return !dos.isLegacy() && dos.getId() > 0 && dos.isClosed();
                case ACCOUNTANCY_OPEN:
                    return !dos.isLegacy() && dos.getId() > 0 && !dos.isClosed();
                case ALL:
                    return true;
                case LEGACY:
                    return dos.isLegacy();
                default:
                    return true;
            }
        }
    };
    return filter;
}
项目:edacc_gui    文件:EDACCFilter.java   
/**
 * Creates new form EDACCFilter. If the table has no instance of TableRowSorter a IllegalArgumentException is thrown.
 * @param parent The parent for this dialog
 * @param modal
 * @param table the table to be used for this filter
 * @param autoUpdateFilterTypes if this is set to true, the filter will updated the classes of the columns on each setVisible(true)
 */
public EDACCFilter(java.awt.Frame parent, boolean modal, JTable table, boolean autoUpdateFilterTypes) {
    this(parent, modal);
    if (!(table.getRowSorter() instanceof TableRowSorter)) {
        throw new IllegalArgumentException("Expected TableRowSorter.");
    }
    this.table = table;
    rowSorter = (TableRowSorter<? extends TableModel>) table.getRowSorter();
    final RowFilter oldRowFilter = rowSorter.getRowFilter();
    rowFilter = new RowFilter<Object, Object>() {

        @Override
        public boolean include(Entry<? extends Object, ? extends Object> entry) {
            return (oldRowFilter == null || oldRowFilter.include(entry)) && EDACCFilter.this.include(entry);
        }
    };
    rowSorter.setRowFilter(rowFilter);
    this.updateFilterTypes = autoUpdateFilterTypes;
}
项目:edacc_gui    文件:EDACCGenerateJobsFilter.java   
/** Creates new form EDACCGenerateJobsFilter */
public EDACCGenerateJobsFilter(java.awt.Frame parent, boolean modal, JTable table, GenerateJobsTableModel model) {
    super(parent, modal);
    initComponents();

    this.table = table;
    this.model = model;
    TableRowSorter<? extends TableModel> rowSorter = (TableRowSorter<? extends TableModel>) table.getRowSorter();
    final RowFilter oldRowFilter = rowSorter.getRowFilter();
    RowFilter rowFilter = new RowFilter<Object, Object>() {

        @Override
        public boolean include(Entry<? extends Object, ? extends Object> entry) {
            return (oldRowFilter == null || oldRowFilter.include(entry)) && EDACCGenerateJobsFilter.this.include(entry);
        }
    };
    rowSorter.setRowFilter(rowFilter);
    instanceRegex = ".*";
    solverConfigRegex = ".*";
}
项目:swingx    文件:ListSortUITest.java   
/**
 * Issue #1536-swingx: AIOOB on restoring selection with filter
 * This is a core issue, sneaked into ListSortUI by c&p
 * 
 */
@Test
public void testSelectionWithFilterXListInsert() {
    DefaultListModel model = new DefaultListModel();
    // a model with 3 elements is the minimum size to demonstrate
    // the bug
    int last = 2;
    for (int i = 0; i <= last; i++) {
        model.addElement(i);
    }
    JXList table = new JXList(model, true);
    // set selection to the end
    table.setSelectionInterval(last, last);
    // exclude rows based on identifier
    final RowFilter filter = new RowFilters.GeneralFilter() {

        List excludes = Arrays.asList(0);
        @Override
        protected boolean include(
                Entry<? extends Object, ? extends Object> entry,
                int index) {
            return !excludes.contains(entry.getIdentifier());
        }

    };
    table.setRowFilter(filter);
    // insertRow _before or at_ selected model index, such that
    // endIndex (in event) > 1
    model.add(2, "x");
}
项目:breakout    文件:RowAnnotator.java   
@Override
public RowFilter<M, I> annotate(Entry<? extends M, ? extends I> entry) {
    int resultCount = 0;

    for (RowFilter<M, I> filter : filters) {
        if (filter.include(entry)) {
            return filter;
        }
    }

    return null;
}
项目:edacc_gui    文件:EDACCInstanceFilter.java   
@Override
public boolean include(Entry<? extends Object, ? extends Object> entry) {
    LinkedList<Integer> classIds = model.getInstanceClassIdsForRow((Integer) entry.getIdentifier());
    if (filterInstanceClasses) {
        boolean res = false;
        for (Integer id : classIds) {
            if (instanceClassIds.contains(id)) {
                res = true;
            }
        }
        if (!res) return false;
    }
    return super.include(entry);
}
项目:edacc_gui    文件:EDACCFilter.java   
public EDACCFilter(java.awt.Frame parent, boolean modal, EDACCSolverConfigComponent component) {
    this(parent, modal);
    this.table = null;
    this.solverConfigComponent = component;
    component.setFilter(new RowFilter<SolverConfigurationEntryModel, Pair<Solver, Integer>>() {

        @Override
        public boolean include(Entry<? extends SolverConfigurationEntryModel, ? extends Pair<Solver, Integer>> entry) {
            return EDACCFilter.this.include(entry);
        }
    });
    updateFilterTypesForSolverConfigComponent();
}
项目:edacc_gui    文件:EDACCFilter.java   
/**
 * Returns true iff the given entry matches the filter parameters.
 * @param entry
 * @return boolean
 */
public synchronized boolean include(Entry<? extends Object, ? extends Object> entry) {
    HashMap<Integer, Boolean> arguments = new HashMap<Integer, Boolean>();
    for (ArgumentPanel panel : filterArguments) {
        arguments.put(panel.getArgNum(), panel.getFilterInterface().include(getValueAt(entry.getIdentifier(), panel.getColumn())));
    }
    try {
        return parser.eval(expression, arguments);
    } catch (Exception ex) {
        return false;
    }
}
项目:edacc_gui    文件:EDACCGenerateJobsFilter.java   
public boolean include(Entry<? extends Object, ? extends Object> entry) {
    Object value = entry.getValue(0);
    String val;
    if (value instanceof String) {
        val = (String) value;
    } else {
        val = value.toString();
    }
    try {
        return val.matches(instanceRegex);
    } catch (Exception e) {
        return false;
    }
}
项目:edacc_gui    文件:InstanceDupErrorFilter.java   
@Override
public boolean include(Entry<? extends InstanceDupErrorTableModel, ? extends Integer> entry) {
    ArrayList<Instance> instances = model.getRelatedErrorInstance((Integer) entry.getIdentifier());
    if (instances == null) {
        return false;
    }

    if (instances.contains(selectedInstance)) {
        return true;
    }
    return false;
}
项目:incubator-netbeans    文件:SQLHistoryPanel.java   
@Override
public boolean include(Entry<? extends HistoryTableModel, ? extends Integer> entry) {
    return ((String) entry.getModel().getValueAt(entry.getIdentifier(), referenzColumn)).equals(referenz);
    }
项目:incubator-netbeans    文件:SQLHistoryPanel.java   
@Override
public boolean include(Entry<? extends HistoryTableModel, ? extends Integer> entry) {
    return ((String) entry.getModel().getValueAt(entry.getIdentifier(), referenzColumn)).toLowerCase().contains(referenz);
}
项目:edacc_gui    文件:SolverConfigurationTableRowFilter.java   
@Override
public boolean include(Entry<? extends SolverConfigurationTableModel, ? extends Integer> entry) {
    SolverConfiguration sc = entry.getModel().getSolverConfigurationAt(entry.getIdentifier());
    return includeExperiments.contains(sc.getExperiment_id()) || (!excludeExperiments.contains(sc.getExperiment_id()) && solverBinaryIds.contains(sc.getSolverBinary().getId()));
}
项目:breakout    文件:RowAnnotator.java   
/**
 * Returns a non-null {@code A} if the specified entry should be annotated;
 * returns {@code null} if the entry should not be annotated.
 * <p>
 * The <code>entry</code> argument is valid only for the duration of the
 * invocation. Using <code>entry</code> after the call returns results in
 * undefined behavior.
 *
 * @param entry
 *            a non-<code>null</code> object that wraps the underlying
 *            object from the model
 * @return a non-null {@code A} if the entry should be annotated
 */
public abstract Object annotate(Entry<? extends M, ? extends I> entry);