|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.RowSorter<M>
javax.swing.DefaultRowSorter<M,Integer>
org.jdesktop.swingx.sort.DefaultSortController<M>
public abstract class DefaultSortController<M>
A default SortController implementation used as parent class for concrete SortControllers in SwingX.
Additionally, this implementation contains a fix for core Issue 6894632. It guarantees to only touch the underlying model during sort/filter and during processing the notification methods. This implies that the conversion and size query methods are valid at all times outside the internal updates, including the critical period (in core with undefined behaviour) after the underlying model has changed and before this sorter has been notified.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.DefaultRowSorter |
|---|
DefaultRowSorter.ModelWrapper<M,I> |
| Nested classes/interfaces inherited from class javax.swing.RowSorter |
|---|
RowSorter.SortKey |
| Field Summary | |
|---|---|
protected int |
cachedModelRowCount
|
static Comparator |
COMPARABLE_COMPARATOR
Comparator that uses compareTo on the contents. |
| Constructor Summary | |
|---|---|
DefaultSortController()
|
|
| Method Summary | |
|---|---|
void |
allRowsChanged()
Invoked when the contents of the underlying model have completely changed. |
int |
convertRowIndexToModel(int viewIndex)
Returns the location of index in terms of the
underlying model. |
int |
convertRowIndexToView(int modelIndex)
Returns the location of index in terms of the
view. |
static SortOrder[] |
getDefaultSortOrderCycle()
Returns the default cycle. |
int |
getModelRowCount()
Returns the number of rows in the underlying model. |
SortOrder |
getSortOrder(int column)
Returns the sort order of the specified column. |
SortOrder[] |
getSortOrderCycle()
Returns the cycle of sort orders to cycle through. |
StringValueProvider |
getStringValueProvider()
Returns the registry of string values. |
int |
getViewRowCount()
Returns the number of rows in the view. |
boolean |
isSortable()
Returns true if this controller is sortable; otherwise, false. |
boolean |
isSortable(int column)
Returns true if the specified column is sortable; otherwise, false. |
void |
modelStructureChanged()
Invoked when the underlying model structure has completely changed. |
void |
resetSortOrders()
Resets all interactive sorting. |
void |
rowsDeleted(int firstRow,
int endRow)
Invoked when rows have been deleted from the underlying model in the specified range (inclusive). |
void |
rowsInserted(int firstRow,
int endRow)
Invoked when rows have been inserted into the underlying model in the specified range (inclusive). |
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 |
setStringValueProvider(StringValueProvider registry)
Sets the registry of string values. |
void |
toggleSortOrder(int column)
Reverses the sort order from ascending to descending (or descending to ascending) if the specified column is already the primary sorted column; otherwise, makes the specified column the primary sorted column, with an ascending sort order. |
| Methods inherited from class javax.swing.DefaultRowSorter |
|---|
getComparator, getMaxSortKeys, getModel, getModelWrapper, getRowFilter, getSortKeys, getSortsOnUpdates, rowsUpdated, rowsUpdated, setComparator, setMaxSortKeys, setModelWrapper, setRowFilter, setSortKeys, setSortsOnUpdates, sort, useToString |
| 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 |
|---|
getComparator, getRowFilter, getSortsOnUpdates, setComparator, setRowFilter, setSortsOnUpdates |
| Field Detail |
|---|
public static final Comparator COMPARABLE_COMPARATOR
protected int cachedModelRowCount
| Constructor Detail |
|---|
public DefaultSortController()
| Method Detail |
|---|
public 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.
setSortable in interface SortController<M>sortable - whether or not this controller is sortableSortController.isSortable()public boolean isSortable()
isSortable in interface SortController<M>SortController.isSortable()
public void setSortable(int column,
boolean sortable)
toggleSortOrder is invoked.
It is still possible to sort on a column that has been marked as
unsortable by directly setting the sort keys. The default is
true.
setSortable in interface SortController<M>setSortable in class DefaultRowSorter<M,Integer>column - the column to enable or disable sorting on, in terms
of the underlying modelsortable - whether or not the specified column is sortableDefaultRowSorter.toggleSortOrder(int),
DefaultRowSorter.setSortKeys(java.util.List extends javax.swing.RowSorter.SortKey>)public boolean isSortable(int column)
isSortable in interface SortController<M>isSortable in class DefaultRowSorter<M,Integer>column - the column to check sorting for, in terms of the
underlying model
SortController.isSortable(int)public void toggleSortOrder(int column)
Overridden - that is completely new implementation - to get first/next SortOrder from sort order cycle. Does nothing if the cycle is empty.
toggleSortOrder in interface SortController<M>toggleSortOrder in class DefaultRowSorter<M,Integer>column - index of the column to make the primary sorted column,
in terms of the underlying modelDefaultRowSorter.setSortable(int,boolean),
DefaultRowSorter.setMaxSortKeys(int)
public void setSortOrder(int column,
SortOrder sortOrder)
Implementations must respect the per-controller and per-column-sortable property.
PENDING JW: toggle has two effects: makes the column the primary sort column, and cycle through. So here we something similar. Should we?
setSortOrder in interface SortController<M>column - the model index of the column to setsortOrder - the SortOrder to set for the columnSortController.isSortable(int),
SortController.isSortable()public SortOrder getSortOrder(int column)
getSortOrder in interface SortController<M>SortOrder.ASCENDING,
SortOrder.DESCENDING or SortOrder.UNSORTED.public void resetSortOrders()
Implementations must respect the per-controller and per-column-sortable property.
resetSortOrders in interface SortController<M>public SortOrder[] getSortOrderCycle()
getSortOrderCycle in interface SortController<M>public void setSortOrderCycle(SortOrder... cycle)
setSortOrderCycle in interface SortController<M>cycle - the SortOrders to cycle through, may be emptypublic void setStringValueProvider(StringValueProvider registry)
setStringValueProvider in interface SortController<M>registry - the registry to get StringValues for conversion.public StringValueProvider getStringValueProvider()
getStringValueProvider in interface SortController<M>public static SortOrder[] getDefaultSortOrderCycle()
public int convertRowIndexToModel(int viewIndex)
index in terms of the
underlying model. That is, for the row index in
the coordinates of the view this returns the row index in terms
of the underlying model.
Overridden to use check against getViewRowCount for validity.
convertRowIndexToModel in class DefaultRowSorter<M,Integer>viewIndex - the row index in terms of the underlying view
getViewRowCount()public int convertRowIndexToView(int modelIndex)
index in terms of the
view. That is, for the row index in the
coordinates of the underlying model this returns the row index
in terms of the view.
Overridden to use check against getModelRowCount for validity.
convertRowIndexToView in class DefaultRowSorter<M,Integer>modelIndex - the row index in terms of the underlying model
getModelRowCount()public int getModelRowCount()
Overridden to return the model row count which corresponds to the currently mapped model instead of accessing the model directly (as super does). This may differ from the "real" current model row count if the model has changed but this sorter not yet notified.
getModelRowCount in class DefaultRowSorter<M,Integer>RowSorter.getViewRowCount()public int getViewRowCount()
Overridden to return the model row count if no filters installed, otherwise return super.
getViewRowCount in class DefaultRowSorter<M,Integer>getModelRowCount()public void allRowsChanged()
javax.swing.DefaultRowSorterYou normally do not call this method. This method is public to allow view classes to call it.
allRowsChanged in class DefaultRowSorter<M,Integer>public void modelStructureChanged()
javax.swing.DefaultRowSorterTableModel changed, this method would be invoked.
You normally do not call this method. This method is public to allow view classes to call it.
modelStructureChanged in class DefaultRowSorter<M,Integer>
public void rowsDeleted(int firstRow,
int endRow)
javax.swing.DefaultRowSorterThe arguments give the indices of the effected range and are in terms of the model before the change. For example, if you have a 5-row model and delete 3 items from the end of the model the indices are 2, 4.
You normally do not call this method. This method is public to allow view classes to call it.
rowsDeleted in class DefaultRowSorter<M,Integer>firstRow - the first rowendRow - the last row
public void rowsInserted(int firstRow,
int endRow)
javax.swing.DefaultRowSorterThe arguments give the indices of the effected range. The first argument is in terms of the model before the change, and must be less than or equal to the size of the model before the change. The second argument is in terms of the model after the change and must be less than the size of the model after the change. For example, if you have a 5-row model and add 3 items to the end of the model the indices are 5, 7.
You normally do not call this method. This method is public to allow view classes to call it.
rowsInserted in class DefaultRowSorter<M,Integer>firstRow - the first rowendRow - the last row
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||