org.norvelle.textcite.gui.outlook_bar
Class AuthorPubTreeModel

java.lang.Object
  extended by org.norvelle.textcite.gui.outlook_bar.AuthorPubTreeModel
All Implemented Interfaces:
javax.swing.tree.TreeModel, ListModelChangeListener

public class AuthorPubTreeModel
extends java.lang.Object
implements javax.swing.tree.TreeModel, ListModelChangeListener

AuthorPubTreeModel: Provides a TreeModel for browing and displaying Authors and Publications in a tree view

Author:
Erik Norvelle

Field Summary
protected  java.util.HashMap<java.lang.Object,AuthorPubTreeNode> bookNodes
           
protected  CiteBook citebook
           
protected  javax.swing.event.EventListenerList listenerList
           
protected  AuthorPubTreeNode root
           
 
Constructor Summary
AuthorPubTreeModel()
          Generate the TreeModel, meaning basically creating a Root node and saving it.
 
Method Summary
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
           
protected  AuthorPubTreeNode findNode(java.lang.Object data)
          Given an integer position of a node, and a sending object collection, figure out the AuthorPubNode that corresponds to the position and return it.
 void fireContentsChanged(java.lang.Object sender, java.lang.Object data, int pos, int pos2)
          Figure out who the sender was, and depending on the object type that has changed, update the tree model appropriately, and fire notifications to listeners.
 void fireIntervalAdded(java.lang.Object sender, java.lang.Object data, int pos, int pos2)
          Figure out who the sender was, and depending on the object type that has been added, insert the corresponding tree node, and fire notifications to listeners.
 void fireIntervalRemoved(java.lang.Object sender, java.lang.Object data, int pos, int pos2)
          Figure out who the sender was, and depending on the object type that has been removed, eliminate the corresponding tree nodes, and fire notifications to listeners.
protected  void fireTreeNodesChanged(java.lang.Object source, java.lang.Object[] path, int[] childIndices, java.lang.Object[] children)
          Notifies all listeners that have registered interest for notification on this event type.
 java.lang.Object getChild(java.lang.Object node, int pos)
           
 int getChildCount(java.lang.Object node)
           
 int getIndexOfChild(java.lang.Object node, java.lang.Object child)
           
 java.lang.Object getRoot()
          Returns the root node.
 boolean isLeaf(java.lang.Object node)
           
 javax.swing.tree.TreePath nodeToPath(AuthorPubTreeNode node)
          Produce a TreePath to the given node
 void registerBookNode(AuthorPubTreeNode node)
           
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
           
 void unregisterBookNode(AuthorPubTreeNode node)
           
 void valueForPathChanged(javax.swing.tree.TreePath arg0, java.lang.Object arg1)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected AuthorPubTreeNode root

listenerList

protected javax.swing.event.EventListenerList listenerList

citebook

protected CiteBook citebook

bookNodes

protected java.util.HashMap<java.lang.Object,AuthorPubTreeNode> bookNodes
Constructor Detail

AuthorPubTreeModel

public AuthorPubTreeModel()
Generate the TreeModel, meaning basically creating a Root node and saving it.

Method Detail

registerBookNode

public void registerBookNode(AuthorPubTreeNode node)

unregisterBookNode

public void unregisterBookNode(AuthorPubTreeNode node)

getRoot

public java.lang.Object getRoot()
Returns the root node.

Specified by:
getRoot in interface javax.swing.tree.TreeModel

getChild

public java.lang.Object getChild(java.lang.Object node,
                                 int pos)
Specified by:
getChild in interface javax.swing.tree.TreeModel
Returns:
the child of the node at position 'pos'

getChildCount

public int getChildCount(java.lang.Object node)
Specified by:
getChildCount in interface javax.swing.tree.TreeModel
Returns:
the number of children of the given node

isLeaf

public boolean isLeaf(java.lang.Object node)
Specified by:
isLeaf in interface javax.swing.tree.TreeModel
Returns:
true if the node is a leaf, false otherwise

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath arg0,
                                java.lang.Object arg1)
Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel

getIndexOfChild

public int getIndexOfChild(java.lang.Object node,
                           java.lang.Object child)
Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel
Returns:
the index of the child in the nodes children list

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel

nodeToPath

public javax.swing.tree.TreePath nodeToPath(AuthorPubTreeNode node)
Produce a TreePath to the given node

Parameters:
node - The node which will terminate the TreePath
Returns:
A TreePath beginning at the root and terminating in the given node

findNode

protected AuthorPubTreeNode findNode(java.lang.Object data)
Given an integer position of a node, and a sending object collection, figure out the AuthorPubNode that corresponds to the position and return it.

Parameters:
sender - The collection object that sent the event
pos - The position in the collection of the object causing the event
Returns:
The AuthorPubTreeNode corresponding to the position.

fireContentsChanged

public void fireContentsChanged(java.lang.Object sender,
                                java.lang.Object data,
                                int pos,
                                int pos2)
Figure out who the sender was, and depending on the object type that has changed, update the tree model appropriately, and fire notifications to listeners.

Specified by:
fireContentsChanged in interface ListModelChangeListener
data - TODO

fireIntervalRemoved

public void fireIntervalRemoved(java.lang.Object sender,
                                java.lang.Object data,
                                int pos,
                                int pos2)
Figure out who the sender was, and depending on the object type that has been removed, eliminate the corresponding tree nodes, and fire notifications to listeners.

Specified by:
fireIntervalRemoved in interface ListModelChangeListener
data - TODO

fireIntervalAdded

public void fireIntervalAdded(java.lang.Object sender,
                              java.lang.Object data,
                              int pos,
                              int pos2)
Figure out who the sender was, and depending on the object type that has been added, insert the corresponding tree node, and fire notifications to listeners.

Specified by:
fireIntervalAdded in interface ListModelChangeListener
data - TODO

fireTreeNodesChanged

protected void fireTreeNodesChanged(java.lang.Object source,
                                    java.lang.Object[] path,
                                    int[] childIndices,
                                    java.lang.Object[] children)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

Parameters:
source - the node being changed
path - the path to the root node
childIndices - the indices of the changed elements
children - the changed elements
See Also:
EventListenerList