JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.treetable
Class BranchTree

java.lang.Object
  |
  +--com.klg.jclass.util.treetable.BranchTree
All Implemented Interfaces:
Serializable, TreeModel

public class BranchTree
extends Object
implements TreeModel, Serializable

Class to wrap a tree model so that it only exposes branches; that is, non- Leaf nodes. This is useful for Explorer-type views where the "tree view" portion only displays the branch nodes.

See Also:
Serialized Form

Field Summary
protected  com.klg.jclass.util.JCListenerList listeners
           
protected  TreeModel tree
           
 
Constructor Summary
BranchTree(TreeModel tree)
           
 
Method Summary
 void addTreeModelListener(TreeModelListener l)
          Adds the specified treemodel listener.
 Object getChild(Object parent, int index)
          Returns the "index"th non-leaf child of the parent node.
 int getChildCount(Object parent)
          Returns the count of non-leaf children.
 int getIndexOfChild(Object parent, Object child)
          Returns the non-leaf index of this child.
protected static Object getNode(TreePath path)
          Given a TreePath, this method returns the last component or "node" of the TreePath.
 Object getRoot()
          Returns the root node of the tree.
 boolean isLeaf(Object node)
          Returns true if the child is a leaf.
 void removeTreeModelListener(TreeModelListener l)
          Removes the specified treemodel listener
 void valueForPathChanged(TreePath path, Object newValue)
          Called when the user has altered the value for the item identified by path to newValue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tree

protected TreeModel tree

listeners

protected com.klg.jclass.util.JCListenerList listeners
Constructor Detail

BranchTree

public BranchTree(TreeModel tree)
Method Detail

addTreeModelListener

public void addTreeModelListener(TreeModelListener l)
Adds the specified treemodel listener.

Specified by:
addTreeModelListener in interface TreeModel
Parameters:
l - The treemodel listener to add

removeTreeModelListener

public void removeTreeModelListener(TreeModelListener l)
Removes the specified treemodel listener

Specified by:
removeTreeModelListener in interface TreeModel
Parameters:
l - The treemodel listener to remove

getChild

public Object getChild(Object parent,
                       int index)
Returns the "index"th non-leaf child of the parent node.

Specified by:
getChild in interface TreeModel
Parameters:
parent - The parent node
index - The index of the child to get
Returns:
The "index"th child of the given parent

getChildCount

public int getChildCount(Object parent)
Returns the count of non-leaf children.

Specified by:
getChildCount in interface TreeModel
Parameters:
parent - The parent node
Returns:
The count of non-leaf children for the given parent

getIndexOfChild

public int getIndexOfChild(Object parent,
                           Object child)
Returns the non-leaf index of this child.

Specified by:
getIndexOfChild in interface TreeModel
Parameters:
parent - The parent node
child - The child whose index is required
Returns:
The non-leaf index of the child of the given parent

getRoot

public Object getRoot()
Returns the root node of the tree.

Specified by:
getRoot in interface TreeModel
Returns:
The root node

isLeaf

public boolean isLeaf(Object node)
Returns true if the child is a leaf.

Specified by:
isLeaf in interface TreeModel
Parameters:
node - The node to check
Returns:
Is the given node a leaft?

valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)
Called when the user has altered the value for the item identified by path to newValue. If newValue signifies a truly new value the model should post a treeNodesChanged event.

Specified by:
valueForPathChanged in interface TreeModel
Parameters:
path - path to the node that the user has altered
newValue - the new value from the TreeCellEditor

getNode

protected static Object getNode(TreePath path)
Given a TreePath, this method returns the last component or "node" of the TreePath.

Parameters:
path - The path from which to get the node
Returns:
The node (i.e. last path component) of the given path

Copyright © 2004 Quest Software Inc..
All rights reserved.