@Override protected String convertElementToString(Object item) { if (item instanceof TreeBrowserEntry) { return ((TreeBrowserEntry) item).getType(); } return super.convertElementToString(item); } };
/** * Installs the searchable function onto a JTable. * * @param table the JTable to install searchable * @return A TableSearchable */ public static TableSearchable installSearchable(JTable table) { return new TableSearchable(table); }
@Override protected void setSelectedIndex(int index, boolean incremental) { int majorIndex, minorIndex; JTable table = ((JTable) _component); if (isColumnSelectionAllowed(table)) { minorIndex = index; majorIndex = getMainIndex(); addTableSelection(table, majorIndex, minorIndex, incremental); } else if (isRowSelectionAllowed(table)) { majorIndex = index; minorIndex = table.convertColumnIndexToView(getMainIndex()); addTableSelection(table, majorIndex, minorIndex, incremental); } else { // cell selection allowed int columnCount = table.getColumnCount(); if (columnCount == 0) { return; } majorIndex = index / columnCount; minorIndex = index % columnCount; addTableSelection(table, majorIndex, minorIndex, incremental); } }
public void tableChanged(TableModelEvent e) { if (isProcessModelChangeEvent()) { hidePopup(); fireSearchableEvent(new SearchableEvent(this, SearchableEvent.SEARCHABLE_MODEL_CHANGE)); } }
public void propertyChange(PropertyChangeEvent evt) { if ("model".equals(evt.getPropertyName())) { hidePopup(); if (evt.getOldValue() instanceof TableModel) { ((TableModel) evt.getOldValue()).removeTableModelListener(this); } if (evt.getNewValue() instanceof TableModel) { ((TableModel) evt.getNewValue()).addTableModelListener(this); } fireSearchableEvent(new SearchableEvent(this, SearchableEvent.SEARCHABLE_MODEL_CHANGE)); } }
@Override protected Object getElementAt(int index) { JTable table = (JTable) _component; if (isColumnSelectionAllowed(table)) { // column selection mode return getValueAt(table, getMainIndex(), index); } else if (isRowSelectionAllowed(table)) { // row selection mode return getValueAt(table, index, table.convertColumnIndexToView(getMainIndex())); } else if (isSearchSelectedRows()) { // search on multi columns int columnIndex = index % table.getColumnCount(); int modelIndex = table.convertColumnIndexToModel(columnIndex); boolean doNotSearch = true; for (int i : getSearchColumnIndices()) { if (i == modelIndex) { doNotSearch = false; } } if (doNotSearch) { return null; } int rowIndex = index / table.getColumnCount(); return getValueAt(table, rowIndex, columnIndex); } else { // cell selection allowed int columnIndex = index % table.getColumnCount(); int rowIndex = index / table.getColumnCount(); return getValueAt(table, rowIndex, columnIndex); } }
private void initComponents() { manifestsTableAdjuster.adjustColumns(); manifestsTableAdjuster.setDynamicAdjustment(true); manifestsTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); manifestsTable.setAutoCreateRowSorter(true); JPanel container = new JPanel(); container.setLayout(new MigLayout("insets dialog, fill", "[grow 0][grow 100]")); container.add(new JLabel("Output Directory:")); container.add(destDirField, "span"); container.add(new JLabel("Package Listing Type:")); container.add(listingTypeCombo, "span"); container.add(gameKeyWarning, "span, skip 1, hidemode 3"); container.add(new JLabel("Modpacks to Include:"), "span, gaptop unrel"); container.add(SwingHelper.wrapScrollPane(manifestsTable), "grow, pushy, span, w 500:650, h 170"); container.add(editManifestButton, "gapbottom unrel, span, split 2"); container.add(new JLabel("<html>Previously-selected modpacks and those in the _upload directory are the available options."), "gapbottom unrel"); container.add(generateButton, "tag ok, span, split 2, sizegroup bttn"); container.add(cancelButton, "tag cancel, sizegroup bttn"); add(container, BorderLayout.CENTER); getRootPane().setDefaultButton(generateButton); getRootPane().registerKeyboardAction(e -> cancelButton.doClick(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); TableSearchable tableSearchable = SearchableUtils.installSearchable(manifestsTable); tableSearchable.setMainIndex(-1); }
/** * Are we trying to search on multi-columns (but NOT all columns)? * * @return true if the search is set to look at multi-columns (but NOT all columns). */ protected boolean isSearchSelectedRows() { return getSearchColumnIndices().length > 1; }
public static void installSearchable(JTable table) { table.setPreferredScrollableViewportSize(new Dimension(200, 24)); table.setColumnSelectionAllowed(false); table.setRowSelectionAllowed(true); TableSearchable tSearchable = SearchableUtils.installSearchable(table); setSearchableParams(tSearchable); tSearchable.setMainIndex(-1); // search for all columns //installTitledPanel("Search: ", 'T', table); }
/** * Is the column selection allowed? * * @param table the table. * @return true if the table is the column selection. */ protected boolean isColumnSelectionAllowed(JTable table) { // NOTES: must sync with TableShrinkSearchableSupport#isColumnSelectionAllowed. return getSearchColumnIndices().length == 1 && (table.getColumnSelectionAllowed() && !table.getRowSelectionAllowed()); }
private void initComponents() { updateTableAdjuster.adjustColumns(); updateTableAdjuster.setDynamicAdjustment(true); unknownTableAdjuster.adjustColumns(); unknownTableAdjuster.setDynamicAdjustment(true); knownModsTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); knownModsTable.setAutoCreateRowSorter(true); unknownModsTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); unknownModsTable.setAutoCreateRowSorter(true); JPanel container = new JPanel(); container.setLayout(new MigLayout("insets dialog, fill")); container.add(new JLabel("With Potential Updates:"), "span"); container.add(SwingHelper.wrapScrollPane(knownModsTable), "grow, pushy, span, w 500:900, h 230"); container.add(new JLabel("Unknown Status:"), "span"); container.add(SwingHelper.wrapScrollPane(unknownModsTable), "grow, pushy, span, w 500:900, h 150, gapbottom unrel, wrap"); container.add(new JLabel("Version data is sourced from NotEnoughMods.com."), ""); container.add(closeButton, "tag cancel, sizegroup bttn"); add(container, BorderLayout.CENTER); getRootPane().registerKeyboardAction(e -> closeButton.doClick(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); TableSearchable tableSearchable; tableSearchable = SearchableUtils.installSearchable(knownModsTable); tableSearchable.setMainIndex(-1); tableSearchable = SearchableUtils.installSearchable(unknownModsTable); tableSearchable.setMainIndex(-1); }
/** * Is the row selection allowed? * * @param table the table. * @return true if the table is the row selection. */ protected boolean isRowSelectionAllowed(JTable table) { // NOTES: must sync with TableShrinkSearchableSupport#isRowSelectionAllowed. return getSearchColumnIndices().length == 1 && (!table.getColumnSelectionAllowed() && table.getRowSelectionAllowed()); }
@Override protected String convertElementToString(Object item) { if (item instanceof TreeBrowserEntry) { return ((TreeBrowserEntry) item).getType(); } return super.convertElementToString(item); } };
private void initComponents() { TableColumnAdjuster adjuster = new TableColumnAdjuster(packTable); adjuster.adjustColumns(); adjuster.setDynamicAdjustment(true); packTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); packTable.setAutoCreateRowSorter(true); JPanel container = new JPanel(); container.setLayout(new MigLayout("fill, wrap 1")); container.add(createToolbar(), "dock north"); container.add(SwingHelper.wrapScrollPane(packTable), "grow, span, w null:800:null"); TableSearchable tableSearchable = SearchableUtils.installSearchable(packTable); tableSearchable.setMainIndex(-1); add(container, BorderLayout.CENTER); }
@Override protected String convertElementToString(Object item) { if (item instanceof TreeBrowserEntry) { return ((TreeBrowserEntry) item).getType(); } return super.convertElementToString(item); } };
tableSearchable.setMainIndex(-1);
@Override protected String convertElementToString(Object item) { if (item instanceof TreeBrowserEntry) { return ((TreeBrowserEntry) item).getType(); } return super.convertElementToString(item); } };
searchable.setMainIndex(0); // only search for name column
searchable.setMainIndex(0); // only search for name column
table.setRowSelectionAllowed(true); TableSearchable tableSearchable = SearchableUtils.installSearchable(table); tableSearchable.setMainIndex(-1); // search for all columns