]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Fixed synchronousness problem in drag event transferable handling 54/2254/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 28 Sep 2018 06:19:02 +0000 (09:19 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 28 Sep 2018 06:19:02 +0000 (09:19 +0300)
Previously handleEvent would post the event for asynchronous handling
while handling the drag starting via Transferable requires the drag to
be started synchronously within the AWT drag start event handler.

Added syncHandleEvent to AbstractEventHandler to support this.

gitlab #112

Change-Id: I694844fbfc1be74b9f6b620afc8fc441a0ab4d31

bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/adapter/AWTMouseEventAdapter.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/events/adapter/AbstractEventAdapter.java

index 43653cbd0930abc7da98159406c44a71122ed235..0b33ae3c4f65dda2250adf361cfeb7868d872056 100644 (file)
@@ -62,7 +62,6 @@ import org.simantics.scenegraph.g2d.events.MouseEvent.MouseClickEvent;
 import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDoubleClickedEvent;
 import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDragBegin;
 import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent;
-import org.simantics.scenegraph.g2d.events.NodeEventHandler;
 import org.simantics.scenegraph.g2d.events.command.CommandEvent;
 import org.simantics.scenegraph.g2d.events.command.Commands;
 import org.simantics.scenegraph.utils.GeometryUtils;
index e01876c6d0000dfa1049631cf9d766cf8fbc4713..d5b2aac411e4ac48d39b38a343657450d0e805a5 100644 (file)
@@ -317,7 +317,7 @@ public class AWTMouseEventAdapter extends AbstractEventAdapter implements MouseL
                             controlPos,
                             getScreenPosition(e));
 
-                    handleEvent(event);
+                    syncHandleEvent(event);
 
                     if (event.transferable != null) {
                         ds.startDrag(dge, null, event.transferable, null);
index ef718456847e26c59b273c8c82429ba0594ad0c8..a0e0fd47feaecdf4f834db1d24230ac29b535413 100644 (file)
@@ -53,4 +53,13 @@ public abstract class AbstractEventAdapter {
             delegator.handleEvent(e);
     }
 
+    protected void syncHandleEvent(Event e) {
+        if (queue instanceof IEventHandler)
+            ((IEventHandler) queue).handleEvent(e);
+        else if (delegator != null && EventTypes.passes(delegator, e))
+            delegator.handleEvent(e);
+        else
+            throw new UnsupportedOperationException("Cannot handle event synchronously, no handler available: " + e);
+    }
+
 }