Author: thomasobrien95
Date: Thu Jan  8 12:38:27 2009
New Revision: 2909

Modified:
   trunk/regress/ca/sqlpower/architect/CountingSQLObjectListener.java
trunk/regress/ca/sqlpower/architect/CountingUndoCompoundEventListener.java
   trunk/regress/ca/sqlpower/architect/SQLObjectTest.java
   trunk/regress/ca/sqlpower/architect/TestSQLTable.java
   trunk/regress/ca/sqlpower/architect/TestingSQLObjectListener.java
   trunk/regress/ca/sqlpower/architect/swingui/TestTablePane.java
   trunk/src/ca/sqlpower/architect/InsertionPointWatcher.java
   trunk/src/ca/sqlpower/architect/SQLColumn.java
   trunk/src/ca/sqlpower/architect/SQLIndex.java
   trunk/src/ca/sqlpower/architect/SQLObject.java
   trunk/src/ca/sqlpower/architect/SQLObjectListener.java
   trunk/src/ca/sqlpower/architect/SQLRelationship.java
   trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java
   trunk/src/ca/sqlpower/architect/swingui/ColumnEditPanel.java
   trunk/src/ca/sqlpower/architect/swingui/IndexColumnTable.java
   trunk/src/ca/sqlpower/architect/swingui/Navigator.java
   trunk/src/ca/sqlpower/architect/swingui/PlayPen.java
   trunk/src/ca/sqlpower/architect/swingui/Relationship.java
   trunk/src/ca/sqlpower/architect/swingui/RelationshipEditPanel.java
   trunk/src/ca/sqlpower/architect/swingui/SQLObjectComboBoxModel.java
   trunk/src/ca/sqlpower/architect/swingui/SQLTableListModel.java
   trunk/src/ca/sqlpower/architect/swingui/TableEditPanel.java
   trunk/src/ca/sqlpower/architect/swingui/TablePane.java
   trunk/src/ca/sqlpower/architect/swingui/action/OpenProjectAction.java
   trunk/src/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java
   trunk/src/ca/sqlpower/architect/undo/ArchitectUndoManager.java

Log:
the dbStructureChange method has finally been removed from the SQLObjectListener. The method was problematic as it was not undoable.

Modified: trunk/regress/ca/sqlpower/architect/CountingSQLObjectListener.java
==============================================================================
--- trunk/regress/ca/sqlpower/architect/CountingSQLObjectListener.java (original) +++ trunk/regress/ca/sqlpower/architect/CountingSQLObjectListener.java Thu Jan 8 12:38:27 2009
@@ -77,15 +77,6 @@
                changedCount++;
        }
        
