|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.odell.glazedlists.gui.AbstractTableComparatorChooser
public abstract class AbstractTableComparatorChooser
A TableComparatorChooser is a tool that allows the user to sort a table widget by clicking on the table's headers. It requires that the table has a SortedList as a source as the sorting on that list is used.
| Field Summary | |
|---|---|
protected static int |
COLUMN_PRIMARY_SORTED
|
protected static int |
COLUMN_PRIMARY_SORTED_ALTERNATE
|
protected static int |
COLUMN_PRIMARY_SORTED_ALTERNATE_REVERSE
|
protected static int |
COLUMN_PRIMARY_SORTED_REVERSE
|
protected static int |
COLUMN_SECONDARY_SORTED
|
protected static int |
COLUMN_SECONDARY_SORTED_ALTERNATE
|
protected static int |
COLUMN_SECONDARY_SORTED_ALTERNATE_REVERSE
|
protected static int |
COLUMN_SECONDARY_SORTED_REVERSE
|
protected static int |
COLUMN_UNSORTED
the sorting style on a column is used for icon choosing |
protected ca.odell.glazedlists.gui.AbstractTableComparatorChooser.ColumnClickTracker[] |
columnClickTrackers
the columns and their click counts |
protected boolean |
multipleColumnSort
whether to support sorting on single or multiple columns |
protected int |
primaryColumn
the first comparator in the comparator chain |
protected ArrayList |
recentlyClickedColumns
an array that contains all columns with non-zero click counts |
protected SortedList |
sortedList
the sorted list to choose the comparators for |
protected Comparator |
sortedListComparator
the potentially foreign comparator associated with the sorted list |
protected TableFormat |
tableFormat
the columns to sort over |
| Constructor Summary | |
|---|---|
protected |
AbstractTableComparatorChooser(SortedList sortedList,
TableFormat tableFormat,
boolean multipleColumnSort)
Create a AbstractTableComparatorChooser that sorts the specified
SortedList over the specified columns. |
| Method Summary | |
|---|---|
void |
appendComparator(int column,
int comparatorIndex,
boolean reverse)
Append the comparator specified by the column, comparator index and reverse parameters to the end of the sequence of comparators this AbstractTableComparatorChooser is sorting the SortedList
by. |
void |
clearComparator()
Clear all sorting state and set the SortedList to use its
natural order. |
protected void |
columnClicked(int column,
int clicks)
Handle a column being clicked by sorting that column. |
Comparator |
createComparatorForElement(Comparator comparatorForColumn,
int column)
Creates a Comparator that can compare list elements
given a Comparator that can compare column values for the specified
column. |
void |
dispose()
|
void |
fromString(String stringEncoded)
This class is capable of representing its own state with a String, to persist sorting state externally. |
int |
getColumnComparatorIndex(int column)
Gets the index comparator in use for the specified column. |
List |
getComparatorsForColumn(int column)
Gets the list of comparators for the specified column. |
List |
getSortingColumns()
Get the columns that the TableComparatorChooser is sorting by. |
protected int |
getSortingStyle(int column)
Gets the sorting style currently applied to the specified column. |
boolean |
isColumnReverse(int column)
Gets whether the comparator in use for the specified column is reverse. |
protected void |
rebuildColumns()
When the column model is changed, this resets the column clicks and comparator list for each column. |
protected void |
rebuildComparator()
Updates the comparator in use and applies it to the table. |
protected void |
redetectComparator(Comparator currentComparator)
Examines the current Comparator of the SortedList and
adds icons to the table header renderers in response. |
protected void |
setTableFormat(TableFormat tableFormat)
Adjusts the TableFormat this comparator chooser uses when selecting comparators. |
String |
toString()
Encode the current sorting state as a String. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected SortedList sortedList
protected TableFormat tableFormat
protected Comparator sortedListComparator
protected ca.odell.glazedlists.gui.AbstractTableComparatorChooser.ColumnClickTracker[] columnClickTrackers
protected int primaryColumn
protected ArrayList recentlyClickedColumns
protected boolean multipleColumnSort
protected static final int COLUMN_UNSORTED
protected static final int COLUMN_PRIMARY_SORTED
protected static final int COLUMN_PRIMARY_SORTED_REVERSE
protected static final int COLUMN_PRIMARY_SORTED_ALTERNATE
protected static final int COLUMN_PRIMARY_SORTED_ALTERNATE_REVERSE
protected static final int COLUMN_SECONDARY_SORTED
protected static final int COLUMN_SECONDARY_SORTED_REVERSE
protected static final int COLUMN_SECONDARY_SORTED_ALTERNATE
protected static final int COLUMN_SECONDARY_SORTED_ALTERNATE_REVERSE
| Constructor Detail |
|---|
protected AbstractTableComparatorChooser(SortedList sortedList,
TableFormat tableFormat,
boolean multipleColumnSort)
AbstractTableComparatorChooser that sorts the specified
SortedList over the specified columns.
| Method Detail |
|---|
protected void setTableFormat(TableFormat tableFormat)
protected void rebuildColumns()
public List getComparatorsForColumn(int column)
public List getSortingColumns()
public int getColumnComparatorIndex(int column)
getComparatorsForColumn(int).
public boolean isColumnReverse(int column)
public void appendComparator(int column,
int comparatorIndex,
boolean reverse)
AbstractTableComparatorChooser is sorting the SortedList
by.
Append implies that if this AbstractTableComparatorChooser
is already sorting that list by another column, this comparator will only
be used to break ties from that Comparator. If the table is already
sorting by the specified column, it will be silently discarded.
Suppose we're currently not sorting the table, this method will cause the table to be sorted by the column specified. If we are sorting the table by some column c, this will sort by that column first and the column specified here second.
If this AbstractTableComparatorChooser doesn't support multiple
column sort, this will replace the current Comparator rather than
appending to it.
column - the column to sort bycomparatorIndex - the comparator to use, specify 0 for the
default comparator.reverse - whether to reverse the specified comparator.public void clearComparator()
SortedList to use its
natural order.
protected void columnClicked(int column,
int clicks)
protected void rebuildComparator()
protected void redetectComparator(Comparator currentComparator)
Comparator of the SortedList and
adds icons to the table header renderers in response.
To do this, clicks are injected into each of the
corresponding ColumnClickTrackers.
protected int getSortingStyle(int column)
public Comparator createComparatorForElement(Comparator comparatorForColumn,
int column)
Comparator that can compare list elements
given a Comparator that can compare column values for the specified
column. This returns a Comparator that extracts the table values for
the specified column and then delegates the actual comparison to the specified
comparator.
public String toString()
String. This specially formatted
String is ideal for persistence using any preferences API. The
state of this AbstractTableComparatorChooser can be restored
by passing the return value of this method to fromString(String).
toString in class Objectpublic void fromString(String stringEncoded)
This class is capable of representing its own state with a String, to persist sorting state externally. The format uses zero or more column specifications, separated by commas. Here are some valid examples:
| String Representation | Description |
|---|---|
"column 3" | Sort using the column at index 3, using that column's first comparator, in forward order |
"column 3 reversed" | Sort using the column at index 3, using that column's first comparator, in reverse order |
"column 3, column 1" | Sort using the column at index 3, using that column's first comparator, in forward order then by the column at index 1, using that column's first comparator, in forward order. |
"column 3 comparator 2" | Sort using the column at index 3, using that column's comparator at index 2, in forward order |
"column 3 comparator 2 reversed" | Sort using the column at index 3, using that column's comparator at index 2, in reverse order |
"column 3 reversed, column 1 comparator 2, column 5 comparator 1 reversed, column 0" | Sort using the column at index 3, using that column's first comparator, in reverse order then by the column at index 1, using that column's comparator at index 2, in forward order then by the column at index 5, using that column's comparator at index 1, in reverse order then by the column at index 0, using that column's first comparator, in forward order. |
More formally, the grammar for this String representation is as follows:
<COLUMN> = column <COLUMN INDEX> (reversed)? (comparator <COMPARATOR INDEX>)?
<COMPARATOR SPEC> = ( <COLUMN> (, <COLUMN>)* )?
public void dispose()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||