edu.northwestern.at.wordhoard.swing.tcon
Class TreeNode

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by edu.northwestern.at.wordhoard.swing.tcon.TreeNode
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

public class TreeNode
extends javax.swing.tree.DefaultMutableTreeNode

A table of contents tree node.

There are three types of nodes in table of contents trees:

See Also:
Serialized Form

Field Summary
static int CATEGORY_NODE
          A category node.
static int PLACEHOLDER_NODE
          A placeholder node.
static int WORK_PART_NODE
          A work part node.
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
TreeNode(java.lang.String categoryTitle, TableOfContentsPanel parentPanel)
          Creates a new category node.
TreeNode(TableOfContentsPanel parentPanel)
          Creates a new placeholder node.
TreeNode(WorkPart workPart, TableOfContentsPanel parentPanel)
          Creates a new unloaded work part node.
 
Method Summary
 TreeNode addCategoryNode(java.lang.String categoryTitle)
          Adds a new category node as a child of this node.
 void addUnloadedWorkPartNode(TreeNode node)
          Adds an unloaded work part node as a child of this node.
 TreeNode addUnloadedWorkPartNode(WorkPart workPart)
          Creates and adds a new unloaded work part node as a child of this node.
 int getNodeType()
          Gets the node type.
 WorkPart getWorkPart()
          Gets the work part.
 boolean isLoaded()
          Returns true if the node is loaded.
 void setLoaded(boolean loaded)
          Sets the node loaded attribute.
 java.lang.String toString()
          Returns a string representation of the node.
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CATEGORY_NODE

public static final int CATEGORY_NODE
A category node.

See Also:
Constant Field Values

WORK_PART_NODE

public static final int WORK_PART_NODE
A work part node.

See Also:
Constant Field Values

PLACEHOLDER_NODE

public static final int PLACEHOLDER_NODE
A placeholder node.

See Also:
Constant Field Values
Constructor Detail

TreeNode

public TreeNode(java.lang.String categoryTitle,
                TableOfContentsPanel parentPanel)
Creates a new category node.

Parameters:
categoryTitle - Category title.
parentPanel - The parent table of contents panel.

TreeNode

public TreeNode(WorkPart workPart,
                TableOfContentsPanel parentPanel)
Creates a new unloaded work part node.

Parameters:
workPart - The work part.
parentPanel - The parent table of contents panel.

TreeNode

public TreeNode(TableOfContentsPanel parentPanel)
Creates a new placeholder node.

Parameters:
parentPanel - The parent table of contents panel.
Method Detail

getNodeType

public int getNodeType()
Gets the node type.

Returns:
The node type.

getWorkPart

public WorkPart getWorkPart()
Gets the work part.

Returns:
The work part, or null if category or placeholder node.

isLoaded

public boolean isLoaded()
Returns true if the node is loaded.

Returns:
True if node is loaded.

setLoaded

public void setLoaded(boolean loaded)
Sets the node loaded attribute.

Parameters:
loaded - True if the node is loaded.

addCategoryNode

public TreeNode addCategoryNode(java.lang.String categoryTitle)
Adds a new category node as a child of this node.

Parameters:
categoryTitle - Category title.
Returns:
The new category node.

addUnloadedWorkPartNode

public void addUnloadedWorkPartNode(TreeNode node)
Adds an unloaded work part node as a child of this node.

Parameters:
node - Work part node.

addUnloadedWorkPartNode

public TreeNode addUnloadedWorkPartNode(WorkPart workPart)
Creates and adds a new unloaded work part node as a child of this node.

Parameters:
workPart - Work part.
Returns:
The new work part node.

toString

public java.lang.String toString()
Returns a string representation of the node.

Overrides:
toString in class javax.swing.tree.DefaultMutableTreeNode
Returns:
The node title: The category title, the work part title, or an empty string for placeholder nodes. Work parts may have the work part tag appended if requested, and works may have the author(s) and publication date appended as well.