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.UseDefaultEventSelectionModelinstead. 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).AnEventSelectionModelis a class that performs two simulaneous services. It is aListSelectionModelto provide selection tracking for aJTable. It is also aEventListthat contains the table's selection.As elements are selected or deselected, the
EventListaspect of thisEventSelectionModelchanges. Changes to thatListwill change the sourceEventList. To modify only the selection, use theListSelectionModel's methods.Alongside
MULTIPLE_INTERVAL_SELECTION, thisListSelectionModelsupports an additional selection mode.MULTIPLE_INTERVAL_SELECTION_DEFENSIVEis a new selection mode. It is identical toMULTIPLE_INTERVAL_SELECTIONin every way but one. When a row is inserted immediately before a selected row in theMULTIPLE_INTERVAL_SELECTIONmode, it becomes selected. But in theMULTIPLE_INTERVAL_SELECTION_DEFENSIVEmode, 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>swingThreadSourceDeprecated.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 voidaddListSelectionListener(javax.swing.event.ListSelectionListener listener)Deprecated.Add a listener to the list that's notified each time a change to the selection occurs.voidaddSelectionInterval(int index0, int index1)Deprecated.Change the selection to be the set union of the current selection and the indices between index0 and index1 inclusivevoidaddValidSelectionMatcher(Matcher<E> validSelectionMatcher)Deprecated.Add a matcher which decides when source elements are valid for selection.voidclearSelection()Deprecated.Change the selection to the empty set.voiddispose()Deprecated.Releases the resources consumed by thisEventSelectionModelso that it may eventually be garbage collected.intgetAnchorSelectionIndex()Deprecated.Return the first index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().EventList<E>getDeselected()Deprecated.Gets anEventListthat contains only deselected values and modifies the source list on mutation.booleangetEnabled()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.intgetLeadSelectionIndex()Deprecated.Return the second index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().javax.swing.ListSelectionModelgetListSelectionModel()Deprecated.As of 2004/11/26, theEventSelectionModelimplementsListSelectionModeldirectly.intgetMaxSelectionIndex()Deprecated.Gets the index of the last selected element.intgetMinSelectionIndex()Deprecated.Gets the index of the first selected element.EventList<E>getSelected()Deprecated.Gets anEventListthat contains only selected values and modifies the source list on mutation.intgetSelectionMode()Deprecated.Returns the current selection mode.EventList<E>getTogglingDeselected()Deprecated.Gets anEventListthat contains only deselected values and modifies the selection state on mutation.EventList<E>getTogglingSelected()Deprecated.Gets anEventListthat contains only selected values and modifies the selection state on mutation.booleangetValueIsAdjusting()Deprecated.Returns true if the value is undergoing a series of changes.voidinsertIndexInterval(int index, int length, boolean before)Deprecated.Insert length indices beginning before/after index.voidinvertSelection()Deprecated.Inverts the current selection.booleanisSelectedIndex(int index)Deprecated.Returns true if the specified index is selected.booleanisSelectionEmpty()Deprecated.Returns true if no indices are selected.voidremoveIndexInterval(int index0, int index1)Deprecated.Remove the indices in the interval index0,index1 (inclusive) from the selection model.voidremoveListSelectionListener(javax.swing.event.ListSelectionListener listener)Deprecated.Remove a listener from the list that's notified each time a change to the selection occurs.voidremoveSelectionInterval(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.voidremoveValidSelectionMatcher(Matcher<E> validSelectionMatcher)Deprecated.Remove a matcher which decides when source elements are valid for selection.voidsetAnchorSelectionIndex(int anchorSelectionIndex)Deprecated.Set the anchor selection index.voidsetEnabled(boolean enabled)Deprecated.Set the EventSelectionModel as editable or not.voidsetLeadSelectionIndex(int leadSelectionIndex)Deprecated.Set the lead selection index.voidsetSelectionInterval(int index0, int index1)Deprecated.Change the selection to be between index0 and index1 inclusive.voidsetSelectionMode(int selectionMode)Deprecated.Set the selection mode.voidsetValueIsAdjusting(boolean valueIsAdjusting)Deprecated.This property is true if upcoming changes to the value of the model should be considered a single event.java.lang.StringtoString()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. TheEventSelectionModellistens to thisEventListin order to adjust selection when theEventListis modified. For example, when an element is added to theEventList, this may offset the selection of the following elements.- Parameters:
source- theEventListwhose selection will be managed. This should be the sameEventListpassed to the constructor of yourEventTableModelorEventListModel.
-
-
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:
addListSelectionListenerin 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:
addSelectionIntervalin 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:
addValidSelectionMatcherin 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:
clearSelectionin interfacejavax.swing.ListSelectionModel
-
dispose
public void dispose()
Deprecated.Releases the resources consumed by thisEventSelectionModelso that it may eventually be garbage collected.An
EventSelectionModelwill be garbage collected without a call todispose(), but not before its sourceEventListis garbage collected. By callingdispose(), you allow theEventSelectionModelto be garbage collected before its sourceEventList. This is necessary for situations where anEventSelectionModelis short-lived but its sourceEventListis long-lived.Warning: It is an error to call any method on a
EventSelectionModelafter it has been disposed.- Specified by:
disposein interfaceAdvancedListSelectionModel<E>
-
getAnchorSelectionIndex
public int getAnchorSelectionIndex()
Deprecated.Return the first index argument from the most recent call to setSelectionInterval(), addSelectionInterval() or removeSelectionInterval().- Specified by:
getAnchorSelectionIndexin interfacejavax.swing.ListSelectionModel
-
getDeselected
public EventList<E> getDeselected()
Deprecated.Gets anEventListthat 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:
getDeselectedin interfaceAdvancedListSelectionModel<E>
-
getEnabled
public boolean getEnabled()
Deprecated.Returns whether the EventSelectionModel is editable or not.- Specified by:
getEnabledin 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:
getLeadSelectionIndexin interfacejavax.swing.ListSelectionModel
-
getListSelectionModel
public javax.swing.ListSelectionModel getListSelectionModel()
Deprecated.As of 2004/11/26, theEventSelectionModelimplementsListSelectionModeldirectly.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:
getMaxSelectionIndexin interfacejavax.swing.ListSelectionModel
-
getMinSelectionIndex
public int getMinSelectionIndex()
Deprecated.Gets the index of the first selected element.- Specified by:
getMinSelectionIndexin interfacejavax.swing.ListSelectionModel
-
getSelected
public EventList<E> getSelected()
Deprecated.Gets anEventListthat 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:
getSelectedin interfaceAdvancedListSelectionModel<E>
-
getSelectionMode
public int getSelectionMode()
Deprecated.Returns the current selection mode.- Specified by:
getSelectionModein interfacejavax.swing.ListSelectionModel
-
getTogglingDeselected
public EventList<E> getTogglingDeselected()
Deprecated.Gets anEventListthat 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 anIllegalArgumentExceptionis thrown- Specified by:
getTogglingDeselectedin interfaceAdvancedListSelectionModel<E>
-
getTogglingSelected
public EventList<E> getTogglingSelected()
Deprecated.Gets anEventListthat 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 anIllegalArgumentExceptionis thrown.- Specified by:
getTogglingSelectedin interfaceAdvancedListSelectionModel<E>
-
getValueIsAdjusting
public boolean getValueIsAdjusting()
Deprecated.Returns true if the value is undergoing a series of changes.- Specified by:
getValueIsAdjustingin interfacejavax.swing.ListSelectionModel
-
insertIndexInterval
public void insertIndexInterval(int index, int length, boolean before)Deprecated.Insert length indices beginning before/after index.- Specified by:
insertIndexIntervalin interfacejavax.swing.ListSelectionModel
-
invertSelection
public void invertSelection()
Deprecated.Inverts the current selection.- Specified by:
invertSelectionin 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:
isSelectedIndexin interfacejavax.swing.ListSelectionModel
-
isSelectionEmpty
public boolean isSelectionEmpty()
Deprecated.Returns true if no indices are selected.- Specified by:
isSelectionEmptyin 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:
removeIndexIntervalin 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:
removeListSelectionListenerin 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:
removeSelectionIntervalin 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:
removeValidSelectionMatcherin 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:
setAnchorSelectionIndexin 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:
setEnabledin interfaceAdvancedListSelectionModel<E>
-
setLeadSelectionIndex
public void setLeadSelectionIndex(int leadSelectionIndex)
Deprecated.Set the lead selection index.- Specified by:
setLeadSelectionIndexin 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:
setSelectionIntervalin interfacejavax.swing.ListSelectionModel
-
setSelectionMode
public void setSelectionMode(int selectionMode)
Deprecated.Set the selection mode.- Specified by:
setSelectionModein 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:
setValueIsAdjustingin interfacejavax.swing.ListSelectionModel
-
toString
public java.lang.String toString()
Deprecated.- Overrides:
toStringin classjava.lang.Object
-
-