Packageorg.aswing.tree
Classpublic class DefaultTreeSelectionModel
InheritanceDefaultTreeSelectionModel Inheritance flash.events.EventDispatcher
ImplementsTreeSelectionModel
SubclassesEmptySelectionModel

Default implementation of TreeSelectionModel. Listeners are notified whenever the paths in the selection change, not the rows. In order to be able to track row changes you may wish to become a listener for expansion events on the tree and test for changes from there.

resetRowSelection is called from any of the methods that update the selected paths. If you subclass any of these methods to filter what is allowed to be selected, be sure and message resetRowSelection if you do not message super.



Public Methods
 MethodDefined by
  
Creates a new instance of DefaultTreeSelectionModel that is empty, with a selection mode of DISCONTIGUOUS_TREE_SELECTION.
DefaultTreeSelectionModel
  
addPropertyChangeListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void
Adds a PropertyChangeListener to the listener list.
DefaultTreeSelectionModel
  
addSelectionPath(path:TreePath, programmatic:Boolean = true):void
Adds path to the current selection.
DefaultTreeSelectionModel
  
addSelectionPaths(paths:Array, programmatic:Boolean = true):void
Adds paths(TreePath[]) to the current selection.
DefaultTreeSelectionModel
  
addTreeSelectionListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void
Adds x to the list of listeners that are notified each time the set of selected TreePaths changes.
DefaultTreeSelectionModel
  
clearSelection(programmatic:Boolean = true):void
Empties the current selection.
DefaultTreeSelectionModel
  
Returns the last path that was added.
DefaultTreeSelectionModel
  
Returns the lead selection index.
DefaultTreeSelectionModel
  
Returns the largest value obtained from the RowMapper for the current set of selected TreePaths.
DefaultTreeSelectionModel
  
Returns the smallest value obtained from the RowMapper for the current set of selected TreePaths.
DefaultTreeSelectionModel
  
Returns the RowMapper instance that is able to map a TreePath to a row.
DefaultTreeSelectionModel
  
Returns the number of paths that are selected.
DefaultTreeSelectionModel
  
Returns the selection mode, one of SINGLE_TREE_SELECTION, DISCONTIGUOUS_TREE_SELECTION or CONTIGUOUS_TREE_SELECTION.
DefaultTreeSelectionModel
  
Returns the first path in the selection.
DefaultTreeSelectionModel
  
Returns the paths(TreePath[]) in the selection.
DefaultTreeSelectionModel
  
Returns all of the currently selected rows(int[]).
DefaultTreeSelectionModel
  
isPathSelected(path:TreePath):Boolean
Returns true if the path, path, is in the current selection.
DefaultTreeSelectionModel
  
isRowSelected(row:int):Boolean
Returns true if the row identified by row is selected.
DefaultTreeSelectionModel
  
isSelectionEmpty():Boolean
Returns true if the selection is currently empty.
DefaultTreeSelectionModel
  
removePropertyChangeListener(listener:Function):void
Removed a propertyChangeListener.
DefaultTreeSelectionModel
  
removeSelectionPath(path:TreePath, programmatic:Boolean = true):void
Removes path from the selection.
DefaultTreeSelectionModel
  
removeSelectionPaths(paths:Array, programmatic:Boolean = true):void
Removes paths from the selection.
DefaultTreeSelectionModel
  
removeTreeSelectionListener(listener:Function):void
Removed a treeSelectionListener.
DefaultTreeSelectionModel
  
Updates this object's mapping from TreePath to rows.
DefaultTreeSelectionModel
  
setRowMapper(newMapper:RowMapper):void
Sets the RowMapper instance.
DefaultTreeSelectionModel
  
setSelectionMode(mode:int):void
Sets the selection model, which must be one of SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION.
DefaultTreeSelectionModel
  
setSelectionPath(path:TreePath, programmatic:Boolean = true):void
Sets the selection to path.
DefaultTreeSelectionModel
  