-       /**
-        * Increments the structureChangedCount.
-        */
-       public void dbStructureChanged(SQLObjectEvent e) {
-               lastEvent=e;
-               structureChangedCount++;
-       }
-       
-       
        // =========== Getters ============
        
        /**

Modified: trunk/regress/ca/sqlpower/architect/CountingUndoCompoundEventListener.java
==============================================================================
--- trunk/regress/ca/sqlpower/architect/CountingUndoCompoundEventListener.java (original) +++ trunk/regress/ca/sqlpower/architect/CountingUndoCompoundEventListener.java Thu Jan 8 12:38:27 2009
@@ -98,7 +98,4 @@
                liveEdits++;
        }

-       public void dbStructureChanged(SQLObjectEvent e) {
-               liveEdits++;
-       }
 }

Modified: trunk/regress/ca/sqlpower/architect/SQLObjectTest.java
==============================================================================
--- trunk/regress/ca/sqlpower/architect/SQLObjectTest.java      (original)
+++ trunk/regress/ca/sqlpower/architect/SQLObjectTest.java Thu Jan 8 12:38:27 2009
@@ -66,10 +66,6 @@
                        fireDbObjectChanged(string,oldValue,newValue);
                }
                
-               // manually call fireDbStructureChanged, so it can be tested.
-               public void fakeStructureChanged() {
-                       fireDbStructureChanged();
-               }
                @Override
                public Class<? extends SQLObject> getChildType() {
                        return SQLObject.class;
@@ -169,11 +165,9 @@
     public void testFireStructureChangeEvent() throws Exception {
         CountingSQLObjectListener l = new CountingSQLObjectListener();
         target.addSQLObjectListener(l);
-               ((SQLObjectImpl)target).fakeStructureChanged();
         assertEquals(0, l.getInsertedCount());
         assertEquals(0, l.getRemovedCount());
         assertEquals(0, l.getChangedCount());
-        assertEquals(1, l.getStructureChangedCount());
     }

     public void testAddRemoveListener() {
@@ -185,18 +179,6 @@
         target.removeSQLObjectListener(l);
                assertEquals(0, target.getSQLObjectListeners().size());
        }
-
-    public void testRemovedListenerUnlistens() {
-        CountingSQLObjectListener l = new CountingSQLObjectListener();
-        target.addSQLObjectListener(l);
-
-        ((SQLObjectImpl)target).fakeStructureChanged();
-        assertEquals(1, l.getStructureChangedCount());
-
-        target.removeSQLObjectListener(l);
-        ((SQLObjectImpl)target).fakeStructureChanged();
-        assertEquals(1, l.getStructureChangedCount());
-    }
        
        public void testNoMixChildTypes() throws ArchitectException {
                target.addChild(new SQLColumn());

Modified: trunk/regress/ca/sqlpower/architect/TestSQLTable.java
==============================================================================
--- trunk/regress/ca/sqlpower/architect/TestSQLTable.java       (original)
+++ trunk/regress/ca/sqlpower/architect/TestSQLTable.java Thu Jan 8 12:38:27 2009
@@ -869,15 +869,6 @@
             // FIXME have to unlisten to old objects and listen to new ones
         }

-        /**
- * Listener method. Throws UnsupportedOperationException when called, because we are trying - * to wean the object model from StructureChangeEvents, because they are not undoable. - * Failing early will help to weed these events out of the object model.
-         */
-        public void dbStructureChanged(SQLObjectEvent e) {
- throw new UnsupportedOperationException("Structure changes are not undoable");
-        }
-
         public void compoundEditStart(UndoCompoundEvent e) {
             // whatever
         }
@@ -1225,11 +1216,6 @@

             }

-            public void dbStructureChanged(SQLObjectEvent e) {
-                // TODO Auto-generated method stub
-
-            }
-
         }
table.getColumnsFolder().addSQLObjectListener(new InsertListener());
         SQLRelationship selfref = new SQLRelationship();

Modified: trunk/regress/ca/sqlpower/architect/TestingSQLObjectListener.java
==============================================================================
--- trunk/regress/ca/sqlpower/architect/TestingSQLObjectListener.java (original) +++ trunk/regress/ca/sqlpower/architect/TestingSQLObjectListener.java Thu Jan 8 12:38:27 2009
@@ -24,14 +24,12 @@
     private int insertedCount;
     private int removedCount;
     private int changedCount;
-    private int structureChangedCount;
     private String lastEventName;

     public TestingSQLObjectListener() {
         insertedCount = 0;
         removedCount = 0;
         changedCount = 0;
-        structureChangedCount = 0;
         lastEventName = null;
     }
     public void dbChildrenInserted(SQLObjectEvent e) {
@@ -47,10 +45,6 @@
         lastEventName = e.getPropertyName();
     }

-    public void dbStructureChanged(SQLObjectEvent e) {
-        structureChangedCount++;
-    }
-
     public int getInsertedCount() {
         return insertedCount;
     }
