From: jkauttio Date: Thu, 21 Nov 2013 14:49:02 +0000 (+0000) Subject: Make sure no more than one SysdynConnectTool is associated with the canvas context... X-Git-Tag: 1.8.1~187 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=60b90d49c925f85d04d34eea203c6434bc3ed7e9;p=simantics%2Fsysdyn.git Make sure no more than one SysdynConnectTool is associated with the canvas context at a time. Still need to figure out if and how the behaviour of mouse clicks during connection and flow creation should be overridden. refs #4511 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28352 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynConnectTool.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynConnectTool.java index 797b1825..8c2f8190 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynConnectTool.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynConnectTool.java @@ -42,8 +42,6 @@ import org.simantics.g2d.routing.IConnection; import org.simantics.g2d.routing.IRouter2; import org.simantics.g2d.routing.TrivialRouter2; import org.simantics.scenegraph.g2d.G2DParentNode; -import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonEvent; -import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonPressedEvent; import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent; import org.simantics.scenegraph.g2d.nodes.ShapeNode; import org.simantics.scenegraph.g2d.snap.ISnapAdvisor; @@ -380,14 +378,6 @@ public class SysdynConnectTool extends ConnectTool2 { return false; } - - Point2D mousePosition; - - protected boolean processMouseButtonPress(MouseButtonPressedEvent e) { - MouseButtonEvent me = e; - mousePosition = me.controlPosition; - return super.processMouseButtonPress(e); - } @Override protected void createConnection() { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynPointerInteractor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynPointerInteractor.java index a5a0df8a..f5ba77d8 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynPointerInteractor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynPointerInteractor.java @@ -75,6 +75,7 @@ public class SysdynPointerInteractor extends PointerInteractor { super(clickSelect, boxSelect, dragElement, dndDragElement, connect, doubleClickEdit, newConnectionClassProvider); } + @Override @EventHandler(priority = TOOL_PRIORITY) public boolean handlePress(MouseButtonPressedEvent me) { if (!connects()) @@ -82,6 +83,15 @@ public class SysdynPointerInteractor extends PointerInteractor { if (elementClassProvider == null) return false; + // There should (maybe) be only one sysdynConnectTool associated with + // the canvas context at a time. If this is not the case, right-clicks + // are not always handled correctly mid-connection as they are instead + // treated as commands to create a new cloud and a new flow. There + // might be a more sensible way to fix this. + if (getContext().containsItemByClass(SysdynConnectTool.class)) { + return false; + } + IToolMode mode = getHint(Hints.KEY_TOOL); if (!Hints.CONNECTTOOL.equals(mode)) return false; @@ -96,23 +106,25 @@ public class SysdynPointerInteractor extends PointerInteractor { ICanvasParticipant bsi = null; if (me.button == MouseEvent.LEFT_BUTTON) { - if (SysdynElementHints.DEPENDENCY_TOOL.equals(sysdynMode)) + if (SysdynElementHints.LOCK_TOOL.equals(sysdynMode)) + // Do nothing. + return false; + else if (SysdynElementHints.DEPENDENCY_TOOL.equals(sysdynMode)) bsi = getDependencyConnectTool(ti, me.mouseId, curCanvasPos); else if (SysdynElementHints.FLOW_TOOL.equals(sysdynMode)) bsi = getFlowConnectTool(ti, me.mouseId, curCanvasPos); - else if (SysdynElementHints.LOCK_TOOL.equals(sysdynMode)) { - // Do nothing. - } else + else bsi = getDependencyConnectTool(ti, me.mouseId, curCanvasPos); } else if (me.button == MouseEvent.RIGHT_BUTTON) { - if (SysdynElementHints.DEPENDENCY_TOOL.equals(sysdynMode) || + if (SysdynElementHints.LOCK_TOOL.equals(sysdynMode) || + SysdynElementHints.DEPENDENCY_TOOL.equals(sysdynMode) || SysdynElementHints.FLOW_TOOL.equals(sysdynMode)) return false; else bsi = getFlowConnectTool(ti, me.mouseId, curCanvasPos); } - + if (bsi != null) { getContext().add(bsi); return true;