Class fvaswing.components.tree.FvAbstractTreeModel

Implemented Interfaces

TreeModel

Description

Default model to use with FvTree component.

Implements fvaswing.components.FvTreeModel interface.

Based on on AsWing DefaultTreeModel implementation.

Method Index

addTreeModelListener(), asksAllowsChildren(), getAutoSortingEnabled(), getChild(), getChildCount(), getIndexOfChild(), getRoot(), insertNodeInto(), isLeaf(), nodeChanged(), nodesChanged(), nodeStructureChanged(), nodesWereInserted(), nodesWereRemoved(), reload(), removeNodeFromParent(), removeTreeModelListener(), setAsksAllowsChildren(), setAutoSortingEnabled(), setRoot(), setSortingProcess(), sort(), sortNode(), toString(), valueForPathChanged()

Method Detail

setSortingProcess

public function setSortingProcess(process:Function, options:Number):Void

Defines sorting process to use when childnodes are automatically reorder.

Parameters

processSorting function
optionsSorting options

setAsksAllowsChildren

public function setAsksAllowsChildren(newValue:Boolean):Void

Sets whether or not to test leafness by asking getAllowsChildren() or isLeaf() to the TreeNodes. If newvalue is true, getAllowsChildren() is messaged, otherwise isLeaf() is messaged.

asksAllowsChildren

public function asksAllowsChildren():Boolean

Tells how leaf nodes are determined.

Return

true if only nodes which do not allow children are leaf nodes, false if nodes which have no children (even if allowed) are leaf nodes

setRoot

public function setRoot(root:TreeNode):Void

Sets the root to root.
A null root implies the tree is to display nothing, and is legal.

getRoot

public function getRoot():Object

Returns the root of the tree. Returns null only if the tree has no nodes.

Return

the root of the tree

getIndexOfChild

public function getIndexOfChild(parent:Object, child:Object):Number

Returns the index of child in parent. If either the parent or child is null, returns -1.

Parameters

parenta note in the tree, obtained from this data source
childthe node we are interested in

Return

the index of the child in the parent, or -1 if either the parent or the child is null

getChild

public function getChild(parent:Object, index:Number):Object

Returns the child of parent at index index in the parent's child array. parent must be a node previously obtained from this data source. This should not return null if index is a valid index for parent (that is index >= 0 && index < getChildCount(parent)).

Parameters

parenta node in the tree, obtained from this data source

Return

the child of parent at index index

getChildCount

public function getChildCount(parent:Object):Number

Returns the number of children of parent. Returns 0 if the node is a leaf or if it has no children. parent must be a node previously obtained from this data source.

Parameters

parenta node in the tree, obtained from this data source

Return

the number of children of the node parent

isLeaf

public function isLeaf(node:Object):Boolean

Returns whether the specified node is a leaf node.

Parameters

nodethe node to check

Return

true if the node is a leaf node

valueForPathChanged

public function valueForPathChanged(path:TreePath, newValue:Object):Void

This sets the user object of the TreeNode identified by path and posts a node changed.

If you use custom user objects in the TreeModel you're going to need to subclass this and set the user object of the changed node to something meaningful.

insertNodeInto

public function insertNodeInto(newChild:MutableTreeNode, parent:MutableTreeNode, index:Number):Void

Invoked this to insert newChild at location index in parents children.

This will then message nodesWereInserted to create the appropriate event.

This is the preferred way to add children as it will create the appropriate event.

removeNodeFromParent

public function removeNodeFromParent(node:MutableTreeNode):Void

Message this to remove node from its parent. This will message nodesWereRemoved to create the appropriate event. This is the preferred way to remove a node as it handles the event creation for you.

nodeChanged

public function nodeChanged(node:TreeNode):Void

Invoke this method after you've changed how node is to be represented in the tree.

reload

public function reload(node:TreeNode):Void

Invoke this method if you've modified the TreeNodes upon which this model depends. The model will notify all of its listeners that the model has changed below the node node (PENDING).

Parameters

node(optional). Default is root.

setAutoSortingEnabled

public function setAutoSortingEnabled(b:Boolean):Void

Sets if childnodes are automatically reorder ( sort ).

getAutoSortingEnabled

public function getAutoSortingEnabled():Boolean

Returns true if auto sorting is enabled.

sort

public function sort():Void

Sorts full tree childnodes.

Use FvTree#sort() method when you can.
FvTree keep expandable tree state.

sortNode

public function sortNode(node:FvAbstractTreeNode):Void

Sorts passed-in node childnodes.

nodesWereInserted

public function nodesWereInserted(node:TreeNode, childIndices:Array):Void

Invoke this method after you've inserted some TreeNodes into node. childIndices should be the index of the new elements and must be sorted in ascending order.

nodesWereRemoved

public function nodesWereRemoved(node:TreeNode, childIndices:Array, removedChildren:Array):Void

Invoke this method after you've removed some TreeNodes from node. childIndices should be the index of the removed elements and must be sorted in ascending order. And removedChildren should be the array of the children objects that were removed.

nodesChanged

public function nodesChanged(node:TreeNode, childIndices:Array):Void

Invoke this method after you've changed how the children identified by childIndicies are to be represented in the tree.

nodeStructureChanged

public function nodeStructureChanged(node:TreeNode):Void

Invoke this method if you've totally changed the children of node and its childrens children.

This will post a treeStructureChanged event.

addTreeModelListener

public function addTreeModelListener(listener:TreeModelListener):Void

Addspassed-in listener listener for the TreeModelEvent posted after the tree changes.

Parameters

listenerthe listener to add

removeTreeModelListener

public function removeTreeModelListener(listener:TreeModelListener):Void

Removes passed-in listener listener.

Parameters

listenerthe listener to remove

toString

public function toString():String

Returns string representation.