Java Code Examples for javax.swing.RowSorter.SortKey#getSortOrder()
The following examples show how to use
javax.swing.RowSorter.SortKey#getSortOrder() .
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 File: SubstanceTableUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
private boolean isSameSorter(List<? extends SortKey> sortKeys1, List<? extends SortKey> sortKeys2) { int size1 = (sortKeys1 == null) ? 0 : sortKeys1.size(); int size2 = (sortKeys2 == null) ? 0 : sortKeys2.size(); if ((size1 == 0) && (size2 == 0)) { return true; } if ((sortKeys1 == null) && (sortKeys2 == null)) return true; if ((sortKeys1 == null) || (sortKeys2 == null)) return false; if (size1 != size2) return false; for (int i = 0; i < size1; i++) { SortKey sortKey1 = sortKeys1.get(i); SortKey sortKey2 = sortKeys2.get(i); if ((sortKey1.getColumn() != sortKey2.getColumn()) || (sortKey1.getSortOrder() != sortKey2.getSortOrder())) { return false; } } return true; }
Example 2
Source File: SubstanceTableUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void valueChanged(final ListSelectionEvent e) { // fix for issue 478 - no animations when sorter has changed List<? extends SortKey> sortKeys = (table.getRowSorter() == null) ? null : table.getRowSorter().getSortKeys(); boolean isDifferentSorter = !isSameSorter(sortKeys, oldSortKeys); if (e.getValueIsAdjusting() && isDifferentSorter) return; if (sortKeys == null) { oldSortKeys = null; } else { oldSortKeys = new ArrayList<>(); for (SortKey sortKey : sortKeys) { SortKey copy = new SortKey(sortKey.getColumn(), sortKey.getSortOrder()); oldSortKeys.add(copy); } } syncSelection(isDifferentSorter); }
Example 3
Source File: TableHeaderUI.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@Override public Icon getIcon() { int modelCol = header.getTable().convertColumnIndexToModel(curCol); TableModel model = header.getTable().getModel(); if (model instanceof ExtendedJTableSorterModel) { ExtendedJTableSorterModel sortModel = (ExtendedJTableSorterModel) model; switch (sortModel.getSortingStatus(modelCol)) { case ExtendedJTableSorterModel.ASCENDING: return UIManager.getIcon("Table.ascendingSortIcon"); case ExtendedJTableSorterModel.DESCENDING: return UIManager.getIcon("Table.descendingSortIcon"); case ExtendedJTableSorterModel.NOT_SORTED: default: return null; } } else { SortKey sortKey = getSortKey(header.getTable().getRowSorter(), modelCol); SortOrder sortOrder = sortKey != null ? sortKey.getSortOrder() : SortOrder.UNSORTED; switch (sortOrder) { case ASCENDING: return UIManager.getIcon("Table.ascendingSortIcon"); case DESCENDING: return UIManager.getIcon("Table.descendingSortIcon"); case UNSORTED: default: return null; } } }
Example 4
Source File: DefaultTableHeaderCellRenderer.java From mars-sim with GNU General Public License v3.0 | 5 votes |
/** * Overloaded to return an icon suitable to the primary sorted column, or null if * the column is not the primary sort key. * * @param table the <code>JTable</code>. * @param column the column index. * @return the sort icon, or null if the column is unsorted. */ protected Icon getIcon(JTable table, int column) { SortKey sortKey = getSortKey(table, column); if (sortKey != null && table.convertColumnIndexToView(sortKey.getColumn()) == column) { switch (sortKey.getSortOrder()) { case ASCENDING: return UIManager.getIcon("Table.ascendingSortIcon"); case DESCENDING: return UIManager.getIcon("Table.descendingSortIcon"); } } return null; }