Java Code Examples for javax.swing.DefaultRowSorter

The following examples show how to use javax.swing.DefaultRowSorter. These examples are extracted from open source projects. 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 Project: gameserver   Source File: MongoRowFilterAction.java    License: Apache License 2.0 6 votes vote down vote up
@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 2
Source Project: netbeans   Source File: DataViewUI.java    License: Apache License 2.0 5 votes vote down vote up
private void processKeyEvents() {
    ResultSetJXTable table = getDataViewTableUI();
    int[] rows = new int[table.getColumnCount()];
    for (int i = 0; i < table.getColumnCount(); i++) {
        rows[i] = i;
    }
    {
        MultiColPatternFilter filterP = new MultiColPatternFilter(rows);
        filterP.setFilterStr(matchBoxField.getText(), LITERAL_FIND);
        ((DefaultRowSorter) table.getRowSorter()).setRowFilter(filterP);
    }
}
 
Example 3
Source Project: scelight   Source File: XTable.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setSortable( final boolean sortable ) {
	@SuppressWarnings( "unchecked" )
	final DefaultRowSorter< TableModel, Integer > rowSorter = (DefaultRowSorter< TableModel, Integer >) getRowSorter();
	for ( int i = tableModel.getColumnCount() - 1; i >= 0; i-- )
		rowSorter.setSortable( i, sortable );
}
 
Example 4
public PasswordManager() {

		super(ApplicationFrame.getApplicationFrame(), "password_manager", ModalityType.MODELESS, new Object[0]);
		this.clone = new Wallet(Wallet.getInstance());

		credentialsModel = new CredentialsTableModel(clone);
		final JTable table = new JTable(credentialsModel);
		table.setAutoCreateRowSorter(true);
		((DefaultRowSorter<?, ?>) table.getRowSorter()).setMaxSortKeys(1);
		JScrollPane scrollPane = new ExtendedJScrollPane(table);
		scrollPane.setBorder(null);
		JPanel main = new JPanel(new BorderLayout());
		main.add(scrollPane, BorderLayout.CENTER);

		ResourceAction removePasswordAction = new ResourceAction("password_manager_remove_row") {

			private static final long serialVersionUID = 1L;

			@Override
			public void loggedActionPerformed(ActionEvent e) {
				int[] selectedTableRows = table.getSelectedRows();
				ArrayList<Integer> modelRows = new ArrayList<>(selectedTableRows.length);
				for (int i = 0; i <= selectedTableRows.length - 1; i++) {
					modelRows.add(table.getRowSorter().convertRowIndexToModel(selectedTableRows[i]));
				}
				Collections.sort(modelRows);
				for (int i = modelRows.size() - 1; i >= 0; i--) {
					credentialsModel.removeRow(modelRows.get(i));
				}
			}
		};

		JPanel buttonPanel = new JPanel(new BorderLayout());
		buttonPanel.add(makeButtonPanel(new JButton(removePasswordAction), makeOkButton("password_manager_save"),
				makeCancelButton()), BorderLayout.EAST);
		layoutDefault(main, buttonPanel, LARGE);
	}
 
Example 5
Source Project: MobyDroid   Source File: JPanel_FileBrowser.java    License: Apache License 2.0 4 votes vote down vote up
public TableRowSorterModelWrapper(DefaultRowSorter.ModelWrapper modelWrapperImplementation) {
    this.modelWrapperImplementation = modelWrapperImplementation;
}
 
Example 6
Source Project: MobyDroid   Source File: JPanel_AppInstaller.java    License: Apache License 2.0 4 votes vote down vote up
public TableRowSorterModelWrapper(DefaultRowSorter.ModelWrapper modelWrapperImplementation) {
    this.modelWrapperImplementation = modelWrapperImplementation;
}
 
Example 7
Source Project: MobyDroid   Source File: JPanel_AppManager.java    License: Apache License 2.0 4 votes vote down vote up
public TableRowSorterModelWrapper(DefaultRowSorter.ModelWrapper modelWrapperImplementation) {
    this.modelWrapperImplementation = modelWrapperImplementation;
}
 
Example 8
Source Project: MobyDroid   Source File: JPanel_TaskManager.java    License: Apache License 2.0 4 votes vote down vote up
public TableRowSorterModelWrapper(DefaultRowSorter.ModelWrapper modelWrapperImplementation) {
    this.modelWrapperImplementation = modelWrapperImplementation;
}
 
Example 9
Source Project: megamek   Source File: UnitSelectorDialog.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    // Loading mechs can take a while, so it will have its own thread.
    // This prevents the UI from freezing, and allows the
    // "Please wait..." dialog to behave properly on various Java VMs.
    MechSummaryCache mscInstance = MechSummaryCache.getInstance();
    mechs = mscInstance.getAllMechs();

    // break out if there are no units to filter
    if (mechs == null) {
        System.err.println("No units to filter!");
    } else {
        unitModel.setData(mechs);
    }
    filterUnits();

    //initialize with the units sorted alphabetically by chassis
    ArrayList<SortKey> sortlist = new ArrayList<>();
    sortlist.add(new SortKey(MechTableModel.COL_CHASSIS,SortOrder.ASCENDING));
    //sortlist.add(new RowSorter.SortKey(MechTableModel.COL_MODEL,SortOrder.ASCENDING));
    tableUnits.getRowSorter().setSortKeys(sortlist);
    ((DefaultRowSorter<?, ?>)tableUnits.getRowSorter()).sort();

    tableUnits.invalidate(); // force re-layout of window
    pack();
    //setLocation(computeDesiredLocation());

    unitLoadingDialog.setVisible(false);

    // In some cases, it's possible to get here without an initialized
    // instance (loading a saved game without a cache).  In these cases,
    // we dn't care about the failed loads.
    if (mscInstance.isInitialized() && !useAlternate)
    {
        final Map<String, String> hFailedFiles =
            MechSummaryCache.getInstance().getFailedFiles();
        if ((hFailedFiles != null) && (hFailedFiles.size() > 0)) {
            // self-showing dialog
            new UnitFailureDialog(frame, hFailedFiles);
        }
    }
    GUIPreferences guip = GUIPreferences.getInstance();
    int width = guip.getMechSelectorSizeWidth();
    int height = guip.getMechSelectorSizeHeight();
    setSize(width,height);
}