class org.aswing.tree.DefaultTreeSelectionModel extends EventDispatcher

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.

@author paling

Class Fields

static var CONTIGUOUS_TREE_SELECTION:Int

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 DISCONTIGUOUSTREESELECTION.

static var DISCONTIGUOUS_TREE_SELECTION:Int

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

static var ON_PROPERTY_CHANGED:String

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

static var ON_SELECTION_CHANGED:String

onSelectionChanged(source:DefaultTreeSelectionModel, e:TreeSelectionEvent);

static var SELECTION_MODE_PROPERTY:String

Property name for selectionMode.

static var SINGLE_TREE_SELECTION:Int

Selection can only contain one path at a time.

Instance Fields

Show inherited public instance fieldsHide inherited public instance fields

Inherited from EventDispatcher

function addEventListener(type:String, listener:Dynamic ->Void?useCapture:Bool, ?priority:Int, ?useWeakReference:Bool):Void
function dispatchEvent(event:Event):Bool
function hasEventListener(type:String):Bool
function removeEventListener(type:String, listener:Dynamic ->Void?useCapture:Bool):Void
function toString():String
function willTrigger(type:String):Bool

function new(): Void

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

function addPropertyChangeListener(listener:Dynamic ->Void?priority:Int = 0, ?useWeakReference:Bool = 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.

@param priority the priority

 * @param useWeakReference Determines whether the reference to the listener is strong or weak.

@see org.aswing.JTree#ONPROPERTYCHANGED

listener

the propertyChangeListener to be added *

function addSelectionPath(path:TreePath, ?programmatic:Bool = 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.

path

the new path to add to the current selection.

programmatic

indicate if this is a programmatic change.

function addSelectionPaths(paths:Array<Dynamic>, ?programmatic:Bool = 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 CONTIGUOUSTREESELECTION, 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.

paths

the new path to add to the current selection.

programmatic

indicate if this is a programmatic change.

function addTreeSelectionListener(listener:Dynamic ->Void?priority:Int = 0, ?useWeakReference:Bool = false): Void

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

@param priority the priority

  * @param useWeakReference Determines whether the reference to the listener is strong or weak.

@see org.aswing.JTree#ONSELECTIONCHANGED

listener

the new listener to be added *

function clearSelection(?programmatic:Bool = true): Void

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

programmatic

indicate if this is a programmatic change.

function getLeadSelectionPath(): TreePath

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

function getLeadSelectionRow(): Int

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

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.

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.

function getRowMapper(): RowMapper

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

function getSelectionCount(): Int

Returns the number of paths that are selected.

function getSelectionMode(): Int

Returns the selection mode, one of SINGLETREESELECTION, DISCONTIGUOUSTREESELECTION or CONTIGUOUSTREESELECTION.

function getSelectionPath(): TreePath

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

function getSelectionPaths(): Array<Dynamic>

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

function getSelectionRows(): Array<Dynamic>

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).

function isPathSelected(path:TreePath): Bool

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

function isRowSelected(row:Int): Bool

Returns true if the row identified by row is selected.

function isSelectionEmpty(): Bool

Returns true if the selection is currently empty.

function removePropertyChangeListener(listener:Dynamic ->Void): Void

Removed a propertyChangeListener.

listener

the listener to be removed.

function removeSelectionPath(path:TreePath, ?programmatic:Bool = 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.

path

the path to remove from the selection.

programmatic

indicate if this is a programmatic change.

function removeSelectionPaths(paths:Array<Dynamic>, ?programmatic:Bool = 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.

paths

the paths to remove from the selection.

programmatic

indicate if this is a programmatic change.

function removeTreeSelectionListener(listener:Dynamic ->Void): Void

Removed a treeSelectionListener.

listener

the listener to be removed.

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.

function setRowMapper(newMapper:RowMapper): Void

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

function setSelectionMode(mode:Int): Void

Sets the selection model, which must be one of SINGLETREESELECTION, CONTIGUOUSTREESELECTION or DISCONTIGUOUSTREESELECTION. If mode is not one of the defined value, DISCONTIGUOUSTREESELECTION 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 SINGLETREESELECTION, 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 DISCONTIGUOUSTREESELECTION.

function setSelectionPath(path:TreePath, ?programmatic:Bool = 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.

path

new path to select.

programmatic

indicate if this is a programmatic change.

function setSelectionPaths(pPaths:Array<Dynamic>, ?programmatic:Bool = 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 CONTIGUOUSTREESELECTION, and adding the new paths would make the selection discontiguous, the selection is reset to the first TreePath in paths.

pPaths

new selection.

programmatic

indicate if this is a programmatic change.

function toString(): String

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

returns

a String representation of this object