class org.aswing.tree.DefaultTreeModel

A simple tree data model that uses TreeNodes.

@see org.aswing.tree.DefaultMutableTreeNode @author paling

Instance Fields

var root:TreeNode

Root of the tree.

function new(?root:TreeNode = null, ?asc:Bool = false): Void

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

@see #asksAllowsChildren

root

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

function addTreeModelListener(l:TreeModelListener): Void

Adds a listener for the TreeModelEvent posted after the tree changes.

@see #removeTreeModelListener

l

the listener to add

function asksAllowsChildren(): Bool

Tells how leaf nodes are determined.

@see #asksAllowsChildren

returns

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

function getChild(parent:TreeNode, index:Int): Dynamic

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

parent

a node in the tree, obtained from this data source

returns

the child of parent at index index

function getChildCount(parent:TreeNode): Int

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.

parent

a node in the tree, obtained from this data source

returns

the number of children of the node parent

function getIndexOfChild(parent:TreeNode, child:Dynamic): Int

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

parent

a note in the tree, obtained from this data source

child

the node we are interested in

returns

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

function insertNodeInto(newChild:MutableTreeNode, parent:MutableTreeNode, index:Int): 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.

function isLeaf(node:TreeNode): Bool

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

@see #asksAllowsChildren @see TreeModel#isLeaf

node

the node to check

returns

true if the node is a leaf node

function nodeChanged(node:TreeNode): Void

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

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.

function nodesChanged(node:TreeNode, childIndices:Array<Dynamic>): Void

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

function nodesWereInserted(node:TreeNode, childIndices:Array<Dynamic>): 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.

function nodesWereRemoved(node:TreeNode, childIndices:Array<Dynamic>, removedChildren:Array<Dynamic>): 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.

function reload(?node:TreeNode = null): 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).

node

(optional). Default is root.

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.

function removeTreeModelListener(l:TreeModelListener): Void

Removes a listener previously added with addTreeModelListener().

@see #addTreeModelListener

l

the listener to remove

function setAsksAllowsChildren(newValue:Bool): 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.

function toString(): String

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