javax.swing.RowFilter Java Examples
The following examples show how to use
javax.swing.RowFilter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PeakListTableWindow.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") public void updateFilter() { List<RowFilter<Object, Object>> rowSorters = new ArrayList<RowFilter<Object, Object>>(); TableRowSorter<PeakListTableModel> sorter = (TableRowSorter<PeakListTableModel>) table.getRowSorter(); String textId = "(?i)" + filterTextId.getText(); String textIdentity = "(?i)" + filterTextIdentity.getText(); String textComment = "(?i)" + filterTextComment.getText(); rowSorters.add(RowFilter.regexFilter(textId, 0)); rowSorters.add(mzFilter); rowSorters.add(rtFilter); rowSorters.add(RowFilter.regexFilter(textIdentity, 3)); rowSorters.add(RowFilter.regexFilter(textComment, 4)); sorter.setRowFilter(RowFilter.andFilter(rowSorters)); table.setRowSorter(sorter); }
Example #2
Source File: Gui.java From Qora with MIT License | 6 votes |
public static <T extends TableModel> JTable createSortableTable(T tableModel, int defaultSort, RowFilter<T, Object> rowFilter) { //CREATE TABLE JTable table = new JTable(tableModel); //CREATE SORTER TableRowSorter<T> rowSorter = new TableRowSorter<T>(tableModel); //rowSorter.setSortsOnUpdates(true); rowSorter.setRowFilter(rowFilter); //DEFAULT SORT DESCENDING rowSorter.toggleSortOrder(defaultSort); rowSorter.toggleSortOrder(defaultSort); //ADD TO TABLE table.setRowSorter(rowSorter); //RETURN return table; }
Example #3
Source File: MongoRowFilterAction.java From gameserver with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable(){ public void run() { DefaultRowSorter rowSorter = (DefaultRowSorter)parent.getTable().getRowSorter(); String regex = parent.getFilterText(); if ( regex == null || regex.length() == 0 ) { // JOptionPane.showMessageDialog(parent, "请输入需要过滤的正则表达式", // "数据过滤", JOptionPane.INFORMATION_MESSAGE); rowSorter.setRowFilter(null); } else { rowSorter.setRowFilter(RowFilter.regexFilter(regex)); // parent.getTable().setRowFilter(RowFilter.regexFilter(regex)); } } }); }
Example #4
Source File: PeakListTableWindow.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") public void updateFilter() { List<RowFilter<Object, Object>> rowSorters = new ArrayList<RowFilter<Object, Object>>(); TableRowSorter<PeakListTableModel> sorter = (TableRowSorter<PeakListTableModel>) table.getRowSorter(); String textId = "(?i)" + filterTextId.getText(); String textIdentity = "(?i)" + filterTextIdentity.getText(); String textComment = "(?i)" + filterTextComment.getText(); rowSorters.add(RowFilter.regexFilter(textId, 0)); rowSorters.add(mzFilter); rowSorters.add(rtFilter); rowSorters.add(RowFilter.regexFilter(textIdentity, 3)); rowSorters.add(RowFilter.regexFilter(textComment, 4)); sorter.setRowFilter(RowFilter.andFilter(rowSorters)); table.setRowSorter(sorter); }
Example #5
Source File: SBOLInputDialog.java From iBioSim with Apache License 2.0 | 6 votes |
private void updateFilter(String filterText) { filterText = "(?i)" + filterText; @SuppressWarnings({ "rawtypes", "unchecked" }) TableRowSorter<TopLevelTableModel> sorter = (TableRowSorter) table.getRowSorter(); if (filterText.length() == 0) { sorter.setRowFilter(null); } else { try { RowFilter<TopLevelTableModel, Object> rf = RowFilter.regexFilter(filterText, 0, 1); sorter.setRowFilter(rf); } catch (java.util.regex.PatternSyntaxException e) { sorter.setRowFilter(null); } } tableLabel.setText("Matching parts (" + sorter.getViewRowCount() + ")"); }
Example #6
Source File: DefaultsDisplay.java From beautyeye with Apache License 2.0 | 6 votes |
protected void initFilters(JTable table) { TableRowSorter sorter = new TableRowSorter(table.getModel()); table.setRowSorter(sorter); if (visualsFilter == null) { visualsFilter = new RowFilter<UIDefaultsTableModel,Integer>() { public boolean include(Entry<? extends UIDefaultsTableModel, ? extends Integer> entry) { UIDefaultsTableModel model = entry.getModel(); Object defaultsValue = model.getValueAt(entry.getIdentifier().intValue(), UIDefaultsTableModel.VALUE_COLUMN); return defaultsValue instanceof Color || defaultsValue instanceof Font || defaultsValue instanceof Icon; } }; } if (onlyVisualsCheckBox.isSelected()) { sorter.setRowFilter(visualsFilter); } }
Example #7
Source File: RATGeneratorEditor.java From megamek with GNU General Public License v2.0 | 6 votes |
private void filterFactionList() { RowFilter<FactionListTableModel, Integer> rf; rf = new RowFilter<FactionListTableModel, Integer>() { @Override public boolean include(Entry<? extends FactionListTableModel, ? extends Integer> entry) { FactionListTableModel model = entry.getModel(); FactionRecord rec = model.getFactionRecord(entry.getIdentifier()); if (!chkShowSubfactions.isSelected() && rec.getKey().contains(".")) { return false; } return chkShowMinorFactions.isSelected() || rec.getParentFactions() == null; } }; masterFactionListSorter.setRowFilter(rf); }
Example #8
Source File: RATGeneratorEditor.java From megamek with GNU General Public License v2.0 | 6 votes |
private void filterMasterUnitList() { RowFilter<MasterUnitListTableModel, Integer> rf; rf = new RowFilter<MasterUnitListTableModel, Integer>() { @Override public boolean include(Entry<? extends MasterUnitListTableModel, ? extends Integer> entry) { MasterUnitListTableModel model = entry.getModel(); ModelRecord rec = model.getUnitRecord(entry.getIdentifier()); if (cbUnitType.getSelectedIndex() > 0 && !UnitType.getTypeName(rec.getUnitType()).equals(cbUnitType.getSelectedItem())) { return false; } if (cbMovementType.getSelectedIndex() > 0 && (rec.getMovementMode() != EntityMovementMode.getMode((String) cbMovementType.getSelectedItem()))) { return false; } if (txtSearch.getText().length() > 0) { return rec.getKey().toLowerCase().contains(txtSearch.getText().toLowerCase()); } return true; } }; masterUnitListSorter.setRowFilter(rf); }
Example #9
Source File: ProfilerRowSorter.java From visualvm with GNU General Public License v2.0 | 5 votes |
private void refreshRowFilter() { if (filters == null || filters.isEmpty()) { setRowFilter(null); } else if (filters.size() == 1) { setRowFilter(filters.iterator().next()); } else { setRowFilter(filterMode ? RowFilter.andFilter(filters) : RowFilter.orFilter(filters)); } }
Example #10
Source File: JDBCTreeTableView.java From visualvm with GNU General Public License v2.0 | 5 votes |
protected RowFilter getExcludesFilter() { return new RowFilter() { // Do not filter SQL commands public boolean include(RowFilter.Entry entry) { PresoObjAllocCCTNode node = (PresoObjAllocCCTNode)entry.getIdentifier(); return isSQL(node); } }; }
Example #11
Source File: FilterUtils.java From visualvm with GNU General Public License v2.0 | 5 votes |
public static boolean filter(TreeTableView view, final GenericFilter textFilter, final RowFilter excludesFilter) { if (textFilter.isAll()) { view.setViewFilter(null); return false; } view.setViewFilter(new HeapViewerNodeFilter() { public boolean passes(HeapViewerNode node, Heap heap) { String typeName = HeapViewerNode.getValue(node, TruffleType.TYPE_NAME, heap); return typeName == null ? true : textFilter.passes(typeName); } }); return true; }
Example #12
Source File: MultiColPatternFilter.java From netbeans with Apache License 2.0 | 5 votes |
@Override public boolean include(RowFilter.Entry<? extends TableModel,? extends Integer> entry) { for (int colIdx : cols) { Object val = entry.getValue(colIdx); if (testValue(val)) { return true; } } return false; }
Example #13
Source File: ThreadsPanel.java From netbeans with Apache License 2.0 | 5 votes |
public boolean include(RowFilter.Entry entry) { ThreadData data = (ThreadData)entry.getValue(1); switch (filter) { case LIVE: return ThreadData.isAliveState(data.getLastState()); case FINISHED: return !ThreadData.isAliveState(data.getLastState()); case SELECTED: return selectedApplied.contains(entry.getIdentifier()); default: return true; } }
Example #14
Source File: TablePanel.java From programming with GNU General Public License v3.0 | 5 votes |
public TablePanel(JTable table,String format){ formatIfDate = format; this.table = table; table.getTableHeader().setReorderingAllowed(false); sortList = new ArrayList<RowFilter<Object,Object>>(); sortDate = new ArrayList<RowFilter<Object,Object>>(); initUI(); }
Example #15
Source File: ProfilerTreeTable.java From netbeans with Apache License 2.0 | 5 votes |
private SortedFilteredTreeModel treeModelImpl(TreeNode root, Comparator comparator, RowFilter filter) { return new SortedFilteredTreeModel(root, tree == null ? null : tree.getCellRenderer(), comparator, filter) { protected void fireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object[] children) { UIState uiState = tree == null ? null : getUIState(tree); super.fireTreeStructureChanged(source, path, childIndices, children); if (uiState != null) restoreExpandedNodes(tree, uiState); fireTableDataChanged(); // Clears selection if (uiState != null) restoreSelectedNodes(tree, uiState); } }; }
Example #16
Source File: Main_Blockade.java From Hotel-Properties-Management-System with GNU General Public License v2.0 | 5 votes |
private KeyListener customKeyListener() { final KeyAdapter adapter = new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { String modifiedQuery = "(?i)" + searchField.getText(); tableRowShorter.setRowFilter(RowFilter.regexFilter(modifiedQuery)); super.keyTyped(e); } }; return adapter; }
Example #17
Source File: AnalyzeFormationDialog.java From megamek with GNU General Public License v2.0 | 5 votes |
private void filter() { List<RowFilter<UnitTableModel,Integer>> filters = new ArrayList<>(); for (int i = 0; i < allConstraints.size(); i++) { if (otherCriteriaChecks.get(i).isSelected()) { filters.add(new UnitTableRowFilter(allConstraints.get(i))); } } if (otherCriteriaChecks.size() > allConstraints.size() && otherCriteriaChecks.get(otherCriteriaChecks.size() - 1).isSelected()) { filters.add(new UnitTableRowFilter(formationType.getGroupingCriteria())); } tableSorter.setRowFilter(RowFilter.andFilter(filters)); }
Example #18
Source File: ProfilerRowSorter.java From netbeans with Apache License 2.0 | 5 votes |
private void refreshRowFilter() { if (filters == null || filters.isEmpty()) { setRowFilter(null); } else if (filters.size() == 1) { setRowFilter(filters.iterator().next()); } else { setRowFilter(filterMode ? RowFilter.andFilter(filters) : RowFilter.orFilter(filters)); } }
Example #19
Source File: TablePanel.java From programming with GNU General Public License v3.0 | 5 votes |
public TablePanel(JTable table){ formatIfDate = "dd/MM/yyyy"; this.table = table; table.getTableHeader().setReorderingAllowed(false); sortList = new ArrayList<RowFilter<Object,Object>>(); sortDate = new ArrayList<RowFilter<Object,Object>>(); initUI(); }
Example #20
Source File: JDBCTreeTableView.java From netbeans with Apache License 2.0 | 5 votes |
protected RowFilter getExcludesFilter() { return new RowFilter() { // Do not filter SQL commands public boolean include(RowFilter.Entry entry) { PresoObjAllocCCTNode node = (PresoObjAllocCCTNode)entry.getIdentifier(); return isSQL(node); } }; }
Example #21
Source File: LivenessTreeTableView.java From netbeans with Apache License 2.0 | 5 votes |
protected RowFilter getExcludesFilter() { return new RowFilter() { // Do not filter first level nodes public boolean include(RowFilter.Entry entry) { PresoObjAllocCCTNode node = (PresoObjAllocCCTNode)entry.getIdentifier(); CCTNode parent = node.getParent(); if (parent == null) return true; if (parent.getParent() == null) return !filterObjects; return !filterAllocations; } }; }
Example #22
Source File: AllocTreeTableView.java From netbeans with Apache License 2.0 | 5 votes |
protected RowFilter getExcludesFilter() { return new RowFilter() { // Do not filter first level nodes public boolean include(RowFilter.Entry entry) { PresoObjAllocCCTNode node = (PresoObjAllocCCTNode)entry.getIdentifier(); CCTNode parent = node.getParent(); if (parent == null) return true; if (parent.getParent() == null) return !filterObjects; return !filterAllocations; } }; }
Example #23
Source File: TablePanel.java From programming with GNU General Public License v3.0 | 5 votes |
public TablePanel(Object[][] rows, String columns[]){ table = new FTable(rows,columns); table.getTableHeader().setReorderingAllowed(false); sortList = new ArrayList<RowFilter<Object,Object>>(); sortDate = new ArrayList<RowFilter<Object,Object>>(); formatIfDate = "dd/MM/yyyy"; }
Example #24
Source File: FilterTextParser.java From PacketProxy with Apache License 2.0 | 5 votes |
@Override protected boolean include(javax.swing.RowFilter.Entry<? extends Object, ? extends Object> value, int index) { if (!ValidPattern(this.searchWord)) { return false; } Object v = value.getValue(index); if (v instanceof Long) { return groupIds.contains(v); } return false; }
Example #25
Source File: JtableFilter.java From domain_hunter with MIT License | 5 votes |
public static void main(String[] args) { Object[][] data = { { "A", 5 }, { "B", 2 }, { "C", 4 }, { "D", 8 } }; String columnNames[] = { "Item", "Value" }; TableModel model = new DefaultTableModel(data, columnNames) { public Class<?> getColumnClass(int column) { return getValueAt(0, column).getClass(); } }; JTable table = new JTable(model); RowFilter<Object, Object> filter = new RowFilter<Object, Object>() { public boolean include(Entry entry) { Integer population = (Integer) entry.getValue(1); return population.intValue() > 3; } }; TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model); sorter.setRowFilter(filter); table.setRowSorter(sorter); JScrollPane scrollPane = new JScrollPane(table); JFrame frame = new JFrame("Filtering Table"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(scrollPane); frame.setSize(300, 200); frame.setVisible(true); }
Example #26
Source File: FTable.java From programming with GNU General Public License v3.0 | 5 votes |
public FTable(Object[][] rows, String columns[]){ setModel(new ModdedTable(rows,columns)); sorter = new TableRowSorter<>(getModel()); setRowSorter(sorter); setBorder(new EtchedBorder(EtchedBorder.RAISED)); setGridColor(Color.BLACK); setFillsViewportHeight(true); sortList = new ArrayList<RowFilter<Object,Object>>(); }
Example #27
Source File: AllocTreeTableView.java From visualvm with GNU General Public License v2.0 | 5 votes |
protected RowFilter getExcludesFilter() { return new RowFilter() { // Do not filter first level nodes public boolean include(RowFilter.Entry entry) { PresoObjAllocCCTNode node = (PresoObjAllocCCTNode)entry.getIdentifier(); CCTNode parent = node.getParent(); if (parent == null) return true; if (parent.getParent() == null) return !filterObjects; return !filterAllocations; } }; }
Example #28
Source File: FilterUtils.java From visualvm with GNU General Public License v2.0 | 4 votes |
public static JComponent createFilterPanel(final TreeTableView view, final RowFilter excludesFilter) { return createFilterPanel(view, excludesFilter, null); }
Example #29
Source File: FTable.java From programming with GNU General Public License v3.0 | 4 votes |
public void updateSortList(int column, String text){ sortList.set(column,RowFilter.regexFilter(text,column)); sorter.setRowFilter(RowFilter.andFilter(sortList)); }
Example #30
Source File: TableBox.java From sc2gears with Apache License 2.0 | 4 votes |
@Override public void setAdditionalRowFilter( final RowFilter< ? super TableModel, ? super Integer > rowFilter ) { additionalRowFilter = rowFilter; updateRowFilterTask.run(); }