Package org.jdesktop.swingx.sort
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>
public class TableSortController<M extends TableModel> extends DefaultSortController<M>
A SortController to use for a JXTable.PENDING JW: should move up to DefaultRowSorter for re-use in ListRowSorter, but as long as we don't have the latter ...
- Author:
- Jeanette Winzenburg
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.DefaultRowSorter
DefaultRowSorter.ModelWrapper<M extends Object,I extends Object>
-
Nested classes/interfaces inherited from class javax.swing.RowSorter
RowSorter.SortKey
-
-
Field Summary
-
Fields inherited from class org.jdesktop.swingx.sort.DefaultSortController
cachedModelRowCount, COMPARABLE_COMPARATOR
-
-
Constructor Summary
Constructors Constructor Description TableSortController()
TableSortController(M model)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Comparator<?>
getComparator(int column)
Returns theComparator
for the specified column.void
setModel(M model)
Sets theTableModel
to use as the underlying model for thisTableRowSorter
.protected boolean
useToString(int column)
-
Methods inherited from class org.jdesktop.swingx.sort.DefaultSortController
allRowsChanged, convertRowIndexToModel, convertRowIndexToView, getDefaultSortOrderCycle, getModelRowCount, getSortOrder, getSortOrderCycle, getStringValueProvider, getViewRowCount, isSortable, isSortable, modelStructureChanged, resetSortOrders, rowsDeleted, rowsInserted, setSortable, setSortable, setSortOrder, setSortOrderCycle, setStringValueProvider, toggleSortOrder
-
Methods inherited from class javax.swing.DefaultRowSorter
getMaxSortKeys, getModel, getModelWrapper, getRowFilter, getSortKeys, getSortsOnUpdates, rowsUpdated, rowsUpdated, setComparator, setMaxSortKeys, setModelWrapper, setRowFilter, setSortKeys, setSortsOnUpdates, sort
-
Methods inherited from class javax.swing.RowSorter
addRowSorterListener, fireRowSorterChanged, fireSortOrderChanged, removeRowSorterListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jdesktop.swingx.sort.SortController
getRowFilter, getSortsOnUpdates, setComparator, setRowFilter, setSortsOnUpdates
-
-
-
-
Constructor Detail
-
TableSortController
public TableSortController()
-
TableSortController
public TableSortController(M model)
- Parameters:
model
-
-
-
Method Detail
-
setModel
public void setModel(M model)
Sets theTableModel
to use as the underlying model for thisTableRowSorter
. A value ofnull
can be used to set an empty model.- Parameters:
model
- the underlying model to use, ornull
-
getComparator
public Comparator<?> getComparator(int column)
Returns theComparator
for the specified column. If aComparator
has not been specified using thesetComparator
method aComparator
will be returned based on the column class (TableModel.getColumnClass
) of the specified column. If the column class isString
,Collator.getInstance
is returned. If the column class implementsComparable
a privateComparator
is returned that invokes thecompareTo
method. OtherwiseCollator.getInstance
is returned.PENDING JW: think about implications to string value lookup!
- Specified by:
getComparator
in interfaceSortController<M extends TableModel>
- Overrides:
getComparator
in classDefaultRowSorter<M extends TableModel,Integer>
- Parameters:
column
- the column to fetch theComparator
for, in terms of the underlying model- Returns:
- the
Comparator
for 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:
useToString
in classDefaultRowSorter<M extends TableModel,Integer>
- Throws:
IndexOutOfBoundsException
-
-