edu.northwestern.at.utils.swing
Class SortedTreeModel

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by edu.northwestern.at.utils.swing.SortedTreeModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.tree.TreeModel

public class SortedTreeModel
extends javax.swing.tree.DefaultTreeModel

Sorted tree model.

This class extends DefaultTreeModel to support sorted trees.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
SortedTreeModel(SortedTreeNode root)
          Creates a tree in which any node can have children.
SortedTreeModel(SortedTreeNode root, boolean asksAllowsChildren)
          Creates a tree specifying whether any node can have children, or whether only certain nodes can have children.
 
Method Summary
 int getNodeCount()
          Gets the node count.
 void insertNodeInto(javax.swing.tree.MutableTreeNode newChild, javax.swing.tree.MutableTreeNode parent, int index)
          Prohibits attempts to add children at specific locations.
 void insertNodeInto(SortedTreeNode newChild, SortedTreeNode parent)
          Adds a new child node, in the proper sorted position.
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
          Prohibits attempts to set a new node value.
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortedTreeModel

public SortedTreeModel(SortedTreeNode root)
Creates a tree in which any node can have children.

Parameters:
root - The root of the tree.

SortedTreeModel

public SortedTreeModel(SortedTreeNode root,
                       boolean asksAllowsChildren)
Creates a tree specifying whether any node can have children, or whether only certain nodes can have children.

Parameters:
root - The root of the tree.
asksAllowsChildren - See Sun's javadoc.
Method Detail

insertNodeInto

public void insertNodeInto(SortedTreeNode newChild,
                           SortedTreeNode parent)
Adds a new child node, in the proper sorted position.

Parameters:
newChild - The new child node.
parent - The parent node.

getNodeCount

public int getNodeCount()
Gets the node count.

Returns:
The total number of nodes in the tree, not counting the root node.

insertNodeInto

public void insertNodeInto(javax.swing.tree.MutableTreeNode newChild,
                           javax.swing.tree.MutableTreeNode parent,
                           int index)
Prohibits attempts to add children at specific locations.

Overrides:
insertNodeInto in class javax.swing.tree.DefaultTreeModel
Throws:
java.lang.UnsupportedOperationException

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Prohibits attempts to set a new node value.

Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel
Overrides:
valueForPathChanged in class javax.swing.tree.DefaultTreeModel
Throws:
java.lang.UnsupportedOperationException