@@ -60,9 +54,6 @@
     }
     public int getChangedCount() {
         return changedCount;
-    }
-    public int getStructureChangedCount() {
-        return structureChangedCount;
     }
     public String getLastEventName() {
         return lastEventName;

Modified: trunk/regress/ca/sqlpower/architect/swingui/TestTablePane.java
==============================================================================
--- trunk/regress/ca/sqlpower/architect/swingui/TestTablePane.java (original) +++ trunk/regress/ca/sqlpower/architect/swingui/TestTablePane.java Thu Jan 8 12:38:27 2009
@@ -27,7 +27,6 @@
 import java.util.List;

 import ca.sqlpower.architect.ArchitectException;
-import ca.sqlpower.architect.CountingSQLObjectListener;
 import ca.sqlpower.architect.SQLColumn;
 import ca.sqlpower.architect.SQLObject;
 import ca.sqlpower.architect.SQLObjectEvent;
@@ -323,21 +322,28 @@
      * folder.
      */
public void testDropColumnBetweenTablesFiresFolderEvent() throws Exception { - CountingSQLObjectListener listener = new CountingSQLObjectListener();
-        tp.getModel().getColumnsFolder().addSQLObjectListener(listener);

- SQLTable table = new SQLTable(tp.getModel().getParentDatabase(), true);
+        SQLRelationship rel = new SQLRelationship();
+        rel.setIdentifying(true);
+ SQLTable fkTable = new SQLTable(tp.getModel().getParentDatabase(), true);
+        rel.attachRelationship(t, fkTable, true);
+
         SQLColumn col = new SQLColumn();
         col.setName("Test Col");
-        table.addColumn(col);
+        fkTable.addColumn(col);
+
+        assertEquals(3, t.getPkSize());
+        assertEquals(3, fkTable.getPkSize());

- System.out.println(tp.getModel().getParentDatabase() + ", "+ table.getParentDatabase()); + System.out.println(tp.getModel().getParentDatabase() + ", "+ fkTable.getParentDatabase()); tp.insertObjects(Collections.singletonList(col), TablePane.COLUMN_INDEX_END_OF_PK);

         assertEquals(tp.getModel(), col.getParentTable());
         assertTrue(col.isPrimaryKey());
-        assertEquals(1, listener.getStructureChangedCount());
-
+        assertEquals(4, fkTable.getColumns().size());
+        assertEquals(4, rel.getMappings().size());
+        assertNotNull(rel.getMappingByPkCol(col));
+        assertNotNull(rel.getMappingByFkCol(fkTable.getColumn(0)));
     }

     @Override

Modified: trunk/src/ca/sqlpower/architect/InsertionPointWatcher.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/InsertionPointWatcher.java  (original)
+++ trunk/src/ca/sqlpower/architect/InsertionPointWatcher.java Thu Jan 8 12:38:27 2009
@@ -89,13 +89,6 @@
             // don't care
         }

-        public void dbStructureChanged(SQLObjectEvent e) {
-            logger.error(
-                    "Received structure change event, which is" +
-                    "not supported. Setting target index to 0");
-            insertionPoint = 0;
-        }
-
     }

     /**

Modified: trunk/src/ca/sqlpower/architect/SQLColumn.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/SQLColumn.java      (original)
+++ trunk/src/ca/sqlpower/architect/SQLColumn.java      Thu Jan  8 12:38:27 2009
@@ -704,7 +704,7 @@
        public Integer getPrimaryKeySeq()  {
                return this.primaryKeySeq;
        }
-
+       
     /**
* Sets the value of primaryKeySeq, and moves the column to the appropriate location in the * parent table's column folder. However, if magic is disabled on this column, this method
@@ -715,6 +715,22 @@
      * with default values.
      */
        public void setPrimaryKeySeq(Integer argPrimaryKeySeq) {
+           setPrimaryKeySeq(argPrimaryKeySeq, true);
+       }
+
+    /**
+ * Sets the value of primaryKeySeq, and moves the column to the appropriate location in the + * parent table's column folder. However, if magic is disabled on this column, this method + * simply sets the PrimaryKeySeq property to the given value, fires the change event, and
+     * returns without trying to re-order the columns.
+     *
+ * If there is no primary key on this column's table it will create a new key
+     * with default values.
+     *
+ * @param normalizeKey pass in false if the key should not be normalized when setting this
+     *      key's primary sequence.
+     */
+ public void setPrimaryKeySeq(Integer argPrimaryKeySeq, boolean normalizeKey) {
            // do nothing if there's no change
            if ( (primaryKeySeq == null && argPrimaryKeySeq == null) ||
(primaryKeySeq != null && primaryKeySeq.equals(argPrimaryKeySeq)) ) {
@@ -766,7 +782,9 @@
                 } finally {
                     p.setMagicEnabled(true);
                 }
-                   getParentTable().normalizePrimaryKey();
+                if (normalizeKey) {
+                    getParentTable().normalizePrimaryKey();
+                }
             }
         } catch (ArchitectException e) {
             throw new ArchitectRuntimeException(e);

Modified: trunk/src/ca/sqlpower/architect/SQLIndex.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/SQLIndex.java       (original)
+++ trunk/src/ca/sqlpower/architect/SQLIndex.java       Thu Jan  8 12:38:27 2009
@@ -99,13 +99,6 @@
                 }
             }