setSelectionPaths(pPaths:Array, programmatic:Boolean = true):void
Sets the selection to the paths in paths.
DefaultTreeSelectionModel
  
toString():String
Returns a string that displays and identifies this object's properties.
DefaultTreeSelectionModel
Protected Methods
 MethodDefined by
  
firePropertyChange(name:String, oldValue:*, newValue:*):void
DefaultTreeSelectionModel
  
Notifies all listeners that are registered for tree selection events on this object.
DefaultTreeSelectionModel
Public Constants
 ConstantDefined by
  CONTIGUOUS_TREE_SELECTION : int = 2
[static] Selection can only be contiguous.
DefaultTreeSelectionModel
  DISCONTIGUOUS_TREE_SELECTION : int = 4
[static] Selection can contain any number of items that are not necessarily contiguous.
DefaultTreeSelectionModel
  ON_PROPERTY_CHANGED : String = "onPropertyChanged"
[static] onPropertyChanged(source:DefaultTreeSelectionModel, name:String, oldValue, newValue);
DefaultTreeSelectionModel
  ON_SELECTION_CHANGED : String = "onSelectionChanged"
[static] onSelectionChanged(source:DefaultTreeSelectionModel, e:TreeSelectionEvent);
DefaultTreeSelectionModel
  SELECTION_MODE_PROPERTY : String = "selectionMode"
[static] Property name for selectionMode.
DefaultTreeSelectionModel
  SINGLE_TREE_SELECTION : int = 1
[static] Selection can only contain one path at a time.
DefaultTreeSelectionModel
Constructor detail
DefaultTreeSelectionModel()constructor
public function DefaultTreeSelectionModel()

Creates a new instance of DefaultTreeSelectionModel that is empty, with a selection mode of DISCONTIGUOUS_TREE_SELECTION.

Method detail
addPropertyChangeListener()method
public function addPropertyChangeListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void

Adds a PropertyChangeListener to the listener list. The listener is registered for all properties.

A PropertyChangeEvent will get fired when the selection mode changes. Parameters

listener:Function — the propertyChangeListener to be added
 
priority:int (default = 0) — the priority
 
useWeakReference:Boolean (default = false) — Determines whether the reference to the listener is strong or weak.

See also

addSelectionPath()method 
public function addSelectionPath(path:TreePath, programmatic:Boolean = true):void

Adds path to the current selection. If path is not currently in the selection the TreeSelectionListeners are notified. This has no effect if path is null.

Parameters
path:TreePath — the new path to add to the current selection.
 
programmatic:Boolean (default = true) — indicate if this is a programmatic change.
addSelectionPaths()method 
public function addSelectionPaths(paths:Array, programmatic:Boolean = true):void

Adds paths(TreePath[]) to the current selection. If any of the paths in paths are not currently in the selection the TreeSelectionListeners are notified. This has no effect if paths is null.

The lead path is set to the last element in paths.

If the selection mode is CONTIGUOUS_TREE_SELECTION, and adding the new paths would make the selection discontiguous. Then two things can result: if the TreePaths in paths are contiguous, then the selection becomes these TreePaths, otherwise the TreePaths aren't contiguous and the selection becomes the first TreePath in paths. Parameters

paths:Array — the new path to add to the current selection.
 
programmatic:Boolean (default = true) — indicate if this is a programmatic change.
addTreeSelectionListener()method 
public function addTreeSelectionListener(listener:Function, priority:int = 0, useWeakReference:Boolean = false):void

Adds x to the list of listeners that are notified each time the set of selected TreePaths changes.

Parameters
listener:Function — the new listener to be added
 
priority:int (default = 0) — the priority
 
useWeakReference:Boolean (default = false) — Determines whether the reference to the listener is strong or weak.

See also

clearSelection()method 
public function clearSelection(programmatic:Boolean = true):void

