ca.sqlpower.architect.swingui
Class DBTreeModel

java.lang.Object
  extended by ca.sqlpower.architect.swingui.DBTreeModel
All Implemented Interfaces:
SQLObjectListener, java.io.Serializable, javax.swing.tree.TreeModel

public class DBTreeModel
extends java.lang.Object
implements javax.swing.tree.TreeModel, SQLObjectListener, java.io.Serializable

See Also:
Serialized Form

Field Summary
protected  SQLObject root
           
protected  java.util.LinkedList treeModelListeners
           
 
Constructor Summary
DBTreeModel(ArchitectSession session)
           
DBTreeModel(ArchitectSession session, SQLObjectRoot root)
          Creates a tree model with all of the SQLDatabase objects in the given session's root object in its root list of databases.
 
Method Summary
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
           
 void dbChildrenInserted(SQLObjectEvent e)
           
 void dbChildrenRemoved(SQLObjectEvent e)
           
 void dbObjectChanged(SQLObjectEvent e)
           
 void dbStructureChanged(SQLObjectEvent e)
           
protected  void fireTreeNodesChanged(javax.swing.event.TreeModelEvent e)
           
protected  void fireTreeNodesInserted(javax.swing.event.TreeModelEvent e)
           
protected  void fireTreeNodesRemoved(javax.swing.event.TreeModelEvent e)
           
protected  void fireTreeStructureChanged(javax.swing.event.TreeModelEvent e)
           
 java.lang.Object getChild(java.lang.Object parent, int index)
           
 int getChildCount(java.lang.Object parent)
           
 SQLObject[] getFkPathToRelationship(SQLRelationship rel)
           
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
           
 java.util.List<SQLObject[]> getPathsToNode(SQLObject node)
          Returns the path from the conceptual, hidden root node (of type DBTreeRoot) to the given node.
 SQLObject[] getPathToNode(SQLObject node)
          Returns the path from the conceptual, hidden root node (of type DBTreeRoot) to the given node.
 SQLObject[] getPkPathToRelationship(SQLRelationship rel)
           
 java.lang.Object getRoot()
           
 boolean isLeaf(java.lang.Object parent)
           
protected  SQLExceptionNode putExceptionNodeUnder(SQLObject parent, java.lang.Throwable ex)
          Creates a SQLExceptionNode with the given Throwable and places it under parent.
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
           
 void setTestMode(boolean v)
          Sets the testMode flag.
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected SQLObject root

treeModelListeners

protected java.util.LinkedList treeModelListeners
Constructor Detail

DBTreeModel

public DBTreeModel(ArchitectSession session)
            throws ArchitectException
Throws:
ArchitectException

DBTreeModel

public DBTreeModel(ArchitectSession session,
                   SQLObjectRoot root)
            throws ArchitectException
Creates a tree model with all of the SQLDatabase objects in the given session's root object in its root list of databases.

Parameters:
root - A SQLObject that contains all the databases you want in the tree. This does not necessarily have to be the root object associated with the given session, but it normally will be.
Throws:
ArchitectException
Method Detail

getRoot

public java.lang.Object getRoot()
Specified by:
getRoot in interface javax.swing.tree.TreeModel

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Specified by:
getChild in interface javax.swing.tree.TreeModel

getChildCount

public int getChildCount(java.lang.Object parent)
Specified by:
getChildCount in interface javax.swing.tree.TreeModel

isLeaf

public boolean isLeaf(java.lang.Object parent)
Specified by:
isLeaf in interface javax.swing.tree.TreeModel

valueForPathChanged

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

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel

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

fireTreeNodesInserted

protected void fireTreeNodesInserted(javax.swing.event.TreeModelEvent e)

fireTreeNodesRemoved

protected void fireTreeNodesRemoved(javax.swing.event.TreeModelEvent e)

fireTreeNodesChanged

protected void fireTreeNodesChanged(javax.swing.event.TreeModelEvent e)

fireTreeStructureChanged

protected void fireTreeStructureChanged(javax.swing.event.TreeModelEvent e)

getPathToNode

public SQLObject[] getPathToNode(SQLObject node)
Returns the path from the conceptual, hidden root node (of type DBTreeRoot) to the given node.

NOTE: This method doesn't work for SQLRelationship objects, because they have two parents! Use getPkPathToRelationship and getFkPathToRelationship instead.

Throws:
java.lang.IllegalArgumentException - if node is of class SQLRelationship.

getPkPathToRelationship

public SQLObject[] getPkPathToRelationship(SQLRelationship rel)

getFkPathToRelationship

public SQLObject[] getFkPathToRelationship(SQLRelationship rel)

getPathsToNode

public java.util.List<SQLObject[]> getPathsToNode(SQLObject node)
Returns the path from the conceptual, hidden root node (of type DBTreeRoot) to the given node. If the node is not a relationship then the list will only contain one path to the object. Otherwise the list will contain the path to the primary key then the path to the foreign key.


putExceptionNodeUnder

protected SQLExceptionNode putExceptionNodeUnder(SQLObject parent,
                                                 java.lang.Throwable ex)
Creates a SQLExceptionNode with the given Throwable and places it under parent.

Returns:
the node that has been added to parent.

dbChildrenInserted

public void dbChildrenInserted(SQLObjectEvent e)
Specified by:
dbChildrenInserted in interface SQLObjectListener

dbChildrenRemoved

public void dbChildrenRemoved(SQLObjectEvent e)
Specified by:
dbChildrenRemoved in interface SQLObjectListener

dbObjectChanged

public void dbObjectChanged(SQLObjectEvent e)
Specified by:
dbObjectChanged in interface SQLObjectListener

dbStructureChanged

public void dbStructureChanged(SQLObjectEvent e)
Specified by:
dbStructureChanged in interface SQLObjectListener

setTestMode

public void setTestMode(boolean v)
Sets the testMode flag.



Copyright © 2003-2007 SQL Power Group Inc. www.sqlpower.ca