-            /**
-             * Refires structure change events from the target SQLColumn.
-             */
-            public void dbStructureChanged(SQLObjectEvent e) {
-                Column.this.fireDbStructureChanged();
-            }
-
             @Override
             public String toString() {
                 StringBuffer buf = new StringBuffer();

Modified: trunk/src/ca/sqlpower/architect/SQLObject.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/SQLObject.java      (original)
+++ trunk/src/ca/sqlpower/architect/SQLObject.java      Thu Jan  8 12:38:27 2009
@@ -506,32 +506,6 @@
if (logger.isDebugEnabled()) logger.debug("Notified "+count+" listeners.");
        }

-       /**
- * Notifies listeners that a major change has occurred at or under this node.
-        *
- * <p>Note: This method is public because the PlayPen's Objects-Adder cleanup method - * needs to generate these notifications. That kind of code should be in this package instead.
-        */
-       public void fireDbStructureChanged() {
-               if (logger.isDebugEnabled()) {
-                       logger.debug(getClass().getName()+" "+toString()+": " +
-                                       "firing dbStructureChanged event");
-               }
-               SQLObjectEvent e = new SQLObjectEvent(
-                               this,
-                               null);
-
-               int count = 0;
-               synchronized(sqlObjectListeners) {
- SQLObjectListener[] listeners = sqlObjectListeners.toArray(new SQLObjectListener[0]);
-                       for(int i = listeners.length-1;i>=0;i--) {
-                               count++;
-                               listeners[i].dbStructureChanged(e);
-                       }
-               }
- if (logger.isDebugEnabled()) logger.debug("Notified "+count+" listeners.");
-       }
-
     // ------------------- sql object Pre-event support -------------------
private final transient List<SQLObjectPreEventListener> sqlObjectPreEventListeners =
         new ArrayList<SQLObjectPreEventListener>();

Modified: trunk/src/ca/sqlpower/architect/SQLObjectListener.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/SQLObjectListener.java      (original)
+++ trunk/src/ca/sqlpower/architect/SQLObjectListener.java Thu Jan 8 12:38:27 2009
@@ -27,5 +27,4 @@
        public void dbChildrenInserted(SQLObjectEvent e);
        public void dbChildrenRemoved(SQLObjectEvent e);
        public void dbObjectChanged(SQLObjectEvent e);
-       public void dbStructureChanged(SQLObjectEvent e);
 }

Modified: trunk/src/ca/sqlpower/architect/SQLRelationship.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/SQLRelationship.java        (original)
+++ trunk/src/ca/sqlpower/architect/SQLRelationship.java Thu Jan 8 12:38:27 2009
@@ -881,33 +881,6 @@
                        }
                }

-               public void dbStructureChanged(SQLObjectEvent e) {
-                       if (!(e.getSQLSource().isMagicEnabled())){
-                               logger.debug("Magic disabled ignoring sqlobjectEvent 
"+e);
-                               return;
-                       }
-                       logger.debug("Received a dbStructure changed event");
-                       // wow!  let's re-scan the whole table
- // FIXME: This should also check if this relationship is still part of pktable and fktable, and copy properties from pkcol to fkcol in the mappings
-                       try {
-                               startCompoundEdit("Structure Change");
-                               Iterator it = pkTable.getColumns().iterator();
-                               while (it.hasNext()) {
-                                       SQLColumn col = (SQLColumn) it.next();
-                                       if (col.getPrimaryKeySeq() != null) {
-                                               ensureInMapping(col);
-                                       } else {
-                                               ensureNotInMapping(col);
-                                       }
-                               }
-                       } catch (ArchitectException ex) {
- logger.warn("Coulnd't re-scan table as a result of dbStructureChanged", ex);
-                       } finally {
-                               endCompoundEdit("End structure changed 
handler");
-                       }
-
-               }
-
// XXX this code serves essentially the same purpose as the loop in realizeMapping(). // We should refactor that method to use this one as a subroutine, and at that
         //     time, ensure the special cases in both places are preserved.

Modified: trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java Thu Jan 8 12:38:27 2009
@@ -211,9 +211,6 @@
projectModificationWatcher = new ProjectModificationWatcher(playPen);

         getRootObject().addSQLObjectListener(new SQLObjectListener() {
-            public void dbStructureChanged(SQLObjectEvent e) {
-                isNew = false;
-            }
             public void dbObjectChanged(SQLObjectEvent e) {
                 isNew = false;
             }
@@ -651,16 +648,6 @@
         /** Marks project dirty. */
         public void dbObjectChanged(SQLObjectEvent e) {
             getProject().setModified(true);
-            isNew = false;
-        }
-
-        /** Marks project dirty and listens to new hierarchy. */
-        public void dbStructureChanged(SQLObjectEvent e) {
-            try {
-                ArchitectUtils.listenToHierarchy(this, e.getSQLSource());
-            } catch (ArchitectException e1) {
- logger.error("dbStructureChanged listener: Failed to listen to new project hierarchy", e1); //$NON-NLS-1$
-            }
             isNew = false;
         }


Modified: trunk/src/ca/sqlpower/architect/swingui/ColumnEditPanel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/ColumnEditPanel.java        
(original)
+++ trunk/src/ca/sqlpower/architect/swingui/ColumnEditPanel.java Thu Jan 8 12:38:27 2009
@@ -736,9 +736,6 @@

         }

-        public void dbStructureChanged(SQLObjectEvent e) {
-
-        }
     };

     /**

Modified: trunk/src/ca/sqlpower/architect/swingui/IndexColumnTable.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/IndexColumnTable.java       
(original)
+++ trunk/src/ca/sqlpower/architect/swingui/IndexColumnTable.java Thu Jan 8 12:38:27 2009
@@ -157,8 +157,6 @@
             public void dbObjectChanged(SQLObjectEvent e) {
             }

-            public void dbStructureChanged(SQLObjectEvent e) {
-            }
         }

         /**
@@ -359,10 +357,6 @@

         public void dbObjectChanged(SQLObjectEvent e) {
             fireTableDataChanged();
-        }
-
-        public void dbStructureChanged(SQLObjectEvent e) {
- throw new UnsupportedOperationException("Bad idea.. nothing can cope with dbstructurechanged events."); //$NON-NLS-1$
         }

     }

Modified: trunk/src/ca/sqlpower/architect/swingui/Navigator.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/Navigator.java      (original)
+++ trunk/src/ca/sqlpower/architect/swingui/Navigator.java Thu Jan 8 12:38:27 2009
@@ -244,9 +244,6 @@
         navigationPanel.repaint();
     }

-    public void dbStructureChanged(SQLObjectEvent e) {
-    }
-
     /**
      * Refreshes the navigator upon scrolling
      */

Modified: trunk/src/ca/sqlpower/architect/swingui/PlayPen.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/PlayPen.java        (original)
+++ trunk/src/ca/sqlpower/architect/swingui/PlayPen.java Thu Jan 8 12:38:27 2009
@@ -1581,7 +1581,6 @@

                                while (soIt.hasNext() && !isCancelled()) {
                                        SQLObject someData = soIt.next();
-                                       someData.fireDbStructureChanged();
                                        if (someData instanceof SQLTable) {
TablePane tp = importTableCopy((SQLTable) someData, preferredLocation); message = ArchitectUtils.truncateString(((SQLTable)someData).getName());
@@ -1774,22 +1773,6 @@
        public void dbObjectChanged(SQLObjectEvent e) {
firePropertyChange("model."+e.getPropertyName(), null, null); //$NON-NLS-1$
                revalidate();
-       }
-
-       /**
-        * Listens for property changes in the model (significant
-        * structure change).  If this change affects the appearance of
-        * this widget, we will notify all change listeners (the UI
-        * delegate) with a ChangeEvent.
-        *
-        * <p>NOTE: This is not currently implemented.
-        */
-       public void dbStructureChanged(SQLObjectEvent e) {
- logger.debug("Playpen has recieved a db structure change this is unsupported at the moment"); //$NON-NLS-1$
-               //throw new UnsupportedOperationException
- // ("FIXME: we have to make sure we're listening to the right objects now!");
-               //firePropertyChange("model.children", null, null);
-               //revalidate();
        }

        // --------------- SELECTION METHODS ----------------

Modified: trunk/src/ca/sqlpower/architect/swingui/Relationship.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/Relationship.java   (original)
+++ trunk/src/ca/sqlpower/architect/swingui/Relationship.java Thu Jan 8 12:38:27 2009
@@ -447,10 +447,6 @@
                }
        }

-       public void dbStructureChanged(SQLObjectEvent e) {
-        // not sure if this ever happens!
-       }
-
     /**
* Determines if the given rectangle is visibly touching this component.
      *

Modified: trunk/src/ca/sqlpower/architect/swingui/RelationshipEditPanel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/RelationshipEditPanel.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/RelationshipEditPanel.java Thu Jan 8 12:38:27 2009
@@ -383,10 +383,6 @@

     }

-    public void dbStructureChanged(SQLObjectEvent e) {
-
-    }
-
     public void setEditDialog(JDialog editDialog) {
         this.editDialog = editDialog;
     }

Modified: trunk/src/ca/sqlpower/architect/swingui/SQLObjectComboBoxModel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/SQLObjectComboBoxModel.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/SQLObjectComboBoxModel.java Thu Jan 8 12:38:27 2009
@@ -119,10 +119,5 @@
             // doesn't matter
         }

-        public void dbStructureChanged(SQLObjectEvent e) {
-            // I don't think these happen
-            fireListDataEvent(ListDataEvent.CONTENTS_CHANGED, 0, 0);
-        }
-
     };
 }

Modified: trunk/src/ca/sqlpower/architect/swingui/SQLTableListModel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/SQLTableListModel.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/SQLTableListModel.java Thu Jan 8 12:38:27 2009
@@ -146,12 +146,4 @@
                }
        }

-       public void dbStructureChanged(SQLObjectEvent e) {
-               int[] changedIndices = e.getChangedIndices();
-               for (int i = 0; i < changedIndices.length; i++) {
-                       // XXX: should group contiguous regions into one event!
-                       fireContentsChanged(changedIndices[i], 
changedIndices[i]);
-               }
-       }
-
 }

Modified: trunk/src/ca/sqlpower/architect/swingui/TableEditPanel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/TableEditPanel.java (original)
+++ trunk/src/ca/sqlpower/architect/swingui/TableEditPanel.java Thu Jan 8 12:38:27 2009
@@ -250,10 +250,6 @@

     }

-    public void dbStructureChanged(SQLObjectEvent e) {
-
-    }
-
     public void setEditDialog(JDialog editDialog) {
         this.editDialog = editDialog;
     }

Modified: trunk/src/ca/sqlpower/architect/swingui/TablePane.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/TablePane.java      (original)
+++ trunk/src/ca/sqlpower/architect/swingui/TablePane.java Thu Jan 8 12:38:27 2009
@@ -329,29 +329,6 @@
             //repaint();
         }

-        /**
-         * Listens for property changes in the model (significant
-         * structure change).  If this change affects the appearance of
-         * this widget, we will notify all change listeners (the UI
-         * delegate) with a ChangeEvent.
-         */
-        public void dbStructureChanged(SQLObjectEvent e) {
- logger.debug("TablePane got db structure change event. source="+e.getSource()); //$NON-NLS-1$
-            if (e.getSource() == model.getColumnsFolder()) {
-                selectNone();
-                columnHighlight = new HashMap<SQLColumn,List<Color>>();
-                try {
- for (SQLColumn child :((List<SQLColumn>) model.getColumnsFolder().getChildren())) {
-                        columnHighlight.put(child,new ArrayList<Color>());
-                    }
-                } catch (ArchitectException e1) {
-                    throw new ArchitectRuntimeException(e1);
-                }
-                updateHiddenColumns();
- firePropertyChange("model.children", null, null); //$NON-NLS-1$
-                //revalidate();
-            }
-        }
     }

// ----------------------- accessors and mutators --------------------------
@@ -526,22 +503,17 @@
                                                                +"' to table 
'"+getModel().getName() //$NON-NLS-1$
                                                                +"' at position 
"+ipWatcher.getInsertionPoint()); //$NON-NLS-1$
                                        }
