ca.odell.glazedlists.swing
Class TableComparatorChooser<E>
public class TableComparatorChooser<E>
A TableComparatorChooser is a tool that allows the user to sort a ListTable by clicking
on the table's headers. It requires that the
JTable
s model is an
EventTableModel
with a
SortedList
as a source.
This class includes custom arrow icons that indicate the sort
order. The icons used are chosen based on the current Swing look and feel.
Icons are available for the following look and feels: Mac OS X, Metal, Windows.
This class supports multiple sort strategies for each
column, specified by having muliple comparators for each column. This may
be useful when you want to sort a single column in either of two ways. For
example, when sorting movie names, "The Phantom Menace" may be sorted under
"T" for "The", or "P" for "Phantom".
This class supports sorting multiple columns simultaneously.
In this mode, the user clicks a first column to sort by, and then the user
clicks subsequent columns. The list is sorted by the first column and ties
are broken by the second column.
If the
EventTableModel
uses a
AdvancedTableFormat
, its
AdvancedTableFormat.getColumnComparator(int)
method will be used to
populate the initial column
Comparator
s.
TableComparatorChooser(JTable table, SortedList sortedList, Object strategy) - Creates a new TableComparatorChooser that responds to clicks
on the specified table and uses them to sort the specified list by
delegating to the given
strategy .
|
TableComparatorChooser(JTable table, SortedList sortedList, boolean multipleColumnSort) - Creates a new TableComparatorChooser that responds to clicks
on the specified table and uses them to sort the specified list.
|
appendComparator , clearComparator , createComparatorForElement , dispose , fromString , getColumnComparatorIndex , getComparatorsForColumn , getSortingColumns , getSortingStyle , isColumnReverse , rebuildComparator , redetectComparator , setTableFormat , toString |
TableComparatorChooser
public TableComparatorChooser(JTable table,
SortedList sortedList,
Object strategy)
Creates a new TableComparatorChooser that responds to clicks
on the specified table and uses them to sort the specified list by
delegating to the given strategy
.
table
- the table with headers that can be clicked onsortedList
- the sorted list to updatestrategy
- an implementations of SortingStrategy
, typically one of
TableComparatorChooser
public TableComparatorChooser(JTable table,
SortedList sortedList,
boolean multipleColumnSort)
Creates a new TableComparatorChooser that responds to clicks
on the specified table and uses them to sort the specified list.
table
- the table with headers that can be clicked onsortedList
- the sorted list to updatemultipleColumnSort
- true
to sort by multiple columns
at a time, or false
to sort by a single column. Although
sorting by multiple columns is more powerful, the user interface is
not as simple and this strategy should only be used where necessary.
addSortActionListener
public void addSortActionListener(ActionListener sortActionListener)
Registers the specified
ActionListener
to receive notification whenever
the
JTable
is sorted by this
TableComparatorChooser
.
isSortingMouseEvent
protected boolean isSortingMouseEvent(MouseEvent e)
Determines if the specified mouse event shall be handled by this
TableComparatorChooser
. The default implementation handles only clicks
with the left mouse button. Extending classes can customize which mouse
events the table comparator chooser responds to by overriding this method.
As of 2005/12/20, that this method is no longer called when the
corresponding mouse press event was a popup trigger. In effect, if this
is a right-click on Windows or a 'control-click' on the Mac.
redetectComparator
protected void redetectComparator(E> currentComparator)
Examines the current
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
ColumnClickTracker
s.
- redetectComparator in interface AbstractTableComparatorChooser<E>
removeSortActionListener
public void removeSortActionListener(ActionListener sortActionListener)
Deregisters the specified ActionListener
to no longer receive
action events.
setIconPath
public static void setIconPath(String path)
Set all
TableComparatorChooser
s to use the icons from the directory
specified. The folder should contain the following eight icon files:
primary_sorted.png secondary_sorted.png
primary_sorted_alternate.png secondary_sorted_alternate.png
primary_sorted_alternate_reverse.png secondary_sorted_alternate_reverse.png
primary_sorted_reverse.png secondary_sorted_reverse.png
Note that this path must be on the system classpath. It may be within a
jar file.
Glazed Lists, Copyright © 2003-2006 publicobject.com, O'Dell Engineering.
Documentation build by pbuilder at 2007-12-21 23:49