org.zkoss.zul
Interface TreeModel

All Known Implementing Classes:
AbstractTreeModel, SimpleTreeModel

public interface TreeModel

This interface defines the methods that component like Tree use to get the content of items.

Note: changing a render will not cause the tree to re-render. If you want it to re-render, you could assign the same model again (i.e., setModel(getModel())), or fire an TreeDataEvent event.

Since:
ZK 3.0.0
Author:
Jeff Liu

Method Summary
 void addTreeDataListener(TreeDataListener l)
          Add a listener to the tree that's notified each time a change to the data model occurs
 java.lang.Object getChild(java.lang.Object parent, int index)
          Returns the child of parent at index index in the parent's child array.
 int getChildCount(java.lang.Object parent)
          Returns the number of children of parent.
 int[] getPath(java.lang.Object parent, java.lang.Object lastNode)
          Returns an integer array to represent the path from parent(exclusive) to lastNode(inclusive).
 java.lang.Object getRoot()
          Returns the root of the tree.
 boolean isLeaf(java.lang.Object node)
          Returns true if node is a leaf.
 void removeTreeDataListener(TreeDataListener l)
          Remove a listener to the tree that's notified each time a change to the data model occurs
 

Method Detail

isLeaf

boolean isLeaf(java.lang.Object node)
Returns true if node is a leaf.

Parameters:
node - a node in the tree, obtained from this data source
Returns:
true if node is a leafs

getChild

java.lang.Object getChild(java.lang.Object parent,
                          int index)
Returns the child of parent at index index in the parent's child array.

Parameters:
parent - a node in the tree, obtained from this data source
Returns:
the child of parent at index index

getChildCount

int getChildCount(java.lang.Object parent)
Returns the number of children of parent.

Parameters:
parent - a node in the tree, obtained from this data source
Returns:
the number of children of the node parent

getRoot

java.lang.Object getRoot()
Returns the root of the tree.

Returns:
the root of Tree.

addTreeDataListener

void addTreeDataListener(TreeDataListener l)
Add a listener to the tree that's notified each time a change to the data model occurs

Parameters:
l - the listener to add

removeTreeDataListener

void removeTreeDataListener(TreeDataListener l)
Remove a listener to the tree that's notified each time a change to the data model occurs

Parameters:
l - the listener to remove

getPath

int[] getPath(java.lang.Object parent,
              java.lang.Object lastNode)
Returns an integer array to represent the path from parent(exclusive) to lastNode(inclusive).
notice:
The path has to be in "parent" to "lastNode" order
Ex: {1,0,2}
1. Go to the parent's child at index(1);
2. Go to the index(1)'s child at index(0);
3. Go to the index(0)'s child at idnex(2) -- the lastNode;
If parent is the same as lastNode, return null or empty array.

Parameters:
parent - the origin of Path
lastNode - the destination of Path
Returns:
an integer array to represent the path from parent to lastNode.


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo