com.sun.electric.tool.user.ui
Class ExplorerTreeModel

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by com.sun.electric.tool.user.ui.ExplorerTreeModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.tree.TreeModel

public class ExplorerTreeModel
extends javax.swing.tree.DefaultTreeModel

Model of a cell explorer tree-view of the database.

See Also:
Serialized Form

Field Summary
static java.lang.String rootNode
           
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Method Summary
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
          Adds a listener for the TreeModelEvent posted after the tree changes.
 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.
 javax.swing.tree.TreeNode[] getPathToRoot(javax.swing.tree.TreeNode aNode)
          Builds the parents of node up to and including the root node, where the original node is the last element in the returned array.
protected  javax.swing.tree.TreeNode[] getPathToRoot(javax.swing.tree.TreeNode aNode, int depth)
          Builds the parents of node up to and including the root node, where the original node is the last element in the returned array.
 java.lang.Object getRoot()
          Returns the root of the tree.
 boolean isLeaf(java.lang.Object node)
          Returns true if node is a leaf.
static javax.swing.tree.DefaultMutableTreeNode makeLibraryTree()
           
 void nodesChanged(java.lang.Object[] path, int[] childIndices)
          Invoke this method after you've changed how the children identified by childIndicies are to be represented in the tree.
 void nodesWereInserted(java.lang.Object[] path, int[] childIndices)
          Invoke this method after you've inserted some TreeNodes into node.
 void nodesWereRemoved(java.lang.Object[] path, int[] childIndices, java.lang.Object[] removedChildren)
          Invoke this method after you've removed some TreeNodes from node.
 void reload(java.lang.Object[] path)
          Invoke this method if you've modified the TreeNodes upon which this model depends.
 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)
          Messaged when the user has altered the value for the item identified by path to newValue.
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getListeners, getTreeModelListeners, insertNodeInto, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, setAsksAllowsChildren, setRoot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rootNode

public static final java.lang.String rootNode
See Also:
Constant Field Values
Method Detail

getRoot

public java.lang.Object getRoot()
Returns the root of the tree. Returns null only if the tree has no nodes.

Specified by:
getRoot in interface javax.swing.tree.TreeModel
Overrides:
getRoot in class javax.swing.tree.DefaultTreeModel
Returns:
the root of the tree

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
Overrides:
getChild in class javax.swing.tree.DefaultTreeModel
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
Overrides:
getChildCount in class javax.swing.tree.DefaultTreeModel
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 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.

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

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
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 javax.swing.tree.TreeModel
Overrides:
valueForPathChanged in class javax.swing.tree.DefaultTreeModel
Parameters:
path - path to the node that the user has altered
newValue - the new value from the TreeCellEditor

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Returns the index of child in parent. If either parent or child is null, returns -1. If either parent or child don't belong to this tree model, returns -1.

Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel
Overrides:
getIndexOfChild in class javax.swing.tree.DefaultTreeModel
Parameters:
parent - a note in the tree, obtained from this data source
child - the node we are interested in
Returns:
the index of the child in the parent, or -1 if either child or parent are null or don't belong to this tree model

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)
Adds a listener for the TreeModelEvent posted after the tree changes.

Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel
Overrides:
addTreeModelListener in class javax.swing.tree.DefaultTreeModel
Parameters:
l - the listener to add
See Also:
removeTreeModelListener(javax.swing.event.TreeModelListener)

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
Overrides:
removeTreeModelListener in class javax.swing.tree.DefaultTreeModel
Parameters:
l - the listener to remove
See Also:
addTreeModelListener(javax.swing.event.TreeModelListener)

reload

public void reload(java.lang.Object[] path)
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 below the node node (PENDING).


nodesWereInserted

public void nodesWereInserted(java.lang.Object[] path,
                              int[] childIndices)
Invoke this method after you've inserted some TreeNodes into node. childIndices should be the index of the new elements and must be sorted in ascending order.


nodesWereRemoved

public void nodesWereRemoved(java.lang.Object[] path,
                             int[] childIndices,
                             java.lang.Object[] removedChildren)
Invoke this method after you've removed some TreeNodes from node. childIndices should be the index of the removed elements and must be sorted in ascending order. And removedChildren should be the array of the children objects that were removed.


nodesChanged

public void nodesChanged(java.lang.Object[] path,
                         int[] childIndices)
Invoke this method after you've changed how the children identified by childIndicies are to be represented in the tree.


getPathToRoot

public javax.swing.tree.TreeNode[] getPathToRoot(javax.swing.tree.TreeNode aNode)
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. The length of the returned array gives the node's depth in the tree.

Overrides:
getPathToRoot in class javax.swing.tree.DefaultTreeModel
Parameters:
aNode - the TreeNode to get the path for

getPathToRoot

protected javax.swing.tree.TreeNode[] getPathToRoot(javax.swing.tree.TreeNode aNode,
                                                    int depth)
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array. The length of the returned array gives the node's depth in the tree.

Overrides:
getPathToRoot in class javax.swing.tree.DefaultTreeModel
Parameters:
aNode - the TreeNode to get the path for
depth - an int giving the number of steps already taken towards the root (on recursive calls), used to size the returned array
Returns:
an array of TreeNodes giving the path from the root to the specified node

makeLibraryTree

public static javax.swing.tree.DefaultMutableTreeNode makeLibraryTree()