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
\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
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
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
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