Package jmri.swing
Class RowSorterUtil
java.lang.Object
jmri.swing.RowSorterUtil
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.SortKeys returned by
RowSorter.getSortKeys().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RowSorterListeneraddSingleSortableColumnListener(RowSorter<? extends TableModel> rowSorter) Add a RowSorterListener to the rowSorter that prevents multiple columns from being considered while sorting.static SortOrdergetSortOrder(RowSorter<? extends TableModel> rowSorter, int column) Get the sort order for a column given a RowSorter for the TableModel containing the column.static voidsetSortOrder(RowSorter<? extends TableModel> rowSorter, int column, SortOrder sortOrder) Set the sort order for a table using the specified column given a RowSorter for the TableModel containing the column.
-
Constructor Details
-
RowSorterUtil
public RowSorterUtil()
-
-
Method Details
-
getSortOrder
@Nonnull public static SortOrder getSortOrder(@Nonnull RowSorter<? extends 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 RowSorter<? extends TableModel> rowSorter, int column, @Nonnull 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 RowSorterListener addSingleSortableColumnListener(@Nonnull RowSorter<? extends 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:
NullPointerException- if rowSorter is null
-