org.norvelle.textcite.model
Class BookOutlineTree

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

public class BookOutlineTree
extends java.lang.Object
implements TreeModelAdaptee

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

Author:
Erik Norvelle

Nested Class Summary
static class BookOutlineTree.BookOutlineTreeConverter
          BookOutlineTreeConverter is an inner class used for serializing BookOutlineTree objects via XStream.
 
Constructor Summary
protected BookOutlineTree()
          A parameterless constructor, so that we can recreate a serialized BookOutlineTree from XML.
  BookOutlineTree(Book parentBook)
          Default constructor.
 
Method Summary
 void addAdapter(TreeModelAdapter adapter)
           
 void clear()
          Clears the BookOutlineItemTree of all members.
 void debugOutputTree(javax.swing.tree.TreeNode node, int startLevel)
           
 Book getParentBook()
           
 BookOutlineItem getRoot()
           
 int getSize()
           
 void moveBookOutlineItem(BookOutlineItem item, BookOutlineItem newParent, BookOutlineItem priorSibling, boolean asFirst)
          Move a given BookOutlineItem from its current position, to be the child of the given parent (at the position indicated).
 void moveBookOutlineItem(BookOutlineItem item, BookOutlineItem newParent, boolean asFirst)
          Move a given BookOutlineItem from its current position, to be the child of the given parent (either in the last position or the first, based on the asFirst parameter)
 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 registerBookOutlineItem(BookOutlineItem newItem, BookOutlineItem parent, BookOutlineItem priorSibling, boolean asFirst)
          Insert a new BookOutlineItem 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 setParentBook(Book parentBook)
           
 void unregisterBookOutlineItem(BookOutlineItem item)
          Remove a given BookOutlineItem from the tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BookOutlineTree

public BookOutlineTree(Book parentBook)
Default constructor. Builds a one-node tree with a dummy BookOutlineItem as its root. Registers the outline with the given book.


BookOutlineTree

protected BookOutlineTree()
A parameterless constructor, so that we can recreate a serialized BookOutlineTree from XML. Visible only to the inner classes and derived classes.

Method Detail

registerBookOutlineItem

public void registerBookOutlineItem(BookOutlineItem newItem,
                                    BookOutlineItem parent,
                                    BookOutlineItem priorSibling,
                                    boolean asFirst)
Insert a new BookOutlineItem into the tree, under the indicated parent node.

Parameters:
newItem - The new BookOutlineItem to be inserted
parent - The parent BookOutlineItem for the new node.
priorSibling - The BookOutlineItem *after which* the current new item should be added
asFirst - If true, insert the new item as the first child of the parent.

unregisterBookOutlineItem

public void unregisterBookOutlineItem(BookOutlineItem item)
Remove a given BookOutlineItem from the tree.

Parameters:
item - The BookOutlineItem to be removed.

moveBookOutlineItem

public void moveBookOutlineItem(BookOutlineItem item,
                                BookOutlineItem newParent,
                                BookOutlineItem priorSibling,
                                boolean asFirst)
Move a given BookOutlineItem from its current position, to be the child of the given parent (at the position indicated).

Parameters:
item - The BookOutlineItem to be moved.
newParent - The BookOutlineItem which will be the new parent.
priorSibling - The BookOutlineItem *after which* the moved item should be added
asFirst - If true, insert the moved item as the first child of the parent.

moveBookOutlineItem

public void moveBookOutlineItem(BookOutlineItem item,
                                BookOutlineItem newParent,
                                boolean asFirst)
Move a given BookOutlineItem from its current position, to be the child of the given parent (either in the last position or the first, based on the asFirst parameter)

Parameters:
item - The BookOutlineItem to be moved.
newParent - The BookOutlineItem which will be the new parent.
asFirst - If true, insert the moved item as the first child of the parent.

clear

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


getSize

public int getSize()

debugOutputTree

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

getRoot

public BookOutlineItem getRoot()

getParentBook

public Book getParentBook()

setParentBook

public void setParentBook(Book parentBook)

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.