org.apache.myfaces.custom.tree.model

Class DefaultTreeModel

public class DefaultTreeModel extends Object implements TreeModel

Version: $Revision: 169651 $ $Date: 2005-05-11 18:14:23 +0200 (Wed, 11 May 2005) $

Author: Oliver Rossmueller

Constructor Summary
DefaultTreeModel()
DefaultTreeModel(TreeNode root)
Method Summary
protected voidfireTreeNodesChanged(Object source, Object[] path, int[] childIndices, Object[] children)
Notify all listeners of a node change.
protected voidfireTreeNodesInserted(Object source, Object[] path, int[] childIndices, Object[] children)
Notify all listeners of structure change.
protected voidfireTreeNodesRemoved(Object source, Object[] path, int[] childIndices, Object[] children)
Notify all listeners of structure change.
protected voidfireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object[] children)
Notify all listeners of structure change.
protected voidfireTreeStructureChanged(Object source, TreePath path)
Notify all listeners of structure change.
ObjectgetChild(Object parent, int index)
intgetChildCount(Object parent)
intgetIndexOfChild(Object parent, Object child)
TreeNode[]getPathToRoot(TreeNode node)
Collect all parent nodes up to the root node.
protected TreeNode[]getPathToRoot(TreeNode node, int depth)
Recursivly collect parent nodes up the the root node.
ObjectgetRoot()
CollectiongetTreeModelListeners()
booleanisLeaf(Object node)
voidnodeChanged(TreeNode node)
Invoke this method after you've changed how node is to be represented in the tree.
voidnodesChanged(TreeNode node, int[] childIndices)
Invoke this method after you've changed how the children identified by childIndicies are to be represented in the tree.
voidnodesWereInserted(TreeNode node, int[] childIndices)
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.
voidnodesWereRemoved(TreeNode node, int[] childIndices, Object[] removedChildren)
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.
voidnodeStructureChanged(TreeNode node)
Invoke this method if you've totally changed the children of node and its childrens children...
voidvalueForPathChanged(TreePath path, Object newValue)

Constructor Detail

DefaultTreeModel

public DefaultTreeModel()

DefaultTreeModel

public DefaultTreeModel(TreeNode root)

Method Detail

fireTreeNodesChanged

protected void fireTreeNodesChanged(Object source, Object[] path, int[] childIndices, Object[] children)
Notify all listeners of a node change.

Parameters: source the node being changed path the path to the root node childIndices the indices of the changed elements children the changed elements

fireTreeNodesInserted

protected void fireTreeNodesInserted(Object source, Object[] path, int[] childIndices, Object[] children)
Notify all listeners of structure change.

Parameters: source the node where new elements are being inserted path the path to the root node childIndices the indices of the new elements children the new elements

fireTreeNodesRemoved

protected void fireTreeNodesRemoved(Object source, Object[] path, int[] childIndices, Object[] children)
Notify all listeners of structure change.

Parameters: source the node where elements are being removed path the path to the root node childIndices the indices of the removed elements children the removed elements

fireTreeStructureChanged

protected void fireTreeStructureChanged(Object source, Object[] path, int[] childIndices, Object[] children)
Notify all listeners of structure change.

Parameters: source the node where the tree model has changed path the path to the root node childIndices the indices of the affected elements children the affected elements

fireTreeStructureChanged

protected void fireTreeStructureChanged(Object source, TreePath path)
Notify all listeners of structure change.

Parameters: source the node where the tree model has changed path the path to the root node

getChild

public Object getChild(Object parent, int index)

getChildCount

public int getChildCount(Object parent)

getIndexOfChild

public int getIndexOfChild(Object parent, Object child)

getPathToRoot

public TreeNode[] getPathToRoot(TreeNode node)
Collect all parent nodes up to the root node.

Parameters: node the TreeNode to get the path for

getPathToRoot

protected TreeNode[] getPathToRoot(TreeNode node, int depth)
Recursivly collect parent nodes up the the root node.

Parameters: node the TreeNode to get the path for depth number of steps already taken towards the root (on recursive calls)

Returns: an array giving the path from the root to the specified node

getRoot

public Object getRoot()

getTreeModelListeners

public Collection getTreeModelListeners()

isLeaf

public boolean isLeaf(Object node)

nodeChanged

public void nodeChanged(TreeNode node)
Invoke this method after you've changed how node is to be represented in the tree.

nodesChanged

public void nodesChanged(TreeNode node, int[] childIndices)
Invoke this method after you've changed how the children identified by childIndicies are to be represented in the tree.

nodesWereInserted

public void nodesWereInserted(TreeNode node, int[] childIndices)
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 void nodesWereRemoved(TreeNode node, int[] childIndices, Object[] removedChildren)
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.

nodeStructureChanged

public void nodeStructureChanged(TreeNode node)
Invoke this method if you've totally changed the children of node and its childrens children... This will post a treeStructureChanged event.

valueForPathChanged

public void valueForPathChanged(TreePath path, Object newValue)