Empties the current selection. If this represents a change in the current selection, the selection listeners are notified.

Parameters
programmatic:Boolean (default = true) — indicate if this is a programmatic change.
firePropertyChange()method 
protected function firePropertyChange(name:String, oldValue:*, newValue:*):voidParameters
name:String
 
oldValue:*
 
newValue:*
fireValueChanged()method 
protected function fireValueChanged(e:TreeSelectionEvent):void

Notifies all listeners that are registered for tree selection events on this object.

Parameters
e:TreeSelectionEvent

See also

addTreeSelectionListener
EventListenerList
getLeadSelectionPath()method 
public function getLeadSelectionPath():TreePath

Returns the last path that was added. This may differ from the leadSelectionPath property maintained by the JTree.

Returns
TreePath
getLeadSelectionRow()method 
public function getLeadSelectionRow():int

Returns the lead selection index. That is the last index that was added.

Returns
int
getMaxSelectionRow()method 
public function getMaxSelectionRow():int

Returns the largest value obtained from the RowMapper for the current set of selected TreePaths. If nothing is selected, or there is no RowMapper, this will return -1.

Returns
int
getMinSelectionRow()method 
public function getMinSelectionRow():int

Returns the smallest value obtained from the RowMapper for the current set of selected TreePaths. If nothing is selected, or there is no RowMapper, this will return -1.

Returns
int
getRowMapper()method 
public function getRowMapper():RowMapper

Returns the RowMapper instance that is able to map a TreePath to a row.

Returns
RowMapper
getSelectionCount()method 
public function getSelectionCount():int

Returns the number of paths that are selected.

Returns
int
getSelectionMode()method 
public function getSelectionMode():int

Returns the selection mode, one of SINGLE_TREE_SELECTION, DISCONTIGUOUS_TREE_SELECTION or CONTIGUOUS_TREE_SELECTION.

Returns
int
getSelectionPath()method 
public function getSelectionPath():TreePath

Returns the first path in the selection. This is useful if there if only one item currently selected.

Returns
TreePath
getSelectionPaths()method 
public function getSelectionPaths():Array

Returns the paths(TreePath[]) in the selection. This will return null (or an empty array) if nothing is currently selected.

Returns
Array
getSelectionRows()method 
public function getSelectionRows():Array

Returns all of the currently selected rows(int[]). This will return null (or an empty array) if there are no selected TreePaths or a RowMapper has not been set. This may return an array of length less that than of the selected TreePaths if some of the rows are not visible (that is the RowMapper returned -1 for the row corresponding to the TreePath).

Returns
Array
isPathSelected()method 
public function isPathSelected(path:TreePath):Boolean

Returns true if the path, path, is in the current selection.

Parameters
path:TreePath

Returns
Boolean
isRowSelected()method 
public function isRowSelected(row:int):Boolean

Returns true if the row identified by row is selected.

Parameters
row:int

Returns
Boolean
isSelectionEmpty()method 
public function isSelectionEmpty():Boolean

Returns true if the selection is currently empty.

Returns
Boolean
removePropertyChangeListener()method 
public function removePropertyChangeListener(listener:Function):void

Removed a propertyChangeListener.

Parameters
listener:Function — the listener to be removed.
removeSelectionPath()method 
public function removeSelectionPath(path:TreePath, programmatic:Boolean = true):void

Removes path from the selection. If path is in the selection The TreeSelectionListeners are notified. This has no effect if path is null.

Parameters
path:TreePath — the path to remove from the selection.
 
programmatic:Boolean (default = true) — indicate if this is a programmatic change.
removeSelectionPaths()method 
public function removeSelectionPaths(paths:Array, programmatic:Boolean = true):void

Removes paths from the selection. If any of the paths in paths are in the selection the TreeSelectionListeners are notified. This has no effect if paths is null.

Parameters
paths:Array — the paths to remove from the selection.
 
programmatic:Boolean (default = true) — indicate if this is a programmatic change.
removeTreeSelectionListener()method 
public function removeTreeSelectionListener(listener:Function):void

Removed a treeSelectionListener.

Parameters
listener:Function — the listener to be removed.
resetRowSelection()method 
public function resetRowSelection():void

Updates this object's mapping from TreePath to rows. This should be invoked when the mapping from TreePaths to integers has changed (for example, a node has been expanded).

You do not normally have to call this, JTree and its associated Listeners will invoke this for you. If you are implementing your own View class, then you will have to invoke this.

This will invoke insureRowContinuity to make sure the currently selected TreePaths are still valid based on the selection mode.

setRowMapper()method 
public function setRowMapper(newMapper:RowMapper):void

Sets the RowMapper instance. This instance is used to determine the row for a particular TreePath.

Parameters
newMapper:RowMapper
setSelectionMode()method 
public function setSelectionMode(mode:int):void

Sets the selection model, which must be one of SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION. If mode is not one of the defined value, DISCONTIGUOUS_TREE_SELECTION is assumed.

This may change the selection if the current selection is not valid for the new mode. For example, if three TreePaths are selected when the mode is changed to SINGLE_TREE_SELECTION, only one TreePath will remain selected. It is up to the particular implementation to decide what TreePath remains selected.

Setting the mode to something other than the defined types will result in the mode becoming DISCONTIGUOUS_TREE_SELECTION. Parameters

mode:int
setSelectionPath()method 
public function setSelectionPath(path:TreePath, programmatic:Boolean = true):void

Sets the selection to path. If this represents a change, then the TreeSelectionListeners are notified. If path is null, this has the same effect as invoking clearSelection.

Parameters
path:TreePath — new path to select.
 
programmatic:Boolean (default = true) — indicate if this is a programmatic change.
setSelectionPaths()method 
public function setSelectionPaths(pPaths:Array, programmatic:Boolean = true):void

Sets the selection to the paths in paths. If this represents a change the TreeSelectionListeners are notified. Potentially paths will be held by this object; in other words don't change any of the objects in the array once passed in.

If paths is null, this has the same effect as invoking clearSelection.

The lead path is set to the last path in pPaths.

If the selection mode is CONTIGUOUS_TREE_SELECTION, and adding the new paths would make the selection discontiguous, the selection is reset to the first TreePath in paths. Parameters

pPaths:Array — new selection.
 
programmatic:Boolean (default = true) — indicate if this is a programmatic change.
toString()method 
public override function toString():String

Returns a string that displays and identifies this object's properties.

Returns
String — a String representation of this object
Constant detail
CONTIGUOUS_TREE_SELECTIONconstant
public static const CONTIGUOUS_TREE_SELECTION:int = 2

Selection can only be contiguous. This will only be enforced if a RowMapper instance is provided. That is, if no RowMapper is set this behaves the same as DISCONTIGUOUS_TREE_SELECTION.

DISCONTIGUOUS_TREE_SELECTIONconstant 
public static const DISCONTIGUOUS_TREE_SELECTION:int = 4

Selection can contain any number of items that are not necessarily contiguous.

ON_PROPERTY_CHANGEDconstant 
public static const ON_PROPERTY_CHANGED:String = "onPropertyChanged"

onPropertyChanged(source:DefaultTreeSelectionModel, name:String, oldValue, newValue);

ON_SELECTION_CHANGEDconstant 
public static const ON_SELECTION_CHANGED:String = "onSelectionChanged"

onSelectionChanged(source:DefaultTreeSelectionModel, e:TreeSelectionEvent);

SELECTION_MODE_PROPERTYconstant 
public static const SELECTION_MODE_PROPERTY:String = "selectionMode"

Property name for selectionMode.

SINGLE_TREE_SELECTIONconstant 
public static const SINGLE_TREE_SELECTION:int = 1

Selection can only contain one path at a time.