Class EventSelectionModel<E>
- java.lang.Object
-
- ca.odell.glazedlists.swing.EventSelectionModel<E>
-
- All Implemented Interfaces:
AdvancedListSelectionModel<E>
,javax.swing.ListSelectionModel
public final class EventSelectionModel<E> extends java.lang.Object implements AdvancedListSelectionModel<E>
Deprecated.UseDefaultEventSelectionModel
instead. This class will be removed in the GL 2.0 release. The wrapping of the source list with an EDT safe list has been determined to be undesirable (it is better for the user to provide their own EDT safe list).AnEventSelectionModel
is a class that performs two simulaneous services. It is aListSelectionModel
to provide selection tracking for aJTable
. It is also aEventList
that contains the table's selection.As elements are selected or deselected, the
EventList
aspect of thisEventSelectionModel
changes. Changes to thatList
will change the sourceEventList
. To modify only the selection, use theListSelectionModel
's methods.Alongside
MULTIPLE_INTERVAL_SELECTION
, thisListSelectionModel
supports an additional selection mode.MULTIPLE_INTERVAL_SELECTION_DEFENSIVE
is a new selection mode. It is identical toMULTIPLE_INTERVAL_SELECTION
in every way but one. When a row is inserted immediately before a selected row in theMULTIPLE_INTERVAL_SELECTION
mode, it becomes selected. But in theMULTIPLE_INTERVAL_SELECTION_DEFENSIVE
mode, it does not become selected. To set this mode, usesetSelectionMode(ListSelection.MULTIPLE_INTERVAL_SELECTION_DEFENSIVE)
.
-
-
Field Summary
Fields Modifier and Type Field Description protected TransformedList<E,E>
swingThreadSource
Deprecated.the proxy moves events to the Swing Event Dispatch thread
-
Constructor Summary
Constructors Constructor Description EventSelectionModel(EventList<E> source)
Deprecated.Creates a new selection model that also presents a list of the selection.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addListSelectionListener(javax.swing.event.ListSelectionListener listener)
Deprecated.Add a listener to the list that's notified each time a change to the selection occurs.void
addSelectionInterval(int index0, int index1)
Deprecated.Change the selection to be the set union of the current selection and the indices between index0 and index1 inclusivevoid
addValidSelectionMatcher(Matcher<E> validSelectionMatcher)
Deprecated.Add a matcher which decides when source elements are valid for selection.void
clearSelection()
Deprecated.Change the selection to the empty set.void
dispose()
Deprecated.Releases the resources consumed by thisEventSelectionModel
so that it may eventually be garbage collected.int
getAnchorSelectionIndex()
Deprecated.Return the first index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().EventList<E>
getDeselected()
Deprecated.Gets anEventList
that contains only deselected values and modifies the source list on mutation.boolean
getEnabled()
Deprecated.Returns whether the EventSelectionModel is editable or not.EventList<E>
getEventList()
Deprecated.As of 2005/02/18, the naming of this method became ambiguous.int
getLeadSelectionIndex()
Deprecated.Return the second index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().javax.swing.ListSelectionModel
getListSelectionModel()
Deprecated.As of 2004/11/26, theEventSelectionModel
implementsListSelectionModel
directly.int
getMaxSelectionIndex()
Deprecated.Gets the index of the last selected element.int
getMinSelectionIndex()
Deprecated.Gets the index of the first selected element.EventList<E>
getSelected()
Deprecated.Gets anEventList
that contains only selected values and modifies the source list on mutation.int
getSelectionMode()
Deprecated.Returns the current selection mode.EventList<E>
getTogglingDeselected()
Deprecated.Gets anEventList
that contains only deselected values and modifies the selection state on mutation.EventList<E>
getTogglingSelected()
Deprecated.Gets anEventList
that contains only selected values and modifies the selection state on mutation.boolean
getValueIsAdjusting()
Deprecated.Returns true if the value is undergoing a series of changes.void
insertIndexInterval(int index, int length, boolean before)
Deprecated.Insert length indices beginning before/after index.void
invertSelection()
Deprecated.Inverts the current selection.boolean
isSelectedIndex(int index)
Deprecated.Returns true if the specified index is selected.boolean
isSelectionEmpty()
Deprecated.Returns true if no indices are selected.void
removeIndexInterval(int index0, int index1)
Deprecated.Remove the indices in the interval index0,index1 (inclusive) from the selection model.void
removeListSelectionListener(javax.swing.event.ListSelectionListener listener)
Deprecated.Remove a listener from the list that's notified each time a change to the selection occurs.void
removeSelectionInterval(int index0, int index1)
Deprecated.Change the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive.void
removeValidSelectionMatcher(Matcher<E> validSelectionMatcher)
Deprecated.Remove a matcher which decides when source elements are valid for selection.void
setAnchorSelectionIndex(int anchorSelectionIndex)
Deprecated.Set the anchor selection index.void
setEnabled(boolean enabled)
Deprecated.Set the EventSelectionModel as editable or not.void
setLeadSelectionIndex(int leadSelectionIndex)
Deprecated.Set the lead selection index.void
setSelectionInterval(int index0, int index1)
Deprecated.Change the selection to be between index0 and index1 inclusive.void
setSelectionMode(int selectionMode)
Deprecated.Set the selection mode.void
setValueIsAdjusting(boolean valueIsAdjusting)
Deprecated.This property is true if upcoming changes to the value of the model should be considered a single event.java.lang.String
toString()
Deprecated.
-
-
-
Field Detail
-
swingThreadSource
protected TransformedList<E,E> swingThreadSource
Deprecated.the proxy moves events to the Swing Event Dispatch thread
-
-
Constructor Detail
-
EventSelectionModel
public EventSelectionModel(EventList<E> source)
Deprecated.Creates a new selection model that also presents a list of the selection. TheEventSelectionModel
listens to thisEventList
in order to adjust selection when theEventList
is modified. For example, when an element is added to theEventList
, this may offset the selection of the following elements.- Parameters:
source
- theEventList
whose selection will be managed. This should be the sameEventList
passed to the constructor of yourEventTableModel
orEventListModel
.
-
-
Method Detail
-
addListSelectionListener
public void addListSelectionListener(javax.swing.event.ListSelectionListener listener)
Deprecated.Add a listener to the list that's notified each time a change to the selection occurs. Note that the change events fired by this class may include rows that have been removed from the table. For this reason it is advised not tofor()
through the changed range without also verifying that each row is still in the table.- Specified by:
addListSelectionListener
in interfacejavax.swing.ListSelectionModel
-
addSelectionInterval
public void addSelectionInterval(int index0, int index1)
Deprecated.Change the selection to be the set union of the current selection and the indices between index0 and index1 inclusive- Specified by:
addSelectionInterval
in interfacejavax.swing.ListSelectionModel
-
addValidSelectionMatcher
public void addValidSelectionMatcher(Matcher<E> validSelectionMatcher)
Deprecated.Add a matcher which decides when source elements are valid for selection.- Specified by:
addValidSelectionMatcher
in interfaceAdvancedListSelectionModel<E>
- Parameters:
validSelectionMatcher
- returns true if a source element can be selected; false otherwise
-
clearSelection
public void clearSelection()
Deprecated.Change the selection to the empty set.- Specified by:
clearSelection
in interfacejavax.swing.ListSelectionModel
-
dispose
public void dispose()
Deprecated.Releases the resources consumed by thisEventSelectionModel
so that it may eventually be garbage collected.An
EventSelectionModel
will be garbage collected without a call todispose()
, but not before its sourceEventList
is garbage collected. By callingdispose()
, you allow theEventSelectionModel
to be garbage collected before its sourceEventList
. This is necessary for situations where anEventSelectionModel
is short-lived but its sourceEventList
is long-lived.Warning: It is an error to call any method on a
EventSelectionModel
after it has been disposed.- Specified by:
dispose
in interfaceAdvancedListSelectionModel<E>
-
getAnchorSelectionIndex
public int getAnchorSelectionIndex()
Deprecated.Return the first index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().- Specified by:
getAnchorSelectionIndex
in interfacejavax.swing.ListSelectionModel
-
getDeselected
public EventList<E> getDeselected()
Deprecated.Gets anEventList
that contains only deselected values and modifies the source list on mutation. Adding and removing items from this list performs the same operation on the source list.- Specified by:
getDeselected
in interfaceAdvancedListSelectionModel<E>
-
getEnabled
public boolean getEnabled()
Deprecated.Returns whether the EventSelectionModel is editable or not.- Specified by:
getEnabled
in interfaceAdvancedListSelectionModel<E>
-
getEventList
public EventList<E> getEventList()
Deprecated.As of 2005/02/18, the naming of this method became ambiguous. Please usegetSelected()
.Gets the event list that always contains the current selection.
-
getLeadSelectionIndex
public int getLeadSelectionIndex()
Deprecated.Return the second index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().- Specified by:
getLeadSelectionIndex
in interfacejavax.swing.ListSelectionModel
-
getListSelectionModel
public javax.swing.ListSelectionModel getListSelectionModel()
Deprecated.As of 2004/11/26, theEventSelectionModel
implementsListSelectionModel
directly.Gets the selection model that provides selection management for a table.
-
getMaxSelectionIndex
public int getMaxSelectionIndex()
Deprecated.Gets the index of the last selected element.- Specified by:
getMaxSelectionIndex
in interfacejavax.swing.ListSelectionModel
-
getMinSelectionIndex
public int getMinSelectionIndex()
Deprecated.Gets the index of the first selected element.- Specified by:
getMinSelectionIndex
in interfacejavax.swing.ListSelectionModel
-
getSelected
public EventList<E> getSelected()
Deprecated.Gets anEventList
that contains only selected values and modifies the source list on mutation. Adding and removing items from this list performs the same operation on the source list.- Specified by:
getSelected
in interfaceAdvancedListSelectionModel<E>
-
getSelectionMode
public int getSelectionMode()
Deprecated.Returns the current selection mode.- Specified by:
getSelectionMode
in interfacejavax.swing.ListSelectionModel
-
getTogglingDeselected
public EventList<E> getTogglingDeselected()
Deprecated.Gets anEventList
that contains only deselected values and modifies the selection state on mutation. Adding an item to this list deselects it and removing an item selects it. If an item not in the source list is added anIllegalArgumentException
is thrown- Specified by:
getTogglingDeselected
in interfaceAdvancedListSelectionModel<E>
-
getTogglingSelected
public EventList<E> getTogglingSelected()
Deprecated.Gets anEventList
that contains only selected values and modifies the selection state on mutation. Adding an item to this list selects it and removing an item deselects it. If an item not in the source list is added anIllegalArgumentException
is thrown.- Specified by:
getTogglingSelected
in interfaceAdvancedListSelectionModel<E>
-
getValueIsAdjusting
public boolean getValueIsAdjusting()
Deprecated.Returns true if the value is undergoing a series of changes.- Specified by:
getValueIsAdjusting
in interfacejavax.swing.ListSelectionModel
-
insertIndexInterval
public void insertIndexInterval(int index, int length, boolean before)
Deprecated.Insert length indices beginning before/after index.- Specified by:
insertIndexInterval
in interfacejavax.swing.ListSelectionModel
-
invertSelection
public void invertSelection()
Deprecated.Inverts the current selection.- Specified by:
invertSelection
in interfaceAdvancedListSelectionModel<E>
-
isSelectedIndex
public boolean isSelectedIndex(int index)
Deprecated.Returns true if the specified index is selected. If the specified index has not been seen before, this will return false. This is in the case where the table painting and selection have fallen out of sync. Usually in this case there is an update event waiting in the event queue that notifies this model of the change in table size.- Specified by:
isSelectedIndex
in interfacejavax.swing.ListSelectionModel
-
isSelectionEmpty
public boolean isSelectionEmpty()
Deprecated.Returns true if no indices are selected.- Specified by:
isSelectionEmpty
in interfacejavax.swing.ListSelectionModel
-
removeIndexInterval
public void removeIndexInterval(int index0, int index1)
Deprecated.Remove the indices in the interval index0,index1 (inclusive) from the selection model.- Specified by:
removeIndexInterval
in interfacejavax.swing.ListSelectionModel
-
removeListSelectionListener
public void removeListSelectionListener(javax.swing.event.ListSelectionListener listener)
Deprecated.Remove a listener from the list that's notified each time a change to the selection occurs.- Specified by:
removeListSelectionListener
in interfacejavax.swing.ListSelectionModel
-
removeSelectionInterval
public void removeSelectionInterval(int index0, int index1)
Deprecated.Change the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive.- Specified by:
removeSelectionInterval
in interfacejavax.swing.ListSelectionModel
-
removeValidSelectionMatcher
public void removeValidSelectionMatcher(Matcher<E> validSelectionMatcher)
Deprecated.Remove a matcher which decides when source elements are valid for selection.- Specified by:
removeValidSelectionMatcher
in interfaceAdvancedListSelectionModel<E>
- Parameters:
validSelectionMatcher
- returns true if a source element can be selected; false otherwise
-
setAnchorSelectionIndex
public void setAnchorSelectionIndex(int anchorSelectionIndex)
Deprecated.Set the anchor selection index.- Specified by:
setAnchorSelectionIndex
in interfacejavax.swing.ListSelectionModel
-
setEnabled
public void setEnabled(boolean enabled)
Deprecated.Set the EventSelectionModel as editable or not. This means that the user cannot manipulate the selection by clicking. The selection can still be changed as the source list changes.Note that this will also disable the selection from being modified programatically. Therefore you must use setEnabled(true) to modify the selection in code.
- Specified by:
setEnabled
in interfaceAdvancedListSelectionModel<E>
-
setLeadSelectionIndex
public void setLeadSelectionIndex(int leadSelectionIndex)
Deprecated.Set the lead selection index.- Specified by:
setLeadSelectionIndex
in interfacejavax.swing.ListSelectionModel
-
setSelectionInterval
public void setSelectionInterval(int index0, int index1)
Deprecated.Change the selection to be between index0 and index1 inclusive.First this calculates the smallest range where changes occur. This includes the union of the selection range before and the selection range specified. It then walks through the change and sets each index as selected or not based on whether the index is in the new range. Finally it fires events to both the listening lists and selection listeners about what changes happened.
If the selection does not change, this will not fire any events.
- Specified by:
setSelectionInterval
in interfacejavax.swing.ListSelectionModel
-
setSelectionMode
public void setSelectionMode(int selectionMode)
Deprecated.Set the selection mode.- Specified by:
setSelectionMode
in interfacejavax.swing.ListSelectionModel
-
setValueIsAdjusting
public void setValueIsAdjusting(boolean valueIsAdjusting)
Deprecated.This property is true if upcoming changes to the value of the model should be considered a single event.- Specified by:
setValueIsAdjusting
in interfacejavax.swing.ListSelectionModel
-
toString
public java.lang.String toString()
Deprecated.- Overrides:
toString
in classjava.lang.Object
-
-