-                                       try {
- // You need to disable the magic (really the normalization) otherwise it goes around - // the property change events and causes undo to fail when dragging into the primary
-                        // key of a table
-                                           getModel().setMagicEnabled(false);
-                                           
getModel().addColumn(ipWatcher.getInsertionPoint(), col);
-
-                                           if (newColumnsInPk) {
- col.setPrimaryKeySeq(new Integer(ipWatcher.getInsertionPoint()));
-                                           } else {
-                                               col.setPrimaryKeySeq(null);
-                                           }
-                                       } finally {
-                        getModel().setMagicEnabled(true);
+                                       
getModel().addColumn(ipWatcher.getInsertionPoint(), col);
+                                       // You need to disable the 
normalization otherwise it goes around
+                                       // the property change events and 
causes undo to fail when dragging
+                                       // into the primary key of a table
+                                       logger.debug("Column listeners are " + 
col.getSQLObjectListeners());
+
+                                       if (newColumnsInPk) {
+ col.setPrimaryKeySeq(new Integer(ipWatcher.getInsertionPoint()), false);
+                                       } else {
+                                           col.setPrimaryKeySeq(null, false);
                                        }
-                                       
getModel().getColumnsFolder().fireDbStructureChanged();
                                } else {
                                        // importing column from a source 
database
                                        getModel().inherit(insertionPoint, col, 
newColumnsInPk);

Modified: trunk/src/ca/sqlpower/architect/swingui/action/OpenProjectAction.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/action/OpenProjectAction.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/action/OpenProjectAction.java Thu Jan 8 12:38:27 2009
@@ -37,7 +37,6 @@
 import org.apache.log4j.Logger;

 import ca.sqlpower.architect.ArchitectException;
-import ca.sqlpower.architect.SQLObject;
 import ca.sqlpower.architect.swingui.ASUtils;
 import ca.sqlpower.architect.swingui.ArchitectSwingSession;
 import ca.sqlpower.architect.swingui.ArchitectSwingSessionContext;
@@ -195,7 +194,6 @@
             } else {
                 recent.putRecentFileName(file.getAbsolutePath());
                 session.initGUI(openingSession);
- ((SQLObject) session.getSourceDatabases().getModel().getRoot()).fireDbStructureChanged();
             }

             try {

Modified: trunk/src/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java Thu Jan 8 12:38:27 2009
@@ -384,21 +384,6 @@
                }
     }

