|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SortController
Defines the interactive sort control for a table. All sort gesture requests
from a JXTable
will be routed through the SortController returned
from FilterPipeline
.
To customize sorting behaviour, f.i. to define a toggle sort sequence
different from the default, subclass FilterPipeline
and implement a
custom SortController.
public class CustomToggleSortOrderFP extends FilterPipeline {
public CustomToggleSortOrderFP() {
super();
}
public CustomToggleSortOrderFP(Filter[] inList) {
super(inList);
}
//@Override
protected SortController createDefaultSortController() {
return new CustomSortController();
}
protected class CustomSortController extends SorterBasedSortController {
//@Override
public void toggleSortOrder(int column, Comparator comparator) {
Sorter currentSorter = getSorter();
if ((currentSorter != null)
&& (currentSorter.getColumnIndex() == column)
&& !currentSorter.isAscending()) {
setSorter(null);
} else {
super.toggleSortOrder(column, comparator);
}
}
}
}
// use it
xTable.setFilters(new CustomToggleSortOrderFP());
The GlazedLists project (http://publicobject.com/glazedlists/) has an example about how to replace the SwingX' internal (view based) by an external (model-decoration based) sort/filter mechanism.
This interface is inspired by a Java 1.6 class RowSorter, extracting the sort control part - change notification and index mapping is left to the enclosing FilterPipeline.
Method Summary | |
---|---|
List<? extends SortKey> |
getSortKeys()
List the sort order by column. |
SortOrder |
getSortOrder(int column)
Get the sort order of the specified column. |
void |
setSortKeys(List<? extends SortKey> keys)
Set the sort order by column. |
void |
toggleSortOrder(int column)
Reverses the sort order of the specified column. |
void |
toggleSortOrder(int column,
Comparator comparator)
Reverses the sort order of the specified column. |
Method Detail |
---|
void toggleSortOrder(int column)
column
- the model index of the column to togglevoid toggleSortOrder(int column, Comparator comparator)
column
- the model index of the column to togglecomparator
- the comparator to usevoid setSortKeys(List<? extends SortKey> keys)
List<? extends SortKey> getSortKeys()
SortOrder getSortOrder(int column)
SortOrder.ASCENDING
,
SortOrder.DESCENDING
or SortOrder.UNSORTED
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |