echopointng.tree
Class TreeListSelectionModel

java.lang.Object
  extended by echopointng.tree.TreeListSelectionModel
All Implemented Interfaces:
java.io.Serializable, ListSelectionModel

public class TreeListSelectionModel
extends java.lang.Object
implements ListSelectionModel, java.io.Serializable

Default data model for tree list selections.

See Also:
Serialized Form

Field Summary
protected  boolean leadAnchorNotificationEnabled
           
protected  EventListenerList listenerList
           
static int MULTIPLE_INTERVAL_SELECTION
           
static int SINGLE_INTERVAL_SELECTION
           
static int SINGLE_SELECTION
           
 
Fields inherited from interface nextapp.echo2.app.list.ListSelectionModel
MULTIPLE_SELECTION
 
Constructor Summary
TreeListSelectionModel()
           
 
Method Summary
 void addChangeListener(ChangeListener l)
          Adds a ChangeListenerb to the selection model, which will be notified when the selection changes.
 void addSelectionInterval(int index0, int index1)
           
 void clearSelection()
          Deselects all items.
protected  void fireValueChanged(boolean isAdjusting)
          Notify listeners that we have ended a series of adjustments.
protected  void fireValueChanged(int firstIndex, int lastIndex)
          Notify ListSelectionListeners that the value of the selection, in the closed interval firstIndex,lastIndex, has changed.
protected  void fireValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
           
 int getAnchorSelectionIndex()
           
 int getLeadSelectionIndex()
           
 int getMaxSelectedIndex()
          Returns the maximum selected index.
 int getMinSelectedIndex()
          Returns the minimum selected index.
 int getSelectionMode()
          Returns the selection mode.
 boolean getValueIsAdjusting()
           
 void insertIndexInterval(int index, int length, boolean before)
          Insert length indices beginning before/after index.
 boolean isLeadAnchorNotificationEnabled()
          Returns the value of the leadAnchorNotificationEnabled flag.
 boolean isSelectedIndex(int index)
          Determines whether an index is selected.
 boolean isSelectionEmpty()
          Determines if no items are selected.
 void removeChangeListener(ChangeListener l)
          Removes a ChangeListener from being notified of when the selection changes.
 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)
           
 void setAnchorSelectionIndex(int anchorIndex)
          Set the anchor selection index, leaving all selection values unchanged.
 void setLeadAnchorNotificationEnabled(boolean flag)
          Sets the value of the leadAnchorNotificationEnabled flag.
 void setLeadSelectionIndex(int leadIndex)
          Set the lead selection index, ensuring that values between the anchor and the new lead are either all selected or all deselected.
 void setSelectedIndex(int index, boolean selected)
          Sets the selection state of the given index.
 void setSelectionInterval(int index0, int index1)
           
 void setSelectionMode(int selectionMode)
          Sets the selection mode.
 void setValueIsAdjusting(boolean isAdjusting)
           
 java.lang.String toString()
          Returns a string that displays and identifies this object's properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SINGLE_SELECTION

public static final int SINGLE_SELECTION
See Also:
Constant Field Values

SINGLE_INTERVAL_SELECTION

public static final int SINGLE_INTERVAL_SELECTION
See Also:
Constant Field Values

MULTIPLE_INTERVAL_SELECTION

public static final int MULTIPLE_INTERVAL_SELECTION
See Also:
Constant Field Values

listenerList

protected EventListenerList listenerList

leadAnchorNotificationEnabled

protected boolean leadAnchorNotificationEnabled
Constructor Detail

TreeListSelectionModel

public TreeListSelectionModel()
Method Detail

addChangeListener

public void addChangeListener(ChangeListener l)
Description copied from interface: ListSelectionModel
Adds a ChangeListenerb to the selection model, which will be notified when the selection changes.

Specified by:
addChangeListener in interface ListSelectionModel
Parameters:
l - the ChangeListener to add
See Also:
ListSelectionModel.addChangeListener(nextapp.echo2.app.event.ChangeListener)

addSelectionInterval

public void addSelectionInterval(int index0,
                                 int index1)

clearSelection

public void clearSelection()
Description copied from interface: ListSelectionModel
Deselects all items.

Specified by:
clearSelection in interface ListSelectionModel

fireValueChanged

protected void fireValueChanged(int firstIndex,
                                int lastIndex)
Notify ListSelectionListeners that the value of the selection, in the closed interval firstIndex,lastIndex, has changed.


fireValueChanged

protected void fireValueChanged(int firstIndex,
                                int lastIndex,
                                boolean isAdjusting)
Parameters:
firstIndex - The first index in the interval.
lastIndex - The last index in the interval.
isAdjusting - True if this is the final change in a series of them.

fireValueChanged

protected void fireValueChanged(boolean isAdjusting)
Notify listeners that we have ended a series of adjustments.


getAnchorSelectionIndex

public int getAnchorSelectionIndex()

getLeadSelectionIndex

public int getLeadSelectionIndex()

getMaxSelectedIndex

public int getMaxSelectedIndex()
Description copied from interface: ListSelectionModel
Returns the maximum selected index. Returns -1 when no items are selected.

Specified by:
getMaxSelectedIndex in interface ListSelectionModel
Returns:
the maximum selected index

getMinSelectedIndex

public int getMinSelectedIndex()
Description copied from interface: ListSelectionModel
Returns the minimum selected index. Returns -1 when no items are selected.

Specified by:
getMinSelectedIndex in interface ListSelectionModel
Returns:
the minimum selected index

getSelectionMode

public int getSelectionMode()
Description copied from interface: ListSelectionModel
Returns the selection mode.

Specified by:
getSelectionMode in interface ListSelectionModel
Returns:
the selection mode, one of the following values:
  • ListSelectionModel.SINGLE_SELECTION: only one list element may be selected.
  • ListSelectionModel.MULTIPLE_SELECTION: multiple list elements may be selected.

getValueIsAdjusting

public boolean getValueIsAdjusting()

insertIndexInterval

public void insertIndexInterval(int index,
                                int length,
                                boolean before)
Insert length indices beginning before/after index. If the value at index is itself selected, set all of the newly inserted items, otherwise leave them unselected. This method is typically called to sync the selection model with a corresponding change in the data model.


isLeadAnchorNotificationEnabled

public boolean isLeadAnchorNotificationEnabled()
Returns the value of the leadAnchorNotificationEnabled flag. When leadAnchorNotificationEnabled is true the model generates notification events with bounds that cover all the changes to the selection plus the changes to the lead and anchor indices. Setting the flag to false causes a norrowing of the event's bounds to include only the elements that have been selected or deselected since the last change. Either way, the model continues to maintain the lead and anchor variables internally. The default is true.


isSelectedIndex

public boolean isSelectedIndex(int index)
Description copied from interface: ListSelectionModel
Determines whether an index is selected.

Specified by:
isSelectedIndex in interface ListSelectionModel
Parameters:
index - the index
Returns:
true if the index is selected

isSelectionEmpty

public boolean isSelectionEmpty()
Description copied from interface: ListSelectionModel
Determines if no items are selected.

Specified by:
isSelectionEmpty in interface ListSelectionModel
Returns:
true if no items are selected

removeIndexInterval

public void removeIndexInterval(int index0,
                                int index1)
Remove the indices in the interval index0,index1 (inclusive) from the selection model. This is typically called to sync the selection model width a corresponding change in the data model. Note that (as always) index0 need not be <= index1.


removeChangeListener

public void removeChangeListener(ChangeListener l)
Description copied from interface: ListSelectionModel
Removes a ChangeListener from being notified of when the selection changes.

Specified by:
removeChangeListener in interface ListSelectionModel
Parameters:
l - the ChangeListener to remove
See Also:
ListSelectionModel.removeChangeListener(nextapp.echo2.app.event.ChangeListener)

removeSelectionInterval

public void removeSelectionInterval(int index0,
                                    int index1)

setAnchorSelectionIndex

public void setAnchorSelectionIndex(int anchorIndex)
Set the anchor selection index, leaving all selection values unchanged. If leadAnchorNotificationEnabled is true, send a notification covering the old and new anchor cells.


setLeadAnchorNotificationEnabled

public void setLeadAnchorNotificationEnabled(boolean flag)
Sets the value of the leadAnchorNotificationEnabled flag.


setLeadSelectionIndex

public void setLeadSelectionIndex(int leadIndex)
Set the lead selection index, ensuring that values between the anchor and the new lead are either all selected or all deselected. If the value at the anchor index is selected, first clear all the values in the range [anchor, oldLeadIndex], then select all the values values in the range [anchor, newLeadIndex], where oldLeadIndex is the old leadIndex and newLeadIndex is the new one.

If the value at the anchor index is not selected, do the same thing in reverse, selecting values in the old range and deslecting values in the new one.

Generate a single event for this change and notify all listeners. For the purposes of generating minimal bounds in this event, do the operation in a single pass; that way the first and last index inside the ListSelectionEvent that is broadcast will refer to cells that actually changed value because of this method. If, instead, this operation were done in two steps the effect on the selection state would be the same but two events would be generated and the bounds around the changed values would be wider, including cells that had been first cleared only to later be set.

This method can be used in the mouseDragged() method of a UI class to extend a selection.


setSelectedIndex

public void setSelectedIndex(int index,
                             boolean selected)
Description copied from interface: ListSelectionModel
Sets the selection state of the given index.

Specified by:
setSelectedIndex in interface ListSelectionModel
Parameters:
index - the index
selected - the new selection state

setSelectionInterval

public void setSelectionInterval(int index0,
                                 int index1)

setSelectionMode

public void setSelectionMode(int selectionMode)
Description copied from interface: ListSelectionModel
Sets the selection mode.

Specified by:
setSelectionMode in interface ListSelectionModel
Parameters:
selectionMode - the selection mode, one of the following values:
  • ListSelectionModel.SINGLE_SELECTION: only one list element may be selected.
  • ListSelectionModel.MULTIPLE_SELECTION: multiple list elements may be selected.

setValueIsAdjusting

public void setValueIsAdjusting(boolean isAdjusting)

toString

public java.lang.String toString()
Returns a string that displays and identifies this object's properties.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this object