public interface SortController<M>
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
Modifier and Type | Method and Description |
---|---|
Comparator<?> |
getComparator(int column)
Returns the
Comparator for the specified
column. |
RowFilter<? super M,? super Integer> |
getRowFilter()
Returns the filter that determines which rows, if any, should
be hidden from view.
|
SortOrder |
getSortOrder(int column)
Returns the sort order of the specified column.
|
SortOrder[] |
getSortOrderCycle()
Returns the cycle of sort orders to cycle through.
|
boolean |
getSortsOnUpdates()
Returns true if a sort should happen when the underlying
model is updated; otherwise, returns false.
|
StringValueProvider |
getStringValueProvider()
Returns the StringValueProvider used to look up StringValues.
|
boolean |
isSortable()
Returns true if this controller is sortable; otherwise, false.
|
boolean |
isSortable(int column)
Returns true if the specified column is sortable.
|
void |
resetSortOrders()
Resets all interactive sorting.
|
void |
setComparator(int column,
Comparator<?> comparator)
Sets the
Comparator 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.
|
void setSortable(boolean sortable)
The default is true.
PENDING JW: define behaviour if sortable is disabled while has sortOrders. In this case JXTable resets all sorts.
sortable
- whether or not this controller is sortableisSortable()
boolean isSortable()
isSortable()
void setSortable(int column, boolean 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.
column
- the column to enable or disable sorting on, in terms
of the underlying modelsortable
- whether or not the specified column is sortableIndexOutOfBoundsException
- if column
is outside
the range of the modelisSortable(int)
,
toggleSortOrder(int)
,
setSortOrder(int, SortOrder)
boolean isSortable(int column)
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.
column
- the column to check sorting for, in terms of the
underlying modelIndexOutOfBoundsException
- if column is outside
the range of the underlying modelisSortable(int)
void setComparator(int column, Comparator<?> comparator)
Comparator
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 invoke sort
.column
- the index of the column the Comparator
is
to be used for, in terms of the underlying modelcomparator
- the Comparator
to useIndexOutOfBoundsException
- if column
is outside
the range of the underlying modelComparator<?> getComparator(int column)
Comparator
for the specified
column. This will return null
if a Comparator
has not been specified for the column.column
- the column to fetch the Comparator
for, in
terms of the underlying modelComparator
for the specified columnIndexOutOfBoundsException
- if column is outside
the range of the underlying modelvoid setSortOrderCycle(SortOrder... cycle)
cycle
- the SortOrders to cycle through, may be emptyNullPointerException
- if the array or any of its elements is nullSortOrder[] getSortOrderCycle()
void setSortsOnUpdates(boolean sortsOnUpdates)
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.sortsOnUpdates
- whether or not to sort on update eventsboolean getSortsOnUpdates()
void setStringValueProvider(StringValueProvider provider)
PENDING JW: this is more or less parallel to TableStringConverter. Need to think about merging somehow.
provider
- the look up for StringValues, may be null.StringValueProvider getStringValueProvider()
void toggleSortOrder(int column)
Implementations must respect the per-controller and per-column-sortable property.
column
- the model index of the column to toggleisSortable(int)
,
isSortable()
void setSortOrder(int column, SortOrder sortOrder)
Implementations must respect the per-controller and per-column-sortable property.
column
- the model index of the column to setsortOrder
- the SortOrder to set for the columnisSortable(int)
,
isSortable()
SortOrder getSortOrder(int column)
SortOrder.ASCENDING
,
SortOrder.DESCENDING
or SortOrder.UNSORTED
.void resetSortOrders()
Implementations must respect the per-controller and per-column-sortable property.
void setRowFilter(RowFilter<? super M,? super Integer> filter)
null
indicates all values from the model should be
included.
RowFilter
's include
method is passed an
Entry
that wraps the underlying model. The number
of columns in the Entry
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.
filter
- the filter used to determine what entries should be
includedRowFilter<? super M,? super Integer> getRowFilter()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses