Revision: 3871
Author: [email protected]
Date: Wed Aug 11 15:32:36 2010
Log: FIXED - bug 2914: Reverse engineering can bring user out of sync with server
http://trillian.sqlpower.ca/bugzilla/show_bug.cgi?id=2914

Fixed the obsolescence listener in the client side session, so that it will listen to the snapshot collection, but process the project's transaction. It will also no longer throw exceptions for unbalanced transactions, which was the cause for the exception seen.
http://code.google.com/p/power-architect/source/detail?r=3871

Modified:
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java Thu Aug 5 12:09:29 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java Wed Aug 11 15:32:36 2010
@@ -73,6 +73,7 @@
 import ca.sqlpower.enterprise.client.SPServerInfo;
 import ca.sqlpower.enterprise.client.User;
 import ca.sqlpower.object.AbstractPoolingSPListener;
+import ca.sqlpower.object.AbstractSPListener;
 import ca.sqlpower.object.SPChildEvent;
 import ca.sqlpower.object.SPObjectSnapshot;
 import ca.sqlpower.object.SPObjectUUIDComparator;
@@ -91,6 +92,7 @@
 import ca.sqlpower.swingui.event.SessionLifecycleEvent;
 import ca.sqlpower.swingui.event.SessionLifecycleListener;
 import ca.sqlpower.util.SQLPowerUtils;
+import ca.sqlpower.util.TransactionEvent;
 import ca.sqlpower.util.UserPrompterFactory;
 import ca.sqlpower.util.UserPrompter.UserPromptOptions;
 import ca.sqlpower.util.UserPrompter.UserPromptResponse;
@@ -223,7 +225,7 @@
//they haven't been opened in some time but updates have occurred to the types. //While this will also check new snapshots being added to the system doing
         //the check doesn't hurt anything.
-        getWorkspace().addSPListener(new AbstractPoolingSPListener() {
+ final AbstractPoolingSPListener obsolescenceListener = new AbstractPoolingSPListener(false) {
             @Override
             public void childAddedImpl(SPChildEvent e) {
                 if (e.getChild() instanceof UserDefinedSQLTypeSnapshot) {
@@ -246,6 +248,21 @@
                     }
                 }
             }
+        };
+ getWorkspace().getSnapshotCollection().addSPListener(obsolescenceListener);
+        getWorkspace().addSPListener(new AbstractSPListener() {
+            @Override
+            public void transactionStarted(TransactionEvent e) {
+ obsolescenceListener.transactionStarted(TransactionEvent.createStartTransactionEvent(getWorkspace().getSnapshotCollection(), "Simulated begin: " + e.getMessage()));
+            }
+            @Override
+            public void transactionEnded(TransactionEvent e) {
+ obsolescenceListener.transactionEnded(TransactionEvent.createEndTransactionEvent(getWorkspace().getSnapshotCollection(), "Simulated commit: " + e.getMessage()));
+            }
+            @Override
+            public void transactionRollback(TransactionEvent e) {
+ obsolescenceListener.transactionRollback(TransactionEvent.createRollbackTransactionEvent(getWorkspace().getSnapshotCollection(), "Simulated rollback: " + e.getMessage()));
+            }
         });
     }

Reply via email to