SPT Core API

com.sptci.echo.tree
Class TreeModel<T extends Treeable>

java.lang.Object
  extended by nextapp.echo.extras.app.tree.AbstractTreeModel
      extended by com.sptci.echo.tree.TreeModel<T>
All Implemented Interfaces:
Serializable, TreeModel

public class TreeModel<T extends Treeable>
extends AbstractTreeModel

© Copyright 2009 Sans Pareil Technologies, Inc.

Version:
$Id: TreeModel.java 4853 2009-08-10 21:10:14Z rakesh $
Author:
Rakesh Vidyadharan 2009-2-1
See Also:
Serialized Form

Field Summary
protected  Root<T> root
          The root model object for this tree.
static String ROOT_NAME
          The default text to use as the name of Root object.
protected  List<T> roots
          The list of root level nodes in the tree.
 
Fields inherited from class nextapp.echo.extras.app.tree.AbstractTreeModel
listenerList
 
Constructor Summary
TreeModel(List<T> roots)
          Create a new tree model with the list of root level model objects.
TreeModel(List<T> roots, String rootName)
          Create a new tree model with the list of root level model objects and with a root node with the specified name.
TreeModel(Root<T> root)
          Create a new tree model with the specified root node.
 
Method Summary
 T getChild(Object parent, int index)
          Return the child at the specified index under the parent node in the tree.
 int getChildCount(Object parent)
          Return the number of children under the specified parent object.
 int getColumnCount()
          Return the number of columns displayed in the tree table.
 int getIndexOfChild(Object parent, Object child)
          Return the index for the specified child under the specified parent node in the tree.
 Object getRoot()
          Return the object that represents the root of the tree.
 Object getValueAt(Object node, int index)
          Return the value to display in the tree for the specified object at the specified column index.
 boolean isLeaf(Object object)
          Return true if the object (node) does not contain children.
 
Methods inherited from class nextapp.echo.extras.app.tree.AbstractTreeModel
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getColumnClass, getColumnName, removeTreeModelListener, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_NAME

public static final String ROOT_NAME
The default text to use as the name of Root object. ""

See Also:
Constant Field Values

root

protected final Root<T extends Treeable> root
The root model object for this tree.


roots

protected final List<T extends Treeable> roots
The list of root level nodes in the tree. A default root node will be used as the root of the tree.

Constructor Detail

TreeModel

public TreeModel(List<T> roots)
Create a new tree model with the list of root level model objects. Specify a list with size one if there is only one root level object in which case it will be returned by getRoot().

Parameters:
roots - The list of root level objects.

TreeModel

public TreeModel(List<T> roots,
                 String rootName)
Create a new tree model with the list of root level model objects and with a root node with the specified name.

Parameters:
roots - The list of root level objects.
rootName - The name to use for the dummy root node.

TreeModel

public TreeModel(Root<T> root)
Create a new tree model with the specified root node.

Parameters:
root - The root node for the tree.
Method Detail

getRoot

public Object getRoot()
Return the object that represents the root of the tree. Returns root if not null or the first element in the roots list.

Returns:
The object that represents the root of the tree.

getChild

public T getChild(Object parent,
                  int index)
Return the child at the specified index under the parent node in the tree.

Parameters:
parent - The parent node in the tree.
index - The index at which the child resides.
Returns:
The child treeable object.

getChildCount

public int getChildCount(Object parent)
Return the number of children under the specified parent object.

Parameters:
parent - The parent node in the tree.
Returns:
The number of children under the node.

isLeaf

public boolean isLeaf(Object object)
Return true if the object (node) does not contain children.

Parameters:
object - The object that represents the tree node.
Returns:
Return true if the node has children.

getIndexOfChild

public int getIndexOfChild(Object parent,
                           Object child)
Return the index for the specified child under the specified parent node in the tree.

Parameters:
parent - The parent node in the tree.
child - The child node in the tree.
Returns:
The index of the child.

getColumnCount

public int getColumnCount()
Return the number of columns displayed in the tree table. This model does not support tree tables and hence returns 1.

Returns:
Returns 1.

getValueAt

public Object getValueAt(Object node,
                         int index)
Return the value to display in the tree for the specified object at the specified column index. Note that this model does not support tree tables hence the index value is ignored.

Parameters:
node - The node whose display value is to be returned.
index - The column index in the tree table.
Returns:
Returns the display text.

SPT Core API