Interface SortController<M>
- All Known Implementing Classes:
DefaultSortController
,ListSortController
,TableSortController
This is very-much work-in-progress: while moving from ol' SwingX sorting to core jdk6 sorting we need a hook for sorting api on the view. So in terms of jdk6 classes, this is something like:
All methods which change sort state must respect per-controller and per-column
sortable property, as follows
SortController == DefaultRowSorter - RowSorter + XX
- if per-controller sortable is false, do nothing
- if per-controller sortable is true, if per-column sortable is false, do nothing
- if both are true toggle the SortOrder of the given column
-
Method Summary
Modifier and TypeMethodDescriptionComparator
<?> getComparator
(int column) Returns theComparator
for the specified column.Returns the filter that determines which rows, if any, should be hidden from view.getSortOrder
(int column) Returns the sort order of the specified column.Returns the cycle of sort orders to cycle through.boolean
Returns true if a sort should happen when the underlying model is updated; otherwise, returns false.Returns the StringValueProvider used to look up StringValues.boolean
Returns true if this controller is sortable; otherwise, false.boolean
isSortable
(int column) Returns true if the specified column is sortable.void
Resets all interactive sorting.void
setComparator
(int column, Comparator<?> comparator) Sets theComparator
to use when sorting the specified column.void
setRowFilter
(RowFilter<? super M, ? super Integer> filter) Sets the filter that determines which rows, if any, should be hidden from the view.void
setSortable
(boolean sortable) Sets whether or not this controller is sortable.void
setSortable
(int column, boolean sortable) Sets whether or not the specified column is sortable.void
setSortOrder
(int column, SortOrder sortOrder) Sets the sort order of the specified column.void
setSortOrderCycle
(SortOrder... cycle) Sets the cycle of sort ordes to toggle through.void
setSortsOnUpdates
(boolean sortsOnUpdates) If true, specifies that a sort should happen when the underlying model is updated (rowsUpdated
is invoked).void
setStringValueProvider
(StringValueProvider provider) Sets the StringValueProvider to look up the StringValues.void
toggleSortOrder
(int column) Reverses the sort order of the specified column.
-
Method Details
-
setSortable
void setSortable(boolean sortable) Sets whether or not this controller is sortable.The default is true.
PENDING JW: define behaviour if sortable is disabled while has sortOrders. In this case JXTable resets all sorts.
- Parameters:
sortable
- whether or not this controller is sortable- See Also:
-
isSortable
boolean isSortable()Returns true if this controller is sortable; otherwise, false.- Returns:
- true if this controller is sortable
- See Also:
-
setSortable
void setSortable(int column, boolean sortable) Sets whether or not the specified column is sortable.The default is true.
PENDING JW: define behaviour if sortable is disabled while has sortOrders. In this case JXTable removes the sort of the column.
PENDING JW: decide whether or not this method should trigger a resort DefaultRowSorter explicitly doesn't, JXTable does.
- Parameters:
column
- the column to enable or disable sorting on, in terms of the underlying modelsortable
- whether or not the specified column is sortable- Throws:
IndexOutOfBoundsException
- ifcolumn
is outside the range of the model- See Also:
-
isSortable
boolean isSortable(int column) Returns true if the specified column is sortable.This returns true if both the controller's sortable property and the column's sortable property is true. Returns false if any of them is false.
- Parameters:
column
- the column to check sorting for, in terms of the underlying model- Returns:
- true if the column is sortable
- Throws:
IndexOutOfBoundsException
- if column is outside the range of the underlying model- See Also:
-
setComparator
Sets theComparator
to use when sorting the specified column. This does not trigger a sort. If you want to sort after setting the comparator you need to explicitly invokesort
.- Parameters:
column
- the index of the column theComparator
is to be used for, in terms of the underlying modelcomparator
- theComparator
to use- Throws:
IndexOutOfBoundsException
- ifcolumn
is outside the range of the underlying model
-
getComparator
Returns theComparator
for the specified column. This will returnnull
if aComparator
has not been specified for the column.- 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
-
setSortOrderCycle
Sets the cycle of sort ordes to toggle through. Zero or more SortOrders which must not be null.- Parameters:
cycle
- the SortOrders to cycle through, may be empty- Throws:
NullPointerException
- if the array or any of its elements is null
-
getSortOrderCycle
SortOrder[] getSortOrderCycle()Returns the cycle of sort orders to cycle through.- Returns:
-
setSortsOnUpdates
void setSortsOnUpdates(boolean sortsOnUpdates) If true, specifies that a sort should happen when the underlying model is updated (rowsUpdated
is invoked). For example, if this is true and the user edits an entry the location of that item in the view may change. The default is true.- Parameters:
sortsOnUpdates
- whether or not to sort on update events
-
getSortsOnUpdates
boolean getSortsOnUpdates()Returns true if a sort should happen when the underlying model is updated; otherwise, returns false.- Returns:
- whether or not to sort when the model is updated
-
setStringValueProvider
Sets the StringValueProvider to look up the StringValues. If the value is not-null, it guarantees to use it exclusively for string conversion.PENDING JW: this is more or less parallel to TableStringConverter. Need to think about merging somehow.
- Parameters:
provider
- the look up for StringValues, may be null.
-
getStringValueProvider
StringValueProvider getStringValueProvider()Returns the StringValueProvider used to look up StringValues.- Returns:
- StringValueProvider used to look up StringValues, guaranteed to be not null.
-
toggleSortOrder
void toggleSortOrder(int column) Reverses the sort order of the specified column. The exact behaviour is up to implementations.Implementations must respect the per-controller and per-column-sortable property.
- Parameters:
column
- the model index of the column to toggle- See Also:
-
setSortOrder
Sets the sort order of the specified column.Implementations must respect the per-controller and per-column-sortable property.
- Parameters:
column
- the model index of the column to setsortOrder
- the SortOrder to set for the column- See Also:
-
getSortOrder
Returns the sort order of the specified column.- Returns:
- one of
SortOrder.ASCENDING
,SortOrder.DESCENDING
orSortOrder.UNSORTED
.
-
resetSortOrders
void resetSortOrders()Resets all interactive sorting.Implementations must respect the per-controller and per-column-sortable property.
-
setRowFilter
Sets the filter that determines which rows, if any, should be hidden from the view. The filter is applied before sorting. A value ofnull
indicates all values from the model should be included.RowFilter
'sinclude
method is passed anEntry
that wraps the underlying model. The number of columns in theEntry
corresponds to the number of columns in the underlying model. The identifier comes from the underlying model as well.This method triggers a sort. PENDING JW: the "underlying model" is the ModelWrapper ... want to expose here as well? Otherwise, the second paramter doesn't make much sense.
- Parameters:
filter
- the filter used to determine what entries should be included
-
getRowFilter
Returns the filter that determines which rows, if any, should be hidden from view.- Returns:
- the filter
-