Revision: 3861
Author: mo.jeff
Date: Tue Aug 10 08:18:41 2010
Log: Fix for the issue where creating a column and leaving the type to the
default type (at this point, is INTEGER) would not create a snapshot for
it, and subsequent creations of columns using INTEGER would not increment
the snapshot usage count because it wouldn't fire events since each
upstream type change had the same value for new and old value, resulting in
no event firing.
http://code.google.com/p/power-architect/source/detail?r=3861
Modified:
/trunk/src/main/java/ca/sqlpower/architect/SPObjectSnapshotHierarchyListener.java
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/SPObjectSnapshotHierarchyListener.java
Mon Aug 9 15:22:33 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/SPObjectSnapshotHierarchyListener.java
Tue Aug 10 08:18:41 2010
@@ -93,31 +93,39 @@
}
@Override
- public void childAdded(SPChildEvent e) {
- if (e.getChild() instanceof SQLTable) {
- SQLTable table = (SQLTable) e.getChild();
- table.addSPListener(this);
- for (SQLColumn sqlColumn :
table.getChildren(SQLColumn.class)) {
-
sqlColumn.getUserDefinedSQLType().addSPListener(this);
- }
- } else if (e.getChild() instanceof SQLColumn) {
- SQLColumn sqlColumn = (SQLColumn) e.getChild();
- sqlColumn.getUserDefinedSQLType().addSPListener(this);
- UserDefinedSQLType upstreamType =
sqlColumn.getUserDefinedSQLType().getUpstreamType();
- if (upstreamType != null) {
- List<UserDefinedSQLTypeSnapshot> udtSnapshots =
-
session.getWorkspace().getSnapshotCollection().getChildren(UserDefinedSQLTypeSnapshot.class);
- for (UserDefinedSQLTypeSnapshot snapshot:
udtSnapshots) {
- if
(upstreamType.equals(snapshot.getSPObject())) {
- if (listenerMap.get(snapshot) == null) {
- addUpdateListener(upstreamType);
- }
- break;
- }
- }
- }
- }
- }
+ public void childAdded(SPChildEvent e) {
+ if (e.getChild() instanceof SQLTable) {
+ SQLTable table = (SQLTable) e.getChild();
+ table.addSPListener(this);
+ for (SQLColumn sqlColumn : table.getChildren(SQLColumn.class))
{
+ sqlColumn.getUserDefinedSQLType().addSPListener(this);
+ }
+ } else if (e.getChild() instanceof SQLColumn) {
+ SQLColumn sqlColumn = (SQLColumn) e.getChild();
+ UserDefinedSQLType upstreamType =
sqlColumn.getUserDefinedSQLType().getUpstreamType();
+ if (upstreamType != null) {
+ List<UserDefinedSQLTypeSnapshot> udtSnapshots =
+
session.getWorkspace().getSnapshotCollection().getChildren(UserDefinedSQLTypeSnapshot.class);
+ boolean isSnapshot = false;
+ for (UserDefinedSQLTypeSnapshot snapshot: udtSnapshots) {
+ if (upstreamType.equals(snapshot.getSPObject())) {
+ isSnapshot = true;
+
snapshot.setSnapshotUseCount(snapshot.getSnapshotUseCount() + 1);
+ if (listenerMap.get(snapshot) == null) {
+ addUpdateListener(upstreamType);
+ }
+ break;
+ }
+ }
+ if (!isSnapshot) {
+ UserDefinedSQLType columnProxyType =
sqlColumn.getUserDefinedSQLType();
+ createSPObjectSnapshot(columnProxyType, upstreamType);
+ addUpdateListener(columnProxyType.getUpstreamType());
+ }
+ }
+ sqlColumn.getUserDefinedSQLType().addSPListener(this);
+ }
+ }
@Override
public void childRemoved(SPChildEvent e) {