org.zkoss.zul
Class AbstractTreeModel

java.lang.Object
  extended by org.zkoss.zul.AbstractTreeModel
All Implemented Interfaces:
java.io.Serializable, TreeModel
Direct Known Subclasses:
SimpleTreeModel

public abstract class AbstractTreeModel
extends java.lang.Object
implements TreeModel, java.io.Serializable

A skeletal implementation for TreeModel.

Since:
ZK 3.0.0
Author:
Jeff Liu
See Also:
Serialized Form

Constructor Summary
AbstractTreeModel(java.lang.Object root)
          Constructor
 
Method Summary
 void addTreeDataListener(TreeDataListener l)
          Add a listener to the tree that's notified each time a change to the data model occurs
protected  void fireEvent(java.lang.Object node, int indexFrom, int indexTo, int evtType)
          Fires a TreeDataEvent for all registered listener Note: you can invoke this method only in an event listener.
 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()
          Return the root of tree
 void removeTreeDataListener(TreeDataListener l)
          Remove a listener to the tree that's notified each time a change to the data model occurs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.zkoss.zul.TreeModel
getChild, getChildCount, isLeaf
 

Constructor Detail

AbstractTreeModel

public AbstractTreeModel(java.lang.Object root)
Constructor

Parameters:
root - - root of tree
Method Detail

getRoot

public java.lang.Object getRoot()
Return the root of tree

Specified by:
getRoot in interface TreeModel
Returns:
the root of tree

fireEvent

protected void fireEvent(java.lang.Object node,
                         int indexFrom,
                         int indexTo,
                         int evtType)
Fires a TreeDataEvent for all registered listener

Note: you can invoke this method only in an event listener.


getPath

public int[] getPath(java.lang.Object parent,
                     java.lang.Object lastNode)
Description copied from interface: TreeModel
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.

Specified by:
getPath in interface TreeModel
Parameters:
parent - the origin of Path
lastNode - the destination of Path
Returns:
an integer array to represent the path from parent to lastNode.

addTreeDataListener

public void addTreeDataListener(TreeDataListener l)
Description copied from interface: TreeModel
Add a listener to the tree that's notified each time a change to the data model occurs

Specified by:
addTreeDataListener in interface TreeModel
Parameters:
l - the listener to add

removeTreeDataListener

public void removeTreeDataListener(TreeDataListener l)
Description copied from interface: TreeModel
Remove a listener to the tree that's notified each time a change to the data model occurs

Specified by:
removeTreeDataListener in interface TreeModel
Parameters:
l - the listener to remove


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