-       public void dbStructureChanged(SQLObjectEvent e) {
-               logger.debug("dbStructureChanged. source="+e.getSource()); 
//$NON-NLS-1$
-               try {                   
-                       ArchitectUtils.listenToHierarchy(this, 
e.getSQLSource());
-               } catch (ArchitectException ex) {
- logger.error("Couldn't listen to hierarchy rooted at "+e.getSQLSource(), ex); //$NON-NLS-1$
-               }
-        if ((!SwingUtilities.isEventDispatchThread()) && (!testMode)) {
- logger.debug("Not refiring because this is not the EDT."); //$NON-NLS-1$
-            return;
-        }
- TreeModelEvent tme = new TreeModelEvent(this, getPathsToNode(e.getSQLSource()).get(0));
-               fireTreeStructureChanged(tme);
-       }
-
     /**
      * Sets the {...@link #testMode} flag.
      */

Modified: trunk/src/ca/sqlpower/architect/undo/ArchitectUndoManager.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/undo/ArchitectUndoManager.java (original) +++ trunk/src/ca/sqlpower/architect/undo/ArchitectUndoManager.java Thu Jan 8 12:38:27 2009
@@ -225,13 +225,6 @@
             }
         }

-        public void dbStructureChanged(SQLObjectEvent e) {
-            logger.error("Unexpected structure change event");
-
-            // too many changes clear undo
-            ArchitectUndoManager.this.discardAllEdits();
-        }
-
         /**
* Packs property change event into PropertyChangeEdit and then adds
          * to the undo manager.

Reply via email to