|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.zul.AbstractTreeModel<TreeNode<E>>
org.zkoss.zul.DefaultTreeModel<E>
public class DefaultTreeModel<E>
A simple tree data model that uses TreeNode to represent a tree.
Thus the whole tree of data must be loaded into memory, and each node
must be represented by TreeNode.
If you want to implement a huge tree that only a visible part shall
be loaded, it is better to implement it by extending from
AbstractTreeModel.
DefaultTreeModel depends on TreeNode only.
It does not depend on DefaultTreeNode. However, DefaultTreeNode
depends on DefaultTreeModel.
For introduction, please refer to ZK Developer's Reference: Tree Model.
| Constructor Summary | |
|---|---|
DefaultTreeModel(TreeNode<E> root)
Creates a tree with the specified note as the root. |
|
| Method Summary | |
|---|---|
TreeNode<E> |
getChild(TreeNode<E> parent,
int index)
Returns the child of parent at index index in the parent's child array. |
int |
getChildCount(TreeNode<E> parent)
Returns the number of children of parent. |
int |
getIndexOfChild(TreeNode<E> parent,
TreeNode<E> child)
Returns the index of child in parent. |
boolean |
isLeaf(TreeNode<E> node)
Returns true if node is a leaf. |
void |
sort(java.util.Comparator<TreeNode<E>> cmpr,
boolean ascending)
Sorts the data. |
| Methods inherited from class org.zkoss.zul.AbstractTreeModel |
|---|
addSelection, addTreeDataListener, clearOpen, clearSelection, fireEvent, getPath, getRoot, getSelection, isOpen, removeAllSelection, removeSelection, removeTreeDataListener, retainAllSelection, setOpen |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultTreeModel(TreeNode<E> root)
root - the root (cannot be null).| Method Detail |
|---|
public boolean isLeaf(TreeNode<E> node)
TreeModel
isLeaf in interface TreeModel<TreeNode<E>>node - a node in the tree, obtained from this data source
public TreeNode<E> getChild(TreeNode<E> parent,
int index)
TreeModel
getChild in interface TreeModel<TreeNode<E>>parent - a node in the tree, obtained from this data source
public int getChildCount(TreeNode<E> parent)
TreeModel
getChildCount in interface TreeModel<TreeNode<E>>parent - a node in the tree, obtained from this data source
public int getIndexOfChild(TreeNode<E> parent,
TreeNode<E> child)
AbstractTreeModelThe default implementation iterates through all children of parent
by invoking, and check if child is part of them.
You could override it if you have a better algorithm.
TreeModel.getChild(E, int)
getIndexOfChild in interface TreeModel<TreeNode<E>>getIndexOfChild in class AbstractTreeModel<TreeNode<E>>parent - a node in the tree, obtained from this data sourcechild - the node we are interested in
public void sort(java.util.Comparator<TreeNode<E>> cmpr,
boolean ascending)
sort in interface TreeModelExt<TreeNode<E>>cmpr - the comparator.ascending - whether to sort in the ascending order.
It is ignored since this implementation uses cmprt to compare.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||