org.argouml.ui
Class TreeModelComposite

java.lang.Object
  extended byorg.argouml.ui.PerspectiveSupport
      extended byorg.argouml.ui.TreeModelSupport
          extended byorg.argouml.ui.TreeModelComposite
All Implemented Interfaces:
TreeModel
Direct Known Subclasses:
ToDoPerspective

public class TreeModelComposite
extends TreeModelSupport
implements TreeModel

This class is the TreeModel for the navigator and todo list panels.

It is called Composite because there are a set of rules that determine how to link parents to children in the tree. Those rules can now be found in PerspectiveSupport.


Field Summary
private static Logger LOG
           
private  Object root
          The root of the model.
 
Fields inherited from class org.argouml.ui.TreeModelSupport
 
Fields inherited from class org.argouml.ui.PerspectiveSupport
 
Constructor Summary
TreeModelComposite(String name)
          The constructor.
 
Method Summary
 Object getChild(Object parent, int index)
          Finds the each of the children of a parent in the tree.
 int getChildCount(Object parent)
           
 int getIndexOfChild(Object parent, Object child)
           
 Object getRoot()
          Getter for the root of the model.
 boolean isLeaf(Object node)
          Returns true if node is a leaf.
 void setRoot(Object r)
           
 void valueForPathChanged(TreePath path, Object newValue)
          Empty implementation - not used.
 
Methods inherited from class org.argouml.ui.TreeModelSupport
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, fireTreeStructureChanged, fireTreeStructureChanged, fireTreeStructureChanged, fireTreeStructureChanged, removeTreeModelListener
 
Methods inherited from class org.argouml.ui.PerspectiveSupport
addSubTreeModel, getGoRules, getName, getSubTreeModels, registerRule, removeSubTreeModel, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.swing.tree.TreeModel
addTreeModelListener, removeTreeModelListener
 

Field Detail

LOG

private static final Logger LOG

root

private Object root
The root of the model.

Constructor Detail

TreeModelComposite

public TreeModelComposite(String name)
The constructor.

Parameters:
name - the name that will be localized
Method Detail

getRoot

public Object getRoot()
Getter for the root of the model.

Specified by:
getRoot in interface TreeModel
See Also:
TreeModel.getRoot()

getChild

public Object getChild(Object parent,
                       int index)
Finds the each of the children of a parent in the tree.

Specified by:
getChild in interface TreeModel
Parameters:
parent - in the tree
index - of child to find
Returns:
the child found at index. Null if index is out of bounds.

getChildCount

public int getChildCount(Object parent)
Specified by:
getChildCount in interface TreeModel
See Also:
TreeModel.getChildCount(java.lang.Object)

getIndexOfChild

public int getIndexOfChild(Object parent,
                           Object child)
Specified by:
getIndexOfChild in interface TreeModel
See Also:
TreeModel.getIndexOfChild(java.lang.Object, java.lang.Object)

isLeaf

public boolean isLeaf(Object node)
Returns true if node is a leaf. It is possible for this method to return false even if node has no children. A directory in a filesystem, for example, may contain no files; the node representing the directory is not a leaf, but it also has no children.

If none of the subTreeModels is not a leaf, then we are not a leaf.

Specified by:
isLeaf in interface TreeModel
Parameters:
node - a node in the tree, obtained from this data source
Returns:
true if node is a leaf

valueForPathChanged

public void valueForPathChanged(TreePath path,
                                Object newValue)
Empty implementation - not used.

Messaged 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.

setRoot

public void setRoot(Object r)
Parameters:
r - the root of the model


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook