Class fvaswing.components.tree.FvTreeModel

Description

Default model to use with FvTree component.

Extends fvaswing.components.FvAbstractTreeModel class to deploy strong typing strategy.

Allow childnodes sorting.

Method Index

new FvTreeModel()
getChild(), getChildCount(), getIndexOfChild(), getNodeById(), getRoot(), insertNodeInto(), isLeaf(), nodeChanged(), nodesChanged(), nodeStructureChanged(), nodesWereInserted(), nodesWereRemoved(), reload(), removeNodeFromParent(), sortNode(), valueForPathChanged()

Inherited from FvAbstractTreeModel

Constructor Detail

FvTreeModel

public function FvTreeModel(root:FvTreeNode, asc:Boolean)

Creates a tree specifying whether any node can have children, or whether only certain nodes can have children.

Parameters

roota TreeNode object that is the root of the tree
asc(optional)a boolean, false if any node can have children, true if each node is asked to see if it can have children. Default is false.

See Also

Method Detail

getRoot

public function getRoot():FvTreeNode

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

Return

the root of the tree

Overrides

getRoot() in fvaswing.components.tree.FvAbstractTreeModel

getNodeById

public function getNodeById(nodeID:Number):FvTreeNode

Returns tree node resgitred with passed-in nodeID in current tree.

If not, return null

valueForPathChanged

public function valueForPathChanged(path:TreePath, newValue):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.

getIndexOfChild

public function getIndexOfChild(parent:FvTreeNode, child:FvTreeNode):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

Overrides

getIndexOfChild() in fvaswing.components.tree.FvAbstractTreeModel

getChild

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

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

Overrides

getChild() in fvaswing.components.tree.FvAbstractTreeModel

getChildCount

public function getChildCount(parent:FvTreeNode):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

Overrides

getChildCount() in fvaswing.components.tree.FvAbstractTreeModel

isLeaf

public function isLeaf(node:FvTreeNode):Boolean

Returns whether the specified node is a leaf node. The way the test is performed depends on the askAllowsChildren setting.

Parameters

nodethe node to check

Return

true if the node is a leaf node

Overrides

isLeaf() in fvaswing.components.tree.FvAbstractTreeModel

insertNodeInto

public function insertNodeInto(newChild:FvTreeNode, parent:FvTreeNode, 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:FvTreeNode):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:FvTreeNode):Void

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

reload

public function reload(node:FvTreeNode):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.

Overrides

reload() in fvaswing.components.tree.FvAbstractTreeModel

sortNode

public function sortNode(node:FvTreeNode):Void

Sorts passed-in node childnodes.

nodesWereInserted

public function nodesWereInserted(node:FvTreeNode, 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:FvTreeNode, 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:FvTreeNode, 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:FvTreeNode):Void

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

This will post a treeStructureChanged event.