Package jmri.swing
Class RowSorterUtil
- java.lang.Object
-
- jmri.swing.RowSorterUtil
-
public final class RowSorterUtil extends java.lang.Object
Utilities for handling JTable row sorting, assuming only a single column influences the table sort order.Multi-column sorting should be controlled by directly manipulating the
RowSorter.SortKey
s returned byRowSorter.getSortKeys()
.
-
-
Constructor Summary
Constructors Constructor Description RowSorterUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.swing.event.RowSorterListener
addSingleSortableColumnListener(javax.swing.RowSorter<? extends javax.swing.table.TableModel> rowSorter)
Add a RowSorterListener to the rowSorter that prevents multiple columns from being considered while sorting.static javax.swing.SortOrder
getSortOrder(javax.swing.RowSorter<? extends javax.swing.table.TableModel> rowSorter, int column)
Get the sort order for a column given a RowSorter for the TableModel containing the column.static void
setSortOrder(javax.swing.RowSorter<? extends javax.swing.table.TableModel> rowSorter, int column, javax.swing.SortOrder sortOrder)
Set the sort order for a table using the specified column given a RowSorter for the TableModel containing the column.
-
-
-
Constructor Detail
-
RowSorterUtil
public RowSorterUtil()
-
-
Method Detail
-
getSortOrder
@Nonnull public static javax.swing.SortOrder getSortOrder(@Nonnull javax.swing.RowSorter<? extends javax.swing.table.TableModel> rowSorter, int column)
Get the sort order for a column given a RowSorter for the TableModel containing the column.- Parameters:
rowSorter
- the sortercolumn
- the column index in the model, not the view- Returns:
- the sort order or
SortOrder.UNSORTED
.
-
setSortOrder
public static void setSortOrder(@Nonnull javax.swing.RowSorter<? extends javax.swing.table.TableModel> rowSorter, int column, @Nonnull javax.swing.SortOrder sortOrder)
Set the sort order for a table using the specified column given a RowSorter for the TableModel containing the column.This makes all other columns unsorted, even if the specified column is also specified to be unsorted.
- Parameters:
rowSorter
- the sortercolumn
- the column index in the model, not the viewsortOrder
- the sort order
-
addSingleSortableColumnListener
public static javax.swing.event.RowSorterListener addSingleSortableColumnListener(@Nonnull javax.swing.RowSorter<? extends javax.swing.table.TableModel> rowSorter)
Add a RowSorterListener to the rowSorter that prevents multiple columns from being considered while sorting.- Parameters:
rowSorter
- the sorter to add the listener to- Returns:
- the added listener
- Throws:
java.lang.NullPointerException
- if rowSorter is null
-
-