项目:onagui
文件:MappingRowFilter.java
@Override
public boolean include(javax.swing.RowFilter.Entry<? extends MappingTableModel,? extends Integer> entry) {
// Test facile: si les deux parametre de classes sont "null",alors on affiche tout
if(concept1 == null && concept2 == null) return true;
// Maintenant,c'est plus subtil...
MappingTableModel model = entry.getModel();
// System.out.println("Identifier type: "+entry.getIdentifier().getClass().getCanonicalName());
// System.out.println("Identifier value: "+entry.getIdentifier());
Mapping map = model.getMappingAt(entry.getIdentifier());
Object conceptFromMap1 = map.getFirstConcept();
Object conceptFromMap2 = map.getSecondConcept();
// Macro qui aide!
boolean filter1 = concept1 != null && conceptFromMap1.equals(concept1);
boolean filter2 = concept2 != null && conceptFromMap2.equals(concept2);
if(filter1 && filter2) return true; // Double filtrage
else if(filter1 && concept2 == null) return true; // Filtrage ok sur 1,pas de filtrage sur 2
else if(concept1 == null && filter2) return true; // Filtrage ok sur 2,pas de filtrage sur 1
// Sinon,c'est pas bon...
return false;
}
项目:littleluck
文件:TableDemo.java
protected void configureFilters() {
if (showOnlyWinners && hasFilterString()) {
List<RowFilter<OscarTableModel,Integer>> filters =
new ArrayList<RowFilter<OscarTableModel,Integer>>(2);
filters.add(winnerFilter);
filters.add(searchFilter);
RowFilter<OscarTableModel,Integer> comboFilter = RowFilter.andFilter(filters);
sorter.setRowFilter(comboFilter);
} else if (showOnlyWinners) {
sorter.setRowFilter(winnerFilter);
} else if (hasFilterString()) {
sorter.setRowFilter(searchFilter);
} else {
sorter.setRowFilter(null);
}
tableStatus.setText((hasFilterString() ? searchLabelString : statusLabelString)
+ oscarTable.getRowCount());
}
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);
}
}
项目:iBioSim
文件:SBOLInputDialog.java
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,1);
sorter.setRowFilter(rf);
} catch (java.util.regex.PatternSyntaxException e) {
sorter.setRowFilter(null);
}
}
tableLabel.setText("Matching parts (" + sorter.getViewRowCount() + ")");
}
项目:ca-iris
文件:ControllerTableModel.java
/** Create a row filter */
private RowFilter<ProxyTableModel<Controller>,Integer> createFilter() {
return new RowFilter<ProxyTableModel<Controller>,Integer>() {
public boolean include(RowFilter.Entry<? extends
ProxyTableModel<Controller>,? extends Integer>
entry)
{
int i = entry.getIdentifier();
Controller c = getRowProxy(i);
return (c != null)
&& isMatchingLink(c)
&& isMatchingCondition(c)
&& isMatchingCommState(c);
}
};
}
项目:theSemProject
文件:FilesAndSegmentsUtils.java
/**
* filtra la tabella dei segmenti sui segmenti classificati sul primo
* livello
*
* @param semGui frame
* @param level livello
*/
public static void segmentsTableFilterOnFirstLevel(SemGui semGui,int level) {
tablerowsorter<TableModel> sorter = (tablerowsorter<TableModel>) semGui.getSegmentsTable().getRowSorter();
sorter.setRowFilter(new RowFilter() {
@Override
public boolean include(RowFilter.Entry entry) {
String idSeg = (String) entry.getValue(0);
Integer id = Integer.parseInt(idSeg.substring(0,idSeg.indexOf(".")));
SemDocument dto = semGui.getTableData().get(id);
if (dto != null) {
List<ClassificationPath> cpl = dto.getClasspath(idSeg);
if (cpl.size() > 0) {
if (cpl.get(0).getscore()[level] == 0) {
return true;
}
} else {
return true;
}
}
return false;
}
});
semGui.getSegmentsTable().setRowSorter(sorter);
semGui.getStatusSegments().setText("Totale filtrati elementi: " + semGui.getSegmentsTable().getRowCount());
}
项目:theSemProject
文件:GuiUtils.java
/**
* gestisce filtri multicampo sulla tabella
*
* @param table tabella
* @param text testo cercato
* @param idxs elenco degli id dei campi dove cercare
*/
public static void filterTable(JTable table,String text,int idxs[]) {
tablerowsorter<TableModel> sorter = (tablerowsorter<TableModel>) table.getRowSorter();
List<RowFilter<TableModel,Integer>> filters = new ArrayList<>(idxs.length);
if (text != null && text.length() > 0) {
for (int idx : idxs) {
table.getColumnModel().getColumn(idx).setCellRenderer(new JTableCellRender(text));
RowFilter<TableModel,Integer> filterC1 = RowFilter.regexFilter("(?i)" + text,idx);
filters.add(filterC1);
}
RowFilter<TableModel,Integer> filter = RowFilter.orFilter(filters);
sorter.setRowFilter(filter);
} else {
sorter.setRowFilter(null);
}
table.setRowSorter(sorter);
}
项目:theSemProject
文件:GuiUtils.java
/**
* gestisce filtri diversi su campi diversi sulla tabella
*
* @since 1.7
*
* @param table tabella
* @param text testi cercati
* @param idxs elenco degli id dei campi dove cercare
*/
public static void filterTable(JTable table,String text[],Integer>> filters = new ArrayList<>(idxs.length);
if (text != null && text.length > 0) {
for (int i = 0; i < idxs.length; i++) {
if (text[i] != null && text[i].length() > 0) {
LogGui.info("Aggiungo filtro " + text[i] + " su colonna "
+ idxs[i]);
table.getColumnModel().getColumn(idxs[i]).setCellRenderer(new JTableCellRender(text[i]));
RowFilter<TableModel,Integer> filterC1 = RowFilter.regexFilter("(?i)" + text[i],idxs[i]);
filters.add(filterC1);
}
}
RowFilter<TableModel,Integer> filter = RowFilter.andFilter(filters);
sorter.setRowFilter(filter);
} else {
sorter.setRowFilter(null);
}
table.setRowSorter(sorter);
}
项目:theSemProject
文件:GuiUtils.java
/**
* gestisce i filtri sullo stato
*
* @param filter1 primo filtro
* @param filter2 secondo filtro
* @param semGui frame
*/
public static void filterOnStatus(String filter1,String filter2,SemGui semGui) {
if (semGui.isIsClassify()) {
return;
}
tablerowsorter<TableModel> sorter = (tablerowsorter<TableModel>) semGui.getSegmentsTable().getRowSorter();
sorter.setRowFilter(new RowFilter() {
@Override
public boolean include(RowFilter.Entry entry) {
String val = (String) entry.getValue(6);
if (filter2 == null) {
return filter1.equals(val);
} else {
return filter1.equals(val) || filter2.equals(val);
}
}
});
semGui.getSegmentsTable().setRowSorter(sorter);
semGui.getStatusSegments().setText("Totale filtrati elementi: " + semGui.getSegmentsTable().getRowCount());
}
项目:SBOLDesigner
文件:PartInputDialog.java
private void updatefilter(String filterText) {
filterText = "(?i)" + filterText;
@SuppressWarnings({ "rawtypes","unchecked" })
tablerowsorter<ComponentDeFinitionTableModel> sorter = (tablerowsorter) table.getRowSorter();
if (filterText.length() == 0) {
sorter.setRowFilter(null);
} else {
try {
RowFilter<ComponentDeFinitionTableModel,1);
sorter.setRowFilter(rf);
} catch (java.util.regex.PatternSyntaxException e) {
sorter.setRowFilter(null);
}
}
tableLabel.setText("Matching parts (" + sorter.getViewRowCount() + ")");
}
项目:SBOLDesigner
文件:SequenceInputDialog.java
private void updatefilter(String filterText) {
filterText = "(?i)" + filterText;
@SuppressWarnings({ "rawtypes","unchecked" })
tablerowsorter<SequenceTableModel> sorter = (tablerowsorter) table.getRowSorter();
if (filterText.length() == 0) {
sorter.setRowFilter(null);
} else {
try {
RowFilter<SequenceTableModel,1);
sorter.setRowFilter(rf);
} catch (java.util.regex.PatternSyntaxException e) {
sorter.setRowFilter(null);
}
}
tableLabel.setText("Matching sequences (" + sorter.getViewRowCount() + ")");
}
项目:SBOLDesigner
文件:RootInputDialog.java
private void updatefilter(String filterText) {
filterText = "(?i)" + filterText;
@SuppressWarnings({ "rawtypes",1);
sorter.setRowFilter(rf);
} catch (java.util.regex.PatternSyntaxException e) {
sorter.setRowFilter(null);
}
}
tableLabel.setText("Matching parts (" + sorter.getViewRowCount() + ")");
}
项目:beautyeye
文件:TableDemo.java
protected void configureFilters() {
if (showOnlyWinners && hasFilterString()) {
List<RowFilter<OscarTableModel,Integer>> filters = new ArrayList<RowFilter<OscarTableModel,Integer>>(
2);
filters.add(winnerFilter);
filters.add(searchFilter);
// RowFilter<Object,Object> comboFilter =
// RowFilter.andFilter(filters);
RowFilter<OscarTableModel,Integer> comboFilter = RowFilter
.<OscarTableModel,Integer> andFilter(filters);
sorter.setRowFilter(comboFilter);
} else if (showOnlyWinners) {
sorter.setRowFilter(winnerFilter);
} else if (hasFilterString()) {
sorter.setRowFilter(searchFilter);
} else {
sorter.setRowFilter(null);
}
tableStatus.setText((hasFilterString() ? searchLabelString
: statusLabelString) + oscarTable.getRowCount());
}
protected void initFilters(JTable table) {
tablerowsorter sorter = new tablerowsorter(table.getModel());
table.setRowSorter(sorter);
if (visualsFilter == null) {
visualsFilter = new RowFilter<UIDefaultsTableModel,UIDefaultsTableModel.VALUE_COLUMN);
return defaultsValue instanceof Color ||
defaultsValue instanceof Font ||
defaultsValue instanceof Icon;
}
};
}
if (onlyVisualsCheckBox.isSelected()) {
sorter.setRowFilter(visualsFilter);
}
}
项目:PasswordSafe
文件:ZTable.java
public void setRowFilter(final ZRowFilter f)
{
DefaultRowSorter rs = (DefaultRowSorter)getRowSorter();
rs.setRowFilter(new RowFilter<TableModel,Integer>()
{
public boolean include(RowFilter.Entry<? extends TableModel,? extends Integer> en)
{
if(f == null)
{
return true;
}
else
{
TableModel m = en.getModel();
Integer ix = en.getIdentifier();
return f.include(m,ix);
}
}
});
}
项目:swingx
文件:JXListTest.java
/**
* Issue #1263-swingx: JXList selectedValues must convert index to model.
*/
@Test
public void testGetSelectedValue() {
DefaultListModel model = new DefaultListModel();
model.addElement("One");
model.addElement("Two");
model.addElement("Three");
model.addElement("Four");
model.addElement("Five");
model.addElement("Six");
model.addElement("Seven");
JXList list = new JXList();
list.setautocreateRowSorter(true);
list.setModel(model);
list.setSelectedindex(2);
assertEquals("Three",list.getSelectedValue());
list.setRowFilter(new RowFilter<ListModel,Integer>() {
@Override
public boolean include(Entry<? extends ListModel,? extends Integer> entry) {
return entry.getStringValue(entry.getIdentifier()).contains("e");
}
});
assertEquals("Three",list.getSelectedValue());
}
项目:swingx
文件:JXTableVisualCheck.java
/**
* Issue #1254-swingx: JXTable not revalidated on update if filter.
*
* Core JTable issue
* Problem is that the update might change the visible row count.
*/
public void interactiveRevalidateOnUpdateWithFilter() {
String data[][] = { { "satuAA","Satu","SATU","1" },{ "duaAAB","Dua","DUA","2" },{ "tigaBAA","Tiga","TIGA","3" },{ "empatBBA","Empat","EMPAT","4" } };
String cols[] = { "col1","col2","col3","col4" };
final JXTable table = new JXTable(data,cols);
RowFilter<TableModel,Integer> tm = RowFilter.regexFilter(
".*AA.*",0);
table.setRowFilter(tm);
JXFrame frame = wrapWithScrollingInFrame(table,"Update with RowFilter");
Action action = new AbstractAction("filter first row") {
boolean hasAA = true;
@Override
public void actionPerformed(ActionEvent e) {
String newValue = hasAA ? "BB" : "AA";
hasAA = !hasAA;
table.getModel().setValueAt(newValue,0);
}
};
addAction(frame,action);
show(frame);
}
项目: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",table.getSelectedindex());
assertFalse(table.isSelectionEmpty());
}
项目:swingx
文件:ListSortUITest.java
/**
*
* Issue #173-swingx.
*
* table.setFilters() leads to selectionListener
* notification while internal table state not yet stable.
*
* example (second one,from Nicola):
* http://www.javadesktop.org/forums/thread.jspa?messageID=117814
*
*/
@Test
public void testSelectionListenerNotification() {
assertEquals(20,list.getElementCount());
final int modelRow = 0;
// set a selection
list.setSelectedindex(modelRow);
ListSelectionListener l = new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) return;
int viewRow = list.getSelectedindex();
assertEquals("view index visible",viewRow);
// JW: the following checks if the reverse conversion succeeds
list.convertIndexToModel(viewRow);
}
};
list.getSelectionModel().addListSelectionListener(l);
RowFilter<ListModel,Integer> filter = RowFilters.regexFilter("0",0);
((ListSortController<? extends ListModel>) list.getRowSorter()).setRowFilter(filter);
assertEquals(2,list.getElementCount());
}
项目:swingx
文件:OscarFiltering.java
private void updatefilters() {
// <snip> Filter control
// set the filters to the table
if ((searchFilter != null) && (winnerFilter != null)) {
List<RowFilter<Object,Object>> filters =
new ArrayList<RowFilter<Object,Object>>(2);
filters.add(winnerFilter);
filters.add(searchFilter);
RowFilter<Object,Object> comboFilter = RowFilter.andFilter(filters);
oscarTable.setRowFilter(comboFilter);
} else if (searchFilter != null) {
oscarTable.setRowFilter(searchFilter);
} else {
oscarTable.setRowFilter(winnerFilter);
}
// </snip>
}
项目:swingx
文件:DecoratorDemo.java
/**
* called after find modus changed.
*
*/
private void updateDecorators() {
boolean highlightMatches = findModi[0].equals(getFindModus());
// update the Highlighter pipelines
updatePipeline(tableHighlighters,highlightMatches);
updatePipeline(listHighlighters,highlightMatches);
// tree does not support filtering
tree.setEnabled(!findModi[1].equals(getFindModus()));
// filter/search support is implemented for JXList
RowFilter listFilters = findModi[1].equals(getFindModus()) ?
getFilterPipeline("list"): null;
list.setRowFilter(listFilters);
// filter/search support is implemented for JXTable only
RowFilter filters = findModi[1].equals(getFindModus()) ?
getFilterPipeline("table"): null;
table.setRowFilter(filters);
findNextAction.setEnabled(findModi[2].equals(getFindModus()));
// repaint();
}
protected void initFilters(JTable table) {
tablerowsorter sorter = new tablerowsorter(table.getModel());
table.setRowSorter(sorter);
if (visualsFilter == null) {
visualsFilter = new RowFilter<UIDefaultsTableModel,UIDefaultsTableModel.VALUE_COLUMN);
return defaultsValue instanceof Color ||
defaultsValue instanceof Font ||
defaultsValue instanceof Icon;
}
};
}
if (onlyVisualsCheckBox.isSelected()) {
sorter.setRowFilter(visualsFilter);
}
}
项目:chatty
文件:StatusHistoryTable.java
public void filter(final String game,final boolean favorites) {
if (game == null && !favorites) {
resetFilter();
} else {
sorter.setRowFilter(new RowFilter<Model,Integer>() {
@Override
public boolean include(RowFilter.Entry<? extends Model,? extends Integer> entry) {
Model model = entry.getModel();
StatusHistoryEntry e = model.get(entry.getIdentifier());
if (game != null && !game.equals(e.game)) {
return false;
}
if (favorites && !e.favorite) {
return false;
}
return true;
}
});
}
}
项目:esadb
文件:ResultRowFilter.java
@Override
public boolean include(RowFilter.Entry<? extends ResultTableModel,? extends Integer> entry) {
ResultTableModel model = entry.getModel();
Result result = (Result) model.getValueAt(entry.getIdentifier(),-1);
if (teams != result instanceof Team) return false;
if (cd != null && cd.doFilter() && !cd.getSelectedItem().equals(result.getdisziplin())) {
return false;
}
if (cg != null && cg.doFilter() && !cg.getSelectedItem().equals(result.getGroup(false))) {
return false;
}
if (!teams && team != null) {
int row = team.getSelectedRow();
if (row >= 0) {
Team t = (Team) team.getValueAt(row,-1);
return t.contains((Single) result) == member;
}
}
return true;
}
项目:dita-semia-resolver
文件:AdvancedKeyrefDialog.java
private void init() {
filters = new ArrayList<RowFilter<KeyDefTableModel,Object>>(2);
JPanel contextPanel = new JPanel();
JPanel filterPanel = new JPanel();
JPanel tablePanel = new JPanel();
JPanel selectionPanel = new JPanel();
JPanel previewPanel = new JPanel();
createTablePanel(tablePanel);
createContextPanel(contextPanel);
createFilterPanel(filterPanel);
createSelectionPanel(selectionPanel);
createPreviewPanel(previewPanel);
mainPanel.setLayout(new BoxLayout(mainPanel,BoxLayout.PAGE_AXIS));
mainPanel.add(contextPanel);
mainPanel.add(filterPanel);
mainPanel.add(tablePanel);
mainPanel.add(selectionPanel);
mainPanel.add(previewPanel);
}
@Override
public boolean include(final javax.swing.RowFilter.Entry<? extends TableModel,? extends Integer> entry)
{
for (int i = entry.getValueCount() - 1; i >= 0; i--)
{
String entryValue = entry.getStringValue(i);
if (entryValue == null || entryValue.isEmpty())
{
continue;
}
entryValue = entryValue.toupperCase();
if (entryValue.indexOf(textUC) >= 0)
{
return true;
}
}
return false;
}
@SuppressWarnings("unchecked")
public void execute(MVCEvent argEvent) {
ToggledisabledUsersEvent event = (ToggledisabledUsersEvent) argEvent;
boolean show = event.show;
tablerowsorter<SecurityUserTableModelA> useRSSorter = event.model.getUseRSSortera();
if(show){
useRSSorter.setRowFilter(null);
}
else
{
RowFilter<SecurityUserTableModelA,Object> rf = null;
//If current expression doesn't parse,don't update.
try {
rf = RowFilter.regexFilter("t",5);
} catch (java.util.regex.PatternSyntaxException e) {
return;
}
useRSSorter.setRowFilter(rf);
}
}
项目:Chatty-Twitch-Client
文件:StatusHistoryTable.java
public void filter(final String game,? extends Integer> entry) {
Model model = entry.getModel();
StatusHistoryEntry e = model.get(entry.getIdentifier());
if (game != null && !game.equals(e.game)) {
return false;
}
if (favorites && !e.favorite) {
return false;
}
return true;
}
});
}
}
项目:Qora
文件:Gui.java
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;
}
项目:dwoss
文件:PojoTableModel.java
public void setTable(JTable table) {
if ( table == null ) return;
this.table = table;
for (int i = 0; i < columns.size(); i++) {
table.getColumnModel().getColumn(i).setPreferredWidth(columns.get(i).getPreferredWidth());
}
tablerowsorter<PojoTableModel<T>> rowSorter = new tablerowsorter<PojoTableModel<T>>(this);
rowSorter.setRowFilter(new RowFilter<PojoTableModel<T>,Integer>() {
@Override
public boolean include(RowFilter.Entry<? extends PojoTableModel<T>,? extends Integer> entry) {
if ( filter == null ) return true;
return filter.filter(entry.getModel().getLines().get(entry.getIdentifier()));
}
});
table.setRowSorter(rowSorter);
}
@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));
}
}
});
}
public static void filterTable (JTable table,String text) {
tablerowsorter<TableModel> sorter = new tablerowsorter<TableModel>(table.getModel());
table.setRowSorter(sorter);
if ( text.equalsIgnoreCase(" ") ) {
sorter.setRowFilter(null);
}
else {
try {
sorter.setRowFilter(RowFilter.regexFilter("(?i)" + text));
}
catch (PatternSyntaxException e){
}
}
}
public static void filterTable (final JTable table,final ArrayList<String> aList) {
tablerowsorter<TableModel> sorter = new tablerowsorter<TableModel>(table.getModel());
table.setRowSorter(sorter);
sorter.setRowFilter( new RowFilter<TableModel,Object>() {
public boolean include (Entry entry) {
String row = String.valueOf(entry.getValue(0));
if ( aList.contains(row))
return true;
else
return false;
}
});
}
项目:TwitchChatClient
文件:StatusHistoryTable.java
public void filter(final String game,? extends Integer> entry) {
Model model = entry.getModel();
StatusHistoryEntry e = model.get(entry.getIdentifier());
if (game != null && !game.equals(e.game)) {
return false;
}
if (favorites && !e.favorite) {
return false;
}
return true;
}
});
}
}
项目:Simulateur
文件:JCaptures.java
/**
* Met � jour le contenu du tableau en fonction des filtres utilisateurs.
*/
public static void updatefilter(){
for(int i = 0; i<onglet.getTabCount(); i++){
Analyse tmp = ((Analyse)onglet.getComponentAt(i));
LinkedList <RowFilter<Object,Object>> filters = new LinkedList<>();
for(int cond=0; cond<paquets.length; cond++){
if(filtrePaquet[cond]){
filters.add(RowFilter.regexFilter(paquets[cond],7));
}
}
tmp.sorter.setRowFilter(RowFilter.orFilter(filters));
}
}
项目:breakout
文件:AnnotatingJTables.java
public static DocumentListener createFilterFieldListener(
final AnnotatingJTable table,final JTextComponent filterField,final RowFilterFactory<String,TableModel,Integer> filterFactory) {
return new EasyDocumentListener() {
@Override
public void documentChanged(DocumentEvent e) {
if (table.getAnnotatingRowSorter() == null) {
return;
}
if (filterField.getText() != null && filterField.getText().length() > 0) {
RowFilter<TableModel,Integer> filter = null;
try {
filter = filterFactory.createFilter(filterField.getText());
filterField.setForeground(Color.BLACK);
} catch (Exception ex) {
filterField.setForeground(Color.RED);
}
table.getAnnotatingRowSorter().setRowFilter(filter);
} else {
filterField.setForeground(Color.BLACK);
table.getAnnotatingRowSorter().setRowFilter(null);
}
}
};
}
项目:breakout
文件:DescriptionFilter.java
@Override
public boolean include(javax.swing.RowFilter.Entry<? extends TableModel,? extends Integer> entry) {
if (descriptions.length == 0) {
return true;
}
SurveyRow row = ((SurveyTableModel) entry.getModel()).getRow(entry.getIdentifier());
if (row == null || row.getTrip() == null || row.getTrip().getName() == null) {
return false;
}
String desc = row.getTrip().getName().toLowerCase();
for (Pattern description : descriptions) {
if (!description.matcher(desc).find()) {
return false;
}
}
return true;
}
项目:breakout
文件:SurveyorFilter.java
@Override
public boolean include(javax.swing.RowFilter.Entry<? extends TableModel,? extends Integer> entry) {
if (patterns.length == 0) {
return false;
}
SurveyRow row = ((SurveyTableModel) entry.getModel()).getRow(entry.getIdentifier());
if (row == null || row.getTrip() == null || row.getTrip().getSurveyors() == null) {
return false;
}
for (Pattern pattern : patterns) {
if (!row.getTrip().getSurveyors().stream().anyMatch(surveyor -> pattern.matcher(surveyor).find())) {
return false;
}
}
return true;
}
项目:McLauncher
文件: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());
}
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,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,2,3);
rf = RowFilter.andFilter(rfs);
} catch (java.util.regex.PatternSyntaxException e) {
return;
}
tSorter.setRowFilter(rf);
}
public Selecttablerowsorter(final T model,final Map<String,String> filters) {
super(model);
if (filters != null && !filters.isEmpty()) {
setRowFilter(new RowFilter<T,Object>() {
@Override
public boolean include(RowFilter.Entry<? extends T,? extends Object> entry) {
for (int i = 0; i < model.getColumnCount(); i++) {
String filter = filters.get(model.getColumnName(i));
if (filter != null && !entry.getStringValue(i).equals(filter)) {
return false;
}
}
return true;
}
});
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。