Revision: 3955
Author: [email protected]
Date: Wed Sep 22 11:46:00 2010
Log: Fixed an NPE thrown when dragging a column between tables. If the
column has a data type that is the only one using that data type in the
play pen the snapshot would be removed and not added correctly on the drop.
http://code.google.com/p/power-architect/source/detail?r=3955
Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/TablePane.java
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/TablePane.java Wed
Jul 21 07:59:07 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/TablePane.java Wed
Sep 22 11:46:00 2010
@@ -559,17 +559,24 @@
} else if (col.getParent().getParentDatabase() ==
getModel().getParentDatabase()) {
// moving column within playpen
- InsertionPointWatcher<SQLTable> ipWatcher =
- new InsertionPointWatcher<SQLTable>(getModel(),
insertionPoint, SQLColumn.class);
- col.getParent().removeColumn(col);
- ipWatcher.dispose();
-
- if (logger.isDebugEnabled()) {
- logger.debug("Moving column '"+col.getName()
//$NON-NLS-1$
- +"' to table '"+getModel().getName()
//$NON-NLS-1$
- +"' at
position "+ipWatcher.getInsertionPoint()); //$NON-NLS-1$
- }
- getModel().addColumn(col, newColumnsInPk,
ipWatcher.getInsertionPoint());
+ try {
+ getModel().begin("Moving column " + col.getName() + "
to table " + getName());
+ InsertionPointWatcher<SQLTable> ipWatcher =
+ new InsertionPointWatcher<SQLTable>(getModel(),
insertionPoint, SQLColumn.class);
+ col.getParent().removeColumn(col);
+ ipWatcher.dispose();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Moving column '"+col.getName()
//$NON-NLS-1$
+ +"' to table '"+getModel().getName()
//$NON-NLS-1$
+ +"' at
position "+ipWatcher.getInsertionPoint()); //$NON-NLS-1$
+ }
+ getModel().addColumn(col, newColumnsInPk,
ipWatcher.getInsertionPoint());
+ getModel().commit();
+ } catch (RuntimeException e) {
+ getModel().rollback(e.getMessage());
+ throw e;
+ }
// 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