org.norvelle.textcite.model
Class CategoryTree

java.lang.Object
  extended by org.norvelle.textcite.model.CategoryTree
All Implemented Interfaces:
TreeModelAdaptee

public class CategoryTree
extends java.lang.Object
implements TreeModelAdaptee

The CategoryTree stores all the currently defined Category objects in the Citebook. It is derived from DefaultTreeModel in order to easily be able to serve as the Model for the Category tree in the OutlookPane. It also maintains a HashMap of the Category objects, stored by their ids.

Author:
Erik Norvelle

Nested Class Summary
static class CategoryTree.CategoryTreeConverter
          CategoryTreeConverter is an inner class used for serializing CategoryTree objects via XStream.
 
Constructor Summary
CategoryTree()
          Default constructor.
 
Method Summary
 void addAdapter(TreeModelAdapter adapter)
           
 void clear()
          Clears the CategoryTree of all members.
 void debugOutputTree(javax.swing.tree.TreeNode node, int startLevel)
           
 java.lang.Object getRoot()
           
 int getSize()
           
 void nodeChanged(javax.swing.tree.TreeNode node)
           
 void recreateAdapterCollection()
          After loading a new file, the AdapterCollection (which is marked as transient) will not be recreated during the deserialization process.
 void registerCategory(Category cat, Category parent)
          Insert a new Category into the tree, under the indicated parent node.
 void removeAdapter(TreeModelAdapter adapter)
           
 void restoreCitationReferences()
          After deserializing the Books, each Book object needs to rebuild its HashMap of references to the Citations registered for the author.
 void unregisterCategory(Category cat)
          Remove a given Category from the tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CategoryTree

public CategoryTree()
Default constructor. Builds a one-node tree with a dummy Category as its root.

Method Detail

registerCategory

public void registerCategory(Category cat,
                             Category parent)
Insert a new Category into the tree, under the indicated parent node.

Parameters:
cat - The new Category to be inserted
parent - The parent Category for the new node.

unregisterCategory

public void unregisterCategory(Category cat)
Remove a given Category from the tree.

Parameters:
cat - The Category to be removed.

clear

public void clear()
Clears the CategoryTree of all members.


getSize

public int getSize()

debugOutputTree

public void debugOutputTree(javax.swing.tree.TreeNode node,
                            int startLevel)

getRoot

public java.lang.Object getRoot()

nodeChanged

public void nodeChanged(javax.swing.tree.TreeNode node)

addAdapter

public void addAdapter(TreeModelAdapter adapter)
Specified by:
addAdapter in interface TreeModelAdaptee

removeAdapter

public void removeAdapter(TreeModelAdapter adapter)
Specified by:
removeAdapter in interface TreeModelAdaptee

recreateAdapterCollection

public void recreateAdapterCollection()
After loading a new file, the AdapterCollection (which is marked as transient) will not be recreated during the deserialization process. This procedure needs to be called to recreate an emtpy AdapterCollection.

Specified by:
recreateAdapterCollection in interface TreeModelAdaptee

restoreCitationReferences

public void restoreCitationReferences()
After deserializing the Books, each Book object needs to rebuild its HashMap of references to the Citations registered for the author.