Class TableSortController<M extends TableModel>
java.lang.Object
javax.swing.RowSorter<M>
javax.swing.DefaultRowSorter<M,Integer>
org.jdesktop.swingx.sort.DefaultSortController<M>
org.jdesktop.swingx.sort.TableSortController<M>
- All Implemented Interfaces:
SortController<M>
A SortController to use for a JXTable.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classImplementation of DefaultRowSorter.ModelWrapper that delegates to a TableModel.Nested classes/interfaces inherited from class DefaultRowSorter
DefaultRowSorter.ModelWrapper<M,I> Nested classes/interfaces inherited from class RowSorter
RowSorter.SortKey -
Field Summary
FieldsFields inherited from class DefaultSortController
cachedModelRowCount, COMPARABLE_COMPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionComparator<?> getComparator(int column) Returns theComparatorfor the specified column.voidSets theTableModelto use as the underlying model for thisTableRowSorter.protected booleanuseToString(int column) Methods inherited from class DefaultSortController
allRowsChanged, convertRowIndexToModel, convertRowIndexToView, getDefaultSortOrderCycle, getModelRowCount, getSortOrder, getSortOrderCycle, getStringValueProvider, getViewRowCount, isSortable, isSortable, modelStructureChanged, resetSortOrders, rowsDeleted, rowsInserted, setSortable, setSortable, setSortOrder, setSortOrderCycle, setStringValueProvider, toggleSortOrderMethods inherited from class DefaultRowSorter
getMaxSortKeys, getModel, getModelWrapper, getRowFilter, getSortKeys, getSortsOnUpdates, rowsUpdated, rowsUpdated, setComparator, setMaxSortKeys, setModelWrapper, setRowFilter, setSortKeys, setSortsOnUpdates, sortMethods inherited from class RowSorter
addRowSorterListener, fireRowSorterChanged, fireSortOrderChanged, removeRowSorterListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SortController
getRowFilter, getSortsOnUpdates, setComparator, setRowFilter, setSortsOnUpdates
-
Field Details
-
tableModel
Underlying model.
-
-
Constructor Details
-
TableSortController
public TableSortController() -
TableSortController
- Parameters:
model-
-
-
Method Details
-
setModel
Sets theTableModelto use as the underlying model for thisTableRowSorter. A value ofnullcan be used to set an empty model.- Parameters:
model- the underlying model to use, ornull
-
getComparator
Returns theComparatorfor the specified column. If aComparatorhas not been specified using thesetComparatormethod aComparatorwill be returned based on the column class (TableModel.getColumnClass) of the specified column. If the column class isString,Collator.getInstanceis returned. If the column class implementsComparablea privateComparatoris returned that invokes thecompareTomethod. OtherwiseCollator.getInstanceis returned.PENDING JW: think about implications to string value lookup!
- Specified by:
getComparatorin interfaceSortController<M extends TableModel>- Overrides:
getComparatorin classDefaultRowSorter<M extends TableModel, Integer>- Parameters:
column- the column to fetch theComparatorfor, in terms of the underlying model- Returns:
- the
Comparatorfor the specified column - Throws:
IndexOutOfBoundsException- if column is outside the range of the underlying model
-
useToString
protected boolean useToString(int column) Note: must implement same logic as the overridden comparator lookup, otherwise will throw ClassCastException because here the comparator is never null.
PENDING JW: think about implications to string value lookup!
- Overrides:
useToStringin classDefaultRowSorter<M extends TableModel, Integer>
-