com.fullspan.pwkeep.model
Class PwkTreeModel

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by com.fullspan.pwkeep.model.PwkTreeModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.tree.TreeModel

public class PwkTreeModel
extends javax.swing.tree.DefaultTreeModel

The tree model that holds the hierarchy of PWKeep categories and items.

Version:
$Revision: 1.3 $, $Date: 2004/01/18 07:21:04 $
Author:
Mitch Stuart, $Author: mitch $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
PwkTreeModel(javax.swing.tree.TreeNode root)
           
 
Method Summary
 PwkTreeNode getRootNode()
           
 boolean isCategoryNameUnique(PwkTreeNode currentNode, java.lang.String categoryName)
          Checks if the category name is unique.
 boolean isItemNameUnique(PwkTreeNode catNode, PwkTreeNode itemNode, java.lang.String itemName)
          Checks if the item name is unique within its category.
static boolean isNameUnique(java.util.Enumeration nodes, PwkTreeNode currentNode, java.lang.String name)
          Check a node for uniqueness of its name.
 void sort()
          Sorts the tree by sorting the children of each node recursively.
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PwkTreeModel

public PwkTreeModel(javax.swing.tree.TreeNode root)
Method Detail

isNameUnique

public static boolean isNameUnique(java.util.Enumeration nodes,
                                   PwkTreeNode currentNode,
                                   java.lang.String name)
Check a node for uniqueness of its name.

Parameters:
nodes - an enumeration of nodes to compare against for uniqueness
currentNode - the current node - this is needed because a node having the same name as itself is considered unique
name - the name to check for uniqueness
Returns:
true if name is unique within nodes (with the exception of currentNode), false if not

getRootNode

public PwkTreeNode getRootNode()

isCategoryNameUnique

public boolean isCategoryNameUnique(PwkTreeNode currentNode,
                                    java.lang.String categoryName)
Checks if the category name is unique.

Parameters:
currentNode - the category node
categoryName - the category name
Returns:
true if the name is unique, false if not

isItemNameUnique

public boolean isItemNameUnique(PwkTreeNode catNode,
                                PwkTreeNode itemNode,
                                java.lang.String itemName)
Checks if the item name is unique within its category.

Parameters:
catNode - the category node
itemNode - the item node
itemName - the item name
Returns:
true if the name is unique within catNode, false if not

sort

public void sort()
Sorts the tree by sorting the children of each node recursively.

See Also:
PwkTreeNode.sortChildren(boolean)