當前位置: 首頁>>代碼示例>>Java>>正文


Java RowFilter類代碼示例

本文整理匯總了Java中javax.swing.RowFilter的典型用法代碼示例。如果您正苦於以下問題:Java RowFilter類的具體用法?Java RowFilter怎麽用?Java RowFilter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RowFilter類屬於javax.swing包,在下文中一共展示了RowFilter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: include

import javax.swing.RowFilter; //導入依賴的package包/類
@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;
	}
 
開發者ID:lmazuel,項目名稱:onagui,代碼行數:24,代碼來源:MappingRowFilter.java

示例2: configureFilters

import javax.swing.RowFilter; //導入依賴的package包/類
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());

}
 
開發者ID:freeseawind,項目名稱:littleluck,代碼行數:20,代碼來源:TableDemo.java

示例3: initFilters

import javax.swing.RowFilter; //導入依賴的package包/類
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);
    }
}
 
開發者ID:freeseawind,項目名稱:littleluck,代碼行數:23,代碼來源:DefaultsDisplay.java

示例4: updateFilter

import javax.swing.RowFilter; //導入依賴的package包/類
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() + ")");
}
 
開發者ID:MyersResearchGroup,項目名稱:iBioSim,代碼行數:19,代碼來源:SBOLInputDialog.java

示例5: createFilter

import javax.swing.RowFilter; //導入依賴的package包/類
/** 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);
		}
	};
}
 
開發者ID:CA-IRIS,項目名稱:ca-iris,代碼行數:17,代碼來源:ControllerTableModel.java

示例6: segmentsTableFilterOnFirstLevel

import javax.swing.RowFilter; //導入依賴的package包/類
/**
 * 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());
}
 
開發者ID:fiohol,項目名稱:theSemProject,代碼行數:32,代碼來源:FilesAndSegmentsUtils.java

示例7: filterTable

import javax.swing.RowFilter; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:fiohol,項目名稱:theSemProject,代碼行數:26,代碼來源:GuiUtils.java

示例8: filterOnStatus

import javax.swing.RowFilter; //導入依賴的package包/類
/**
 * 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());
}
 
開發者ID:fiohol,項目名稱:theSemProject,代碼行數:27,代碼來源:GuiUtils.java

示例9: updateFilter

import javax.swing.RowFilter; //導入依賴的package包/類
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, 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() + ")");
}
 
開發者ID:SynBioDex,項目名稱:SBOLDesigner,代碼行數:18,代碼來源:PartInputDialog.java

示例10: updateFilter

import javax.swing.RowFilter; //導入依賴的package包/類
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, Object> rf = RowFilter.regexFilter(filterText, 0, 1);
			sorter.setRowFilter(rf);
		} catch (java.util.regex.PatternSyntaxException e) {
			sorter.setRowFilter(null);
		}
	}

	tableLabel.setText("Matching sequences (" + sorter.getViewRowCount() + ")");
}
 
開發者ID:SynBioDex,項目名稱:SBOLDesigner,代碼行數:18,代碼來源:SequenceInputDialog.java

示例11: configureFilters

import javax.swing.RowFilter; //導入依賴的package包/類
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());

}
 
開發者ID:JackJiang2011,項目名稱:beautyeye,代碼行數:23,代碼來源:TableDemo.java

示例12: setRowFilter

import javax.swing.RowFilter; //導入依賴的package包/類
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);
			}
		}
	});
}
 
開發者ID:andy-goryachev,項目名稱:PasswordSafe,代碼行數:21,代碼來源:ZTable.java

示例13: testGetSelectedValue

import javax.swing.RowFilter; //導入依賴的package包/類
/**
 * 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());
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:29,代碼來源:JXListTest.java

示例14: interactiveRevalidateOnUpdateWithFilter

import javax.swing.RowFilter; //導入依賴的package包/類
/**
 * 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, 0);
        }
    };
    addAction(frame, action);
    show(frame);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:32,代碼來源:JXTableVisualCheck.java

示例15: testSelectionWithFilterXListRemove

import javax.swing.RowFilter; //導入依賴的package包/類
/**
 * 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());
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:32,代碼來源:ListSortUITest.java


注:本文中的javax.swing.RowFilter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。