List of usage examples for javax.swing RowFilter andFilter
public static <M, I> RowFilter<M, I> andFilter(Iterable<? extends RowFilter<? super M, ? super I>> filters)
RowFilter
that includes entries if all of the supplied filters include the entry. From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.table.JTableInfoForCMFile.java
private RowFilter<MatchedInfoTableModel, Object> getRowFilterForStringSearchLicense(String stringSearchLicense, FileSummary fileSummary) {//from ww w. j a v a 2 s . c om RowFilter<MatchedInfoTableModel, Object> rowFilter = null; for (CodeMatchInfo codeMatchInfo : fileSummary.getCodeMatchInfoList()) { if (codeMatchInfo.getIdentifiedInfo() != null) return null; } if (stringSearchLicense == null || stringSearchLicense.length() == 0) return null; boolean isFilterNeeded = false; for (CodeMatchInfo tmpCodeMatchUnit : fileSummary.getCodeMatchInfoList()) { if (stringSearchLicense.equals(tmpCodeMatchUnit.getLicenseName()) && tmpCodeMatchUnit.getPercentage() == 100) { isFilterNeeded = true; break; } } if (isFilterNeeded == false) return null; try { List<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>(2); final String key = stringSearchLicense; RowFilter<Object, Object> containsKeywordFilter = new RowFilter<Object, Object>() { private String keyword = key.toLowerCase(); public boolean include(Entry<? extends Object, ? extends Object> entry) { String value = entry.getStringValue(TableModelForCMFile.COL_LICENSE_NAME); if (value == null) return false; value = value.toLowerCase(); if (value.contains(keyword)) return true; return false; } }; filters.add(containsKeywordFilter); rowFilter = RowFilter.andFilter(filters); } catch (java.util.regex.PatternSyntaxException e) { log.warn(e); return null; } return rowFilter; }
From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectAdd.java
private void newFilter() { RowFilter<AddProjectTableModel, Object> rf = null; try {//from w w w. j a v a 2 s.c om String[] texts = jTextFieldFilter.getText().split(" "); List<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>(2); for (String text : texts) { final String key = text; RowFilter<Object, Object> containsKeywordFilter = new RowFilter<Object, Object>() { private String keyword = key.toLowerCase(); public boolean include(Entry<? extends Object, ? extends Object> entry) { String value = entry.getStringValue(projectListTableModel.COL_PROJECT_NAME); if (value == null) return false; value = value.toLowerCase(); if (value.contains(keyword)) return true; return false; } }; filters.add(containsKeywordFilter); } rf = RowFilter.andFilter(filters); } catch (java.util.regex.PatternSyntaxException e) { log.warn(e); return; } sorter.setRowFilter(rf); }
From source file:edu.harvard.mcz.imagecapture.SpecimenBrowser.java
private void newFilter() { RowFilter<SpecimenListTableModel, Object> rf = null; //If current expression doesn't parse, don't update. try {/*from w ww. j a v a2 s .com*/ RowFilter<SpecimenListTableModel, Object> rf_family = null; RowFilter<SpecimenListTableModel, Object> rf_barcode = null; RowFilter<SpecimenListTableModel, Object> rf_drawer = null; RowFilter<SpecimenListTableModel, Object> rf_workflow = null; rf_family = RowFilter.regexFilter(jTextFieldFamily.getText(), SpecimenListTableModel.COL_FAMILY); rf_barcode = RowFilter.regexFilter(jTextField.getText(), SpecimenListTableModel.COL_BARCODE); rf_drawer = RowFilter.regexFilter(jTextFieldDrawerNumber.getText(), SpecimenListTableModel.COL_DRAWER); rf_workflow = RowFilter.regexFilter(jComboBox.getSelectedItem().toString(), SpecimenListTableModel.COL_WORKFLOW); ArrayList<RowFilter<SpecimenListTableModel, Object>> i = new ArrayList<RowFilter<SpecimenListTableModel, Object>>(); i.add(rf_family); i.add(rf_barcode); i.add(rf_drawer); i.add(rf_workflow); rf = RowFilter.andFilter((Iterable<RowFilter<SpecimenListTableModel, Object>>) i); } catch (java.util.regex.PatternSyntaxException e) { return; } sorter.setRowFilter(rf); }
From source file:net.sf.dvstar.transmission.TransmissionView.java
/** * Update the row filter regular expression from the expression in * the text box./* w w w . j av a 2s . c om*/ */ private void setTorrentListFilter() { RowFilter<TorrentsTableModel, Object> rowFilter = null; java.util.List<RowFilter<TorrentsTableModel, Object>> filters = new ArrayList<RowFilter<TorrentsTableModel, Object>>(); //If current expression doesn't parse, don't update. try { rowFilter = RowFilter.regexFilter(tfFindItem.getText(), 1); filters.add(rowFilter); } catch (java.util.regex.PatternSyntaxException ex) { return; } // use combo box filter by status if (cbFilterStatus.getSelectedIndex() > 0) { /* 0 All 1 Download TR_STATUS_DOWNLOAD 2 Stopped TR_STATUS_STOPPED 3 Seed TR_STATUS_SEED 4 Check TR_STATUS_CHECK || TR_STATUS_CHECK_WAIT 5 Error */ String filter = ""; switch (cbFilterStatus.getSelectedIndex()) { case 1: filter = "" + TRS_STATUS_DOWNLOAD; break; case 2: filter = "" + TRS_STATUS_PAUSED; break; case 3: filter = "" + TRS_STATUS_SEED; break; case 4: filter = "" + TRS_STATUS_CHECK; break; case 5: break; } rowFilter = RowFilter.regexFilter(filter, 4); filters.add(rowFilter); } TableRowSorter sorter = (TableRowSorter) tblTorrentList.getRowSorter(); RowFilter mrowFilter = RowFilter.andFilter(filters); if (sorter != null) { /** * @todo change is possible old selection to new */ //selectedTorrentRows = null; lockValueChanged = true; sorter.setRowFilter(mrowFilter); lockValueChanged = false; int rcs = tblTorrentList.getRowSorter().getViewRowCount(); int rca = tblTorrentList.getRowSorter().getModelRowCount(); lbFindInfo.setText(String.format("%d of %d", rcs, rca)); lbFindInfo.invalidate(); } }
From source file:md.mclama.com.ModManager.java
private void newFilter() { //Filter the mods in Download Mods based off mod tags and search filter String regex = ""; String comboText = ""; if (!txtFilterText.getText().equals("Filter Text")) { regex = "(?i)" + Pattern.quote(txtFilterText.getText().toLowerCase()); }//from w w w. j a va 2 s. c o m if (!comboBox.getSelectedItem().toString().equals("No tag filter")) { comboText = "(?i)" + Pattern.quote(comboBox.getSelectedItem().toString()); } List<RowFilter<Object, Object>> rfs = new ArrayList<RowFilter<Object, Object>>(2); rfs.add(RowFilter.regexFilter(regex, 0, 1, 2)); rfs.add(RowFilter.regexFilter(comboText, 3)); RowFilter<DefaultTableModel, Object> rf = null; //If current expression doesn't parse, don't update. try { //rf = RowFilter.regexFilter(regex,0,1,2,3); rf = RowFilter.andFilter(rfs); } catch (java.util.regex.PatternSyntaxException e) { return; } tSorter.setRowFilter(rf); }
From source file:org.nuclos.client.genericobject.logbook.LogbookController.java
private void cmdFilter() { final String sFilterCHANGEDAT = tfCOLUMN_CHANGEDAT.getText(); final String sFilterCHANGEDBY = tfCOLUMN_CHANGEDBY.getText(); final String sFilterLABEL = tfCOLUMN_LABEL.getText(); final String sFilterOLDVALUE = tfCOLUMN_OLDVALUE.getText(); final String sFilterNEWVALUE = tfCOLUMN_NEWVALUE.getText(); final String sFilterID = tfCOLUMN_ID.getText(); ArrayList<RowFilter<TableModel, Integer>> filters = new ArrayList<RowFilter<TableModel, Integer>>(); if (!sFilterCHANGEDAT.equals("")) { filters.add(newFilter(sFilterCHANGEDAT, 0)); }/* w w w . ja v a 2s . c o m*/ if (!sFilterCHANGEDBY.equals("")) { filters.add(newFilter(sFilterCHANGEDBY, 1)); } if (!sFilterLABEL.equals("")) { filters.add(newFilter(sFilterLABEL, 2)); } if (!sFilterOLDVALUE.equals("")) { filters.add(newFilter(sFilterOLDVALUE, 3)); } if (!sFilterNEWVALUE.equals("")) { filters.add(newFilter(sFilterNEWVALUE, 4)); } if (!sFilterID.equals("")) { filters.add(newFilter(sFilterID, 5)); } TableRowSorter<? extends TableModel> rowSorter = (TableRowSorter<? extends TableModel>) pnlLogbook .getTable().getRowSorter(); rowSorter.setRowFilter(!filters.isEmpty() ? RowFilter.andFilter(filters) : null); }
From source file:org.nuclos.client.genericobject.logbook.LogbookController.java
private RowFilter<TableModel, Integer> newFilter(String sFilterText, int iColumn) { String[] split = sFilterText.split(" "); ArrayList<RowFilter<TableModel, Integer>> filters = new ArrayList<RowFilter<TableModel, Integer>>( split.length);/*from w ww. j a v a 2s . c om*/ for (String filterStrg : split) { try { String regex = "^" + StringUtils.wildcardToRegex(filterStrg) + "$"; filters.add(RowFilter.<TableModel, Integer>regexFilter(regex, iColumn)); } catch (java.util.regex.PatternSyntaxException ex) { throw new NuclosFatalException(ex); } } return RowFilter.andFilter(filters); }
From source file:pl.otros.vfs.browser.VfsBrowser.java
License:asdf
private RowFilter<VfsTableModel, Integer> createFilter() { RowFilter<VfsTableModel, Integer> regexFilter = new VfsTableModelFileNameRowFilter(filterField); RowFilter<VfsTableModel, Integer> hiddenFilter = new VfsTableModelHiddenFileRowFilter(showHidden); RowFilter<VfsTableModel, Integer> alwaysShowParent = new VfsTableModelShowParentRowFilter(); @SuppressWarnings("unchecked") RowFilter<VfsTableModel, Integer> filters = RowFilter.andFilter(Arrays.asList(regexFilter, hiddenFilter)); filters = RowFilter.orFilter(Arrays.asList(filters, alwaysShowParent)); return filters; }
From source file:sk.stuba.fiit.kvasnicka.topologyvisual.gui.simulation.SimulationTopComponent.java
private void updateFilter() { filters.clear();//w w w . j a va 2 s.c o m if (!StringUtils.isEmpty(txtName.getText())) { try { nameFilter = RowFilter.regexFilter(txtName.getText(), 1); filters.add(nameFilter); } catch (java.util.regex.PatternSyntaxException e) { return; } } if (!StringUtils.isEmpty(txtSource.getText())) { try { sourceFilter = RowFilter.regexFilter(txtSource.getText(), 2); filters.add(sourceFilter); } catch (java.util.regex.PatternSyntaxException e) { return; } } if (!StringUtils.isEmpty(txtDest.getText())) { try { destinationFilter = RowFilter.regexFilter(txtDest.getText(), 3); filters.add(destinationFilter); } catch (java.util.regex.PatternSyntaxException e) { return; } } compoundRowFilter = RowFilter.andFilter(filters); //it is also possible to use OR filter: RowFilter.orFilter sorterSimRules.setRowFilter(compoundRowFilter); jXTable1.setRowSorter(sorterSimRules); }