Revision: 3208
Author: [email protected]
Date: Wed Dec 16 07:06:15 2009
Log: The DBTree had its own way of creating tree paths that was almost identical to the way the tree model was creating paths. The DBTree now uses its model's tree path method instead to reduce duplicate code. This also fixes an error with delete where deleting a column from a table in the tree caused Architect to attempt to delete the column twice.
http://code.google.com/p/power-architect/source/detail?r=3208

Modified:
/branches/sqlobject-spobject-model/src/ca/sqlpower/architect/swingui/DBTree.java

=======================================
--- /branches/sqlobject-spobject-model/src/ca/sqlpower/architect/swingui/DBTree.java Tue Dec 1 14:51:49 2009 +++ /branches/sqlobject-spobject-model/src/ca/sqlpower/architect/swingui/DBTree.java Wed Dec 16 07:06:15 2009
@@ -126,11 +126,17 @@
        private static final Object KEY_DELETE_SELECTED
= "ca.sqlpower.architect.swingui.DBTree.KEY_DELETE_SELECTED"; //$NON-NLS-1$

+       /**
+        * The model behind this DB tree.
+        */
+       private final DBTreeModel treeModel;
+
        // ----------- CONSTRUCTORS ------------

public DBTree(final ArchitectSwingSession session) throws SQLObjectException {
         this.session = session;
-        setModel(new DBTreeModel(session.getRootObject()));
+        treeModel = new DBTreeModel(session.getRootObject());
+        setModel(treeModel);
                setUI(new MultiDragTreeUI());
                setRootVisible(false);
                setShowsRootHandles(true);
@@ -1063,16 +1069,7 @@
      * @return TreePath for given object.
      */
     public TreePath getTreePathForNode(SQLObject obj) {
-        List<SQLObject> path = new ArrayList<SQLObject>();
-
-        while (obj != null && obj != session.getRootObject()) {
-            path.add(0, obj);
-            obj = obj.getParent();
-        }
-
-        // the root object is not in the hierarchy
-        path.add(0, session.getRootObject());
-        return new TreePath(path.toArray());
+        return new TreePath(treeModel.getPathToNode(obj));
     }

     public void setPopupMenuEnabled(boolean popupMenuEnabled) {
@@ -1122,5 +1119,5 @@
             }
         }
     }
-
-}
+
+}

Reply via email to