net.sourceforge.esw.widgets.tree
Class NodeTreeModel

java.lang.Object
  |
  +--net.sourceforge.esw.widgets.tree.NodeTreeModel
All Implemented Interfaces:
javax.swing.tree.TreeModel

public class NodeTreeModel
extends java.lang.Object
implements javax.swing.tree.TreeModel

The Tree Model mediating INode instances and Swing JTree's.

See Also:
INode

Constructor Summary
NodeTreeModel(INode aRoot)
          Creates new DefaultTreeModel with the specified INode as the root of the tree.
 
Method Summary
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
          Invoke this method after you've changed how node is to be represented in the tree.
 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 getIndexOfChild(java.lang.Object parent, java.lang.Object child)
          Returns the index of child in parent.
 java.lang.Object getRoot()
          Sets the root to root.
 boolean isLeaf(java.lang.Object node)
          Returns whether the specified node is a leaf node.
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
          Removes a listener previously added with addTreeModelListener().
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
          Invoke this method if you've modified the TreeNodes upon which this model depends.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeTreeModel

public NodeTreeModel(INode aRoot)
Creates new DefaultTreeModel with the specified INode as the root of the tree.
Parameters:
aRoot - an INode instance that is the root of the tree.
Method Detail

getRoot

public java.lang.Object getRoot()
Sets the root to root. This will throw an IllegalArgumentException if root is null.
Specified by:
getRoot in interface javax.swing.tree.TreeModel
Parameters:
aRoot - an INode instance that is the root of the tree.

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Returns the index of child in parent.
Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Returns the child of parent at index index in the parent's child array. parent must be a node previously obtained from this data source. This should not return null if index is a valid index for parent (that is index >= 0 && index < getChildCount(parent)).
Specified by:
getChild in interface javax.swing.tree.TreeModel
Parameters:
parent - a node in the tree, obtained from this data source
Returns:
the child of parent at index index

getChildCount

public int getChildCount(java.lang.Object parent)
Returns the number of children of parent. Returns 0 if the node is a leaf or if it has no children. parent must be a node previously obtained from this data source.
Specified by:
getChildCount in interface javax.swing.tree.TreeModel
Parameters:
parent - a node in the tree, obtained from this data source
Returns:
the number of children of the node parent

isLeaf

public boolean isLeaf(java.lang.Object node)
Returns whether the specified node is a leaf node.
Specified by:
isLeaf in interface javax.swing.tree.TreeModel
Parameters:
node - the node to check
Returns:
true if the node is a leaf node
See Also:
TreeModel.isLeaf(java.lang.Object)

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Invoke this method if you've modified the TreeNodes upon which this model depends. The model will notify all of its listeners that the model has changed.
Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)
Invoke this method after you've changed how node is to be represented in the tree.
Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
Removes a listener previously added with addTreeModelListener().
Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel
Parameters:
l - the listener to remove
See Also:
addTreeModelListener(javax.swing.event.TreeModelListener)


Copyright 2002 Free Software Foundation. All Rights Reserved.