Revision: 3829
Author: [email protected]
Date: Tue Aug  3 09:52:46 2010
Log: NEW - bug 2837: Update received during drag sticks the table to the mouse
http://trillian.sqlpower.ca/bugzilla/show_bug.cgi?id=2837

Emulating a mouse released event on the FloatingContainerPaneListener when an update from the server is received while dragging a TablePane. Previously, it would bring up a message prompt notifying the user about the conflict while interrupting the drag.
http://code.google.com/p/power-architect/source/detail?r=3829

Modified:
 /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java Fri Jul 16 08:41:08 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java Tue Aug 3 09:52:46 2010
@@ -27,6 +27,7 @@
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
 import java.awt.font.FontRenderContext;
 import java.beans.PropertyChangeEvent;
 import java.util.Collections;
@@ -43,6 +44,7 @@
 import ca.sqlpower.architect.ArchitectUtils;
 import ca.sqlpower.architect.enterprise.NetworkConflictResolver;
import ca.sqlpower.architect.enterprise.NetworkConflictResolver.UpdateListener;
+import ca.sqlpower.architect.swingui.PlayPen.FloatingContainerPaneListener;
 import ca.sqlpower.architect.swingui.event.SelectionEvent;
 import ca.sqlpower.architect.swingui.event.SelectionListener;
 import ca.sqlpower.object.AbstractSPObject;
@@ -105,7 +107,9 @@
             return true;
         }

- public boolean updateException(NetworkConflictResolver resolver, Throwable t) {return false;} + public boolean updateException(NetworkConflictResolver resolver, Throwable t) {
+            return false;
+        }

         public void preUpdatePerformed(NetworkConflictResolver resolver) {
             //do nothing
@@ -667,6 +671,16 @@
                 commit();
             } else {
                 rollback("Update received while dragging");
+
+                // We need to emulate a mouse released event on all the
+ // FloatingContainerPaneListeners since the following message
+                // dialog prompt interrupts the drag.
+ for (MouseMotionListener l : getPlayPen().getMouseMotionListeners()) {
+                    if (l instanceof FloatingContainerPaneListener) {
+ ((FloatingContainerPaneListener) l).mouseReleased(null);
+                    }
+                }
+
JOptionPane.showMessageDialog(getPlayPen(), "There was an update while you were dragging");
             }
         } else {

Reply via email to