Revision: 4044
Author: [email protected]
Date: Thu Dec 16 13:00:35 2010
Log: FIXED PART OF BUG 3117: Undoing the creation of a snapshot can cause
an error.
http://code.google.com/p/power-architect/source/detail?r=4044
Modified:
/trunk/src/main/java/ca/sqlpower/architect/enterprise/SPObjectSnapshotHierarchyListener.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/enterprise/SPObjectSnapshotHierarchyListener.java
Thu Dec 9 08:44:10 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/enterprise/SPObjectSnapshotHierarchyListener.java
Thu Dec 16 13:00:35 2010
@@ -166,7 +166,8 @@
e.getChild().removeSPListener(this);
for (SQLColumn col :
e.getChild().getChildren(SQLColumn.class)) {
col.getUserDefinedSQLType().removeSPListener(this);
- if
(session.getWorkspace().getSnapshotCollection().isMagicEnabled()) {
+ if
(session.getWorkspace().getSnapshotCollection().isMagicEnabled() &&
+
col.getUserDefinedSQLType().isMagicEnabled()) {
UserDefinedSQLType snapshotType =
col.getUserDefinedSQLType().getUpstreamType();
Integer cleanupCount =
typesToCleanup.get(snapshotType);
if (cleanupCount == null) {
@@ -178,7 +179,8 @@
} else if (e.getChild() instanceof SQLColumn) {
UserDefinedSQLType colType = ((SQLColumn)
e.getChild()).getUserDefinedSQLType();
colType.removeSPListener(this);
- if
(session.getWorkspace().getSnapshotCollection().isMagicEnabled()) {
+ if
(session.getWorkspace().getSnapshotCollection().isMagicEnabled() &&
+ colType.isMagicEnabled()) {
UserDefinedSQLType snapshotType =
colType.getUpstreamType();
Integer cleanupCount = typesToCleanup.get(snapshotType);
if (cleanupCount == null) {
@@ -260,7 +262,9 @@
collection.removeChild(cat);
}
} else {
- collection.removeChild(udtSnapshot.getSPObject());
+ if(udtSnapshot.getSPObject().isMagicEnabled()) {
+ collection.removeChild(udtSnapshot.getSPObject());
+ }
}
} catch (Exception e) {
throw new RuntimeException(e);
@@ -357,7 +361,7 @@
public static void createSPObjectSnapshot(UserDefinedSQLType typeProxy,
UserDefinedSQLType upstreamType, SnapshotCollection collection,
SPObjectSnapshotHierarchyListener updateListener) {
- if (!collection.isMagicEnabled()) return;
+ if (!collection.isMagicEnabled() || !typeProxy.isMagicEnabled())
return;
SPObject upstreamTypeParent = upstreamType.getParent();
@@ -505,7 +509,9 @@
createSPObjectSnapshot(source, newValue,
session.getWorkspace().getSnapshotCollection(), this);
- if (oldValue != null &&
session.getWorkspace().getSnapshotCollection().isMagicEnabled()) {
+ if (oldValue != null &&
+
session.getWorkspace().getSnapshotCollection().isMagicEnabled() &&
+ source.isMagicEnabled()) {
cleanupSnapshot(oldValue);
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java
Wed Dec 1 11:56:55 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java
Thu Dec 16 13:00:35 2010
@@ -253,7 +253,9 @@
* So we need to get around the check.
*/
private void processSQLObjectChanged(PropertyChangeEvent e) {
- if (e.getPropertyName().equals("name") && //$NON-NLS-1$
+ if (e.getSource() != null &&
+ e.getNewValue() != null &&
+ e.getPropertyName().equals("name") && //$NON-NLS-1$
!e.getNewValue().equals(((SPObject)
e.getSource()).getName()) ) {
logger.error("Name change event has wrong new value.
new="+e.getNewValue()+"; real="+((SPObject) e.getSource()).getName());
//$NON-NLS-1$ //$NON-NLS-2$
}