|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.DefaultListSelectionModel
com.jgoodies.binding.internal.TableRowSorterListSelectionModel
public final class TableRowSorterListSelectionModel
A ListSelectionModel for a sorted table that is synchronized with another delegate ListSelectionModel and converts its unsorted indices to the sorted indices provided by the table's row sorter.
If a JTable has a RowSorter, the indices in the table's ListSelectionModel reflect the table's sort state. In other words, sorting modifies the selection indices. This makes it difficult to share ListSelectionModels for multiple JLists/JTables - which is a fundamental feature of the Presentation Model pattern. For example, if the first row is selected in unsorted state, the ListSelectionModel has a minSelectionIndex of 0. Accessing a ListModel or TableModel at row index 0 will get you the first row. Let's say you sort the table and the first row is now displayed as the third row, then the ListSelectionModel gets a minSelectionIndex of 2.
This class is used to keep an unsorted ListSelectionModel (typically provided by a presentation model) in synch with the sorted indices of the table's sorted ListSelectionModel.
Instances of this class are automatically created when using
Bindings.bind(JTable, javax.swing.ListModel, ListSelectionModel)
on a sorted table.
Field Summary |
---|
Fields inherited from class javax.swing.DefaultListSelectionModel |
---|
leadAnchorNotificationEnabled, listenerList |
Fields inherited from interface javax.swing.ListSelectionModel |
---|
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION |
Constructor Summary | |
---|---|
TableRowSorterListSelectionModel(ListSelectionModel listSelectionModel,
JTable table)
|
Method Summary | |
---|---|
void |
addSelectionInterval(int index0,
int index1)
Changes the selection to be the set union of the current selection and the indices between index0 and index1 inclusive. |
void |
clearSelection()
Change the selection to the empty set. |
int |
getSelectionMode()
Returns the current selection mode. |
void |
insertIndexInterval(int index,
int length,
boolean before)
Insert length indices beginning before/after index. |
void |
removeIndexInterval(int index0,
int index1)
Remove the indices in the interval index0,index1 (inclusive) from the selection model. |
void |
removeSelectionInterval(int index0,
int index1)
Changes the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive. |
void |
setSelectionInterval(int index0,
int index1)
Changes the selection to be between index0 and index1
inclusive. |
void |
setSelectionMode(int selectionMode)
Sets the selection mode. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TableRowSorterListSelectionModel(ListSelectionModel listSelectionModel, JTable table)
Method Detail |
---|
public void setSelectionInterval(int index0, int index1)
index0
and index1
inclusive. index0
doesn't have to be less than or equal to
index1
.
In SINGLE_SELECTION
selection mode, only the second index
is used.
If this represents a change to the current selection, then each
ListSelectionListener
is notified of the change.
setSelectionInterval
in interface ListSelectionModel
setSelectionInterval
in class DefaultListSelectionModel
index0
- one end of the interval.index1
- other end of the intervalDefaultListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public void addSelectionInterval(int index0, int index1)
index0
and index1
inclusive.
index0
doesn't have to be less than or equal to index1
.
In SINGLE_SELECTION
selection mode, this is equivalent
to calling setSelectionInterval
, and only the second index
is used. In SINGLE_INTERVAL_SELECTION
selection mode, this
method behaves like setSelectionInterval
, unless the given
interval is immediately adjacent to or overlaps the existing selection,
and can therefore be used to grow the selection.
If this represents a change to the current selection, then each
ListSelectionListener
is notified of the change.
addSelectionInterval
in interface ListSelectionModel
addSelectionInterval
in class DefaultListSelectionModel
index0
- one end of the interval.index1
- other end of the intervalDefaultListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
,
setSelectionInterval(int, int)
public void removeSelectionInterval(int index0, int index1)
index0
and index1
inclusive.
index0
doesn't have to be less than or equal to index1
.
In SINGLE_INTERVAL_SELECTION
selection mode, if the removal
would produce two disjoint selections, the removal is extended through
the greater end of the selection. For example, if the selection is
0-10
and you supply indices 5,6
(in any order) the
resulting selection is 0-4
.
If this represents a change to the current selection, then each
ListSelectionListener
is notified of the change.
removeSelectionInterval
in interface ListSelectionModel
removeSelectionInterval
in class DefaultListSelectionModel
index0
- one end of the interval.index1
- other end of the intervalDefaultListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public void clearSelection()
clearSelection
in interface ListSelectionModel
clearSelection
in class DefaultListSelectionModel
DefaultListSelectionModel.addListSelectionListener(javax.swing.event.ListSelectionListener)
public void insertIndexInterval(int index, int length, boolean before)
insertIndexInterval
in interface ListSelectionModel
insertIndexInterval
in class DefaultListSelectionModel
public void removeIndexInterval(int index0, int index1)
removeIndexInterval
in interface ListSelectionModel
removeIndexInterval
in class DefaultListSelectionModel
public void setSelectionMode(int selectionMode)
ListSelectionModel.SINGLE_SELECTION
-
Only one list index can be selected at a time. In this mode,
setSelectionInterval
and addSelectionInterval
are
equivalent, both replacing the current selection with the index
represented by the second argument (the "lead").
ListSelectionModel.SINGLE_INTERVAL_SELECTION
-
Only one contiguous interval can be selected at a time.
In this mode, addSelectionInterval
behaves like
setSelectionInterval
(replacing the current selection),
unless the given interval is immediately adjacent to or overlaps
the existing selection, and can therefore be used to grow it.
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
-
In this mode, there's no restriction on what can be selected.
setSelectionMode
in interface ListSelectionModel
setSelectionMode
in class DefaultListSelectionModel
IllegalArgumentException
- if the selection mode isn't
one of those allowedgetSelectionMode()
public int getSelectionMode()
getSelectionMode
in interface ListSelectionModel
getSelectionMode
in class DefaultListSelectionModel
setSelectionMode(int)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |