]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Make sure no more than one SysdynConnectTool is associated with the canvas context...
authorjkauttio <jkauttio@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 21 Nov 2013 14:49:02 +0000 (14:49 +0000)
committerjkauttio <jkauttio@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 21 Nov 2013 14:49:02 +0000 (14:49 +0000)
refs #4511

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28352 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynConnectTool.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynPointerInteractor.java

index 797b18258f77c0b6c123c07d1c0a1d05da99916e..8c2f81908e76643bb488759ab18b19b7f1e8a79c 100644 (file)
@@ -42,8 +42,6 @@ import org.simantics.g2d.routing.IConnection;
 import org.simantics.g2d.routing.IRouter2;\r
 import org.simantics.g2d.routing.TrivialRouter2;\r
 import org.simantics.scenegraph.g2d.G2DParentNode;\r
-import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonEvent;\r
-import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonPressedEvent;\r
 import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent;\r
 import org.simantics.scenegraph.g2d.nodes.ShapeNode;\r
 import org.simantics.scenegraph.g2d.snap.ISnapAdvisor;\r
@@ -380,14 +378,6 @@ public class SysdynConnectTool extends ConnectTool2 {
 \r
         return false;\r
     }\r
-    \r
-    Point2D mousePosition;\r
-    \r
-    protected boolean processMouseButtonPress(MouseButtonPressedEvent e) {\r
-        MouseButtonEvent me = e;\r
-        mousePosition = me.controlPosition;\r
-        return super.processMouseButtonPress(e);\r
-    }\r
 \r
     @Override\r
        protected void createConnection() {\r
index a5a0df8a39453d3b4d0c37ac3dac3dd68e784024..f5ba77d807055d66d2a279d509d53b34f1984c67 100644 (file)
@@ -75,6 +75,7 @@ public class SysdynPointerInteractor extends PointerInteractor {
                super(clickSelect, boxSelect, dragElement, dndDragElement, connect, doubleClickEdit, newConnectionClassProvider);\r
        }\r
 \r
+       @Override\r
        @EventHandler(priority = TOOL_PRIORITY)\r
        public boolean handlePress(MouseButtonPressedEvent me) {\r
                if (!connects()) \r
@@ -82,6 +83,15 @@ public class SysdynPointerInteractor extends PointerInteractor {
                if (elementClassProvider == null)\r
                        return false;\r
                \r
+               // There should (maybe) be only one sysdynConnectTool associated with \r
+               // the canvas context at a time. If this is not the case, right-clicks\r
+               // are not always handled correctly mid-connection as they are instead \r
+               // treated as commands to create a new cloud and a new flow. There\r
+               // might be a more sensible way to fix this.\r
+               if (getContext().containsItemByClass(SysdynConnectTool.class)) {\r
+                       return false;\r
+               }\r
+               \r
                IToolMode mode = getHint(Hints.KEY_TOOL);\r
                if (!Hints.CONNECTTOOL.equals(mode))\r
                        return false;\r
@@ -96,23 +106,25 @@ public class SysdynPointerInteractor extends PointerInteractor {
                ICanvasParticipant bsi = null;\r
                \r
                if (me.button == MouseEvent.LEFT_BUTTON) {\r
-                       if (SysdynElementHints.DEPENDENCY_TOOL.equals(sysdynMode))\r
+                       if (SysdynElementHints.LOCK_TOOL.equals(sysdynMode))\r
+                               // Do nothing.\r
+                               return false;\r
+                       else if (SysdynElementHints.DEPENDENCY_TOOL.equals(sysdynMode))\r
                                bsi = getDependencyConnectTool(ti, me.mouseId, curCanvasPos);\r
                        else if (SysdynElementHints.FLOW_TOOL.equals(sysdynMode))\r
                                bsi = getFlowConnectTool(ti, me.mouseId, curCanvasPos);\r
-                       else if (SysdynElementHints.LOCK_TOOL.equals(sysdynMode)) {\r
-                               // Do nothing.\r
-                       } else\r
+                       else\r
                                bsi = getDependencyConnectTool(ti, me.mouseId, curCanvasPos);\r
                }\r
                else if (me.button == MouseEvent.RIGHT_BUTTON) {\r
-                       if (SysdynElementHints.DEPENDENCY_TOOL.equals(sysdynMode) ||\r
+                       if (SysdynElementHints.LOCK_TOOL.equals(sysdynMode) ||\r
+                                       SysdynElementHints.DEPENDENCY_TOOL.equals(sysdynMode) ||\r
                                        SysdynElementHints.FLOW_TOOL.equals(sysdynMode))\r
                                return false;\r
                        else\r
                                bsi = getFlowConnectTool(ti, me.mouseId, curCanvasPos);\r
                }\r
-\r
+               \r
                if (bsi != null) {\r
                        getContext().add(bsi);\r
                        return true;\r