Revision: 3534
Author: [email protected]
Date: Tue May 11 15:34:51 2010
Log: Fixed a bug with expanding the columns folder in certain tables.
http://code.google.com/p/power-architect/source/detail?r=3534

Modified:
 /trunk/src/main/java/ca/sqlpower/architect/swingui/DBTree.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/DBTree.java Thu May 6 08:50:42 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/DBTree.java Tue May 11 15:34:51 2010
@@ -282,6 +282,15 @@
        public void expandPath(TreePath tp) {
                try {
                        session.getArchitectFrame().setCursor(new 
Cursor(Cursor.WAIT_CURSOR));
+                       if 
(treeModel.isColumnsFolder(tp.getLastPathComponent())) {
+                           // This is so that the indices of the table will be 
populated.
+                // When the indices are populated, there is a chance that
+ // columns will be moved around. If this is done while expanding + // the tree, the removal event will make it back to the tree,
+                // and cause exceptions.
+ SQLTable table = (SQLTable) tp.getPathComponent(tp.getPathCount() - 2);
+                           table.getChildren(SQLIndex.class);
+                       }
                        super.expandPath(tp);
                } catch (Exception ex) {
logger.warn("Unexpected exception while expanding path "+tp, ex); //$NON-NLS-1$
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java Thu Apr 29 08:28:11 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java Tue May 11 15:34:51 2010
@@ -473,6 +473,10 @@
                }
                return !((SQLObject) parent).allowsChildren();
        }
+
+       public boolean isColumnsFolder(Object parent) {
+ return parent instanceof FolderNode && ((FolderNode) parent).allowsChildType(SQLColumn.class);
+       }

        public void valueForPathChanged(TreePath path, Object newValue) {
throw new UnsupportedOperationException("model doesn't support editing yet"); //$NON-NLS-1$

Reply via email to