<command\r
commandId="org.simantics.sysdyn.ui.exportModelButton"\r
icon="platform:/plugin/com.famfamfam.silk/icons/disk.png"\r
- id="org.simantics.sysdyn.ui.export.button">\r
+ id="org.simantics.sysdyn.ui.export.button"\r
+ tooltip="Save model">\r
</command>\r
<command\r
commandId="org.simantics.sysdyn.ui.exportModelAsButton"\r
icon="icons/save_as.png"\r
- id="org.simantics.sysdyn.ui.exportAs.button">\r
+ id="org.simantics.sysdyn.ui.exportAs.button"\r
+ tooltip="Save model as...">\r
</command>\r
</toolbar>\r
<toolbar\r
</extension>\r
<extension\r
point="org.simantics.ui.toolbarCommand">\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.diagramTool"\r
+ image="platform:/plugin/com.famfamfam.silk/icons/lock.png"\r
+ name="Lock Sketch"\r
+ toolbarId="org.simantics.sysdyn.ui.diagramToolbar"\r
+ type="radio"\r
+ value="lock">\r
+ </command>\r
<command\r
commandId="org.simantics.sysdyn.ui.diagramTool"\r
image="icons/cursor.png"\r
<command\r
commandId="org.simantics.sysdyn.ui.diagramTool"\r
image="icons/dependency.png"\r
- name="Create Dependency"\r
+ name="Create Dependency (Alt+Mouse1)"\r
toolbarId="org.simantics.sysdyn.ui.diagramToolbar"\r
type="radio"\r
value="dependency">\r
<command\r
commandId="org.simantics.sysdyn.ui.diagramTool"\r
image="icons/flow.png"\r
- name="Create Flow"\r
+ name="Create Flow (Alt+Mouse2)"\r
toolbarId="org.simantics.sysdyn.ui.diagramToolbar"\r
type="radio"\r
value="flow">\r
bsi = getDependencyConnectTool(ti, me.mouseId, curCanvasPos);\r
else if (SysdynElementHints.FLOW_TOOL.equals(sysdynMode))\r
bsi = getFlowConnectTool(ti, me.mouseId, curCanvasPos);\r
- else\r
+ else if (SysdynElementHints.LOCK_TOOL.equals(sysdynMode)) {\r
+ // Do nothing.\r
+ } else\r
bsi = getDependencyConnectTool(ti, me.mouseId, curCanvasPos);\r
}\r
else if (me.button == MouseEvent.RIGHT_BUTTON) {\r
import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonPressedEvent;\r
import org.simantics.scenegraph.g2d.events.MouseEvent.MouseClickEvent;\r
import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDoubleClickedEvent;\r
+import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDragBegin;\r
import org.simantics.scenegraph.utils.NodeUtil;\r
+import org.simantics.sysdyn.ui.utils.SysdynWorkbenchUtils;\r
\r
public class HoverTextNode extends TextNode implements ISelectionPainterNode {\r
\r
}\r
return false;\r
}\r
+ \r
+ @Override\r
+ protected boolean mouseDragged(MouseDragBegin e) {\r
+ // Disable dragging if LockSketch is ON\r
+ if (SysdynElementHints.LOCK_TOOL.equals(SysdynWorkbenchUtils.getSysdynToolMode())){\r
+ super.mouseDragged(e);\r
+ return true;}\r
+ else\r
+ return super.mouseDragged(e);\r
+ }\r
\r
public TextEditActivation activateEdit(int mouseId, IElement e, ICanvasContext ctx, boolean save) {\r
if (save)\r
import java.util.Hashtable;\r
\r
import org.simantics.diagram.elements.TextNode;\r
+import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDragBegin;\r
import org.simantics.scenegraph.utils.GeometryUtils;\r
import org.simantics.scenegraph.utils.NodeUtil;\r
+import org.simantics.sysdyn.ui.utils.SysdynWorkbenchUtils;\r
\r
/**\r
* Multi-line text node for diagrams. Editing is not \r
renderSelectedHover(g, isSelected, hover);\r
\r
}\r
-\r
+ \r
+ @Override\r
+ protected boolean mouseDragged(MouseDragBegin e) {\r
+ // Disable dragging if LockSketch is ON\r
+ if (SysdynElementHints.LOCK_TOOL.equals(SysdynWorkbenchUtils.getSysdynToolMode()))\r
+ return false;\r
+ else\r
+ return super.mouseDragged(e);\r
+ }\r
+ \r
}\r
public static final Key SYSDYN_KEY_TOOL = new KeyOf(ToolMode.class, "SysdynKeyTool");\r
public static final IToolMode DEPENDENCY_TOOL = new ToolMode("DependencyTool");\r
public static final IToolMode FLOW_TOOL = new ToolMode("FlowTool");\r
+ public static final IToolMode LOCK_TOOL = new ToolMode("LockTool");\r
\r
}\r
import org.simantics.scenegraph.g2d.nodes.SingleElementNode;\r
import org.simantics.scenegraph.utils.NodeUtil;\r
import org.simantics.sysdyn.ui.editor.routing.DependencyRouter;\r
+import org.simantics.sysdyn.ui.elements.SysdynElementHints;\r
+import org.simantics.sysdyn.ui.utils.SysdynWorkbenchUtils;\r
import org.simantics.utils.datastructures.Pair;\r
\r
/**\r
if (isEventDummy(e)) {\r
return false;\r
}\r
+ \r
+ // Disable dragging if LockSketch is ON\r
+ if (SysdynElementHints.LOCK_TOOL.equals(SysdynWorkbenchUtils.getSysdynToolMode()))\r
+ return false;\r
+ \r
//System.out.println(this.toString() + " event: " + e.toString());\r
boolean selected = NodeUtil.isSelected(this, 2);\r
double myRadialDistance = this.getRadialDistanse(e.controlPosition);\r
import org.simantics.g2d.element.handler.SceneGraph;\r
import org.simantics.scenegraph.g2d.G2DParentNode;\r
import org.simantics.scenegraph.g2d.nodes.connection.IRouteGraphListener;\r
-import org.simantics.scenegraph.g2d.nodes.connection.RouteGraphNode;\r
-\r
\r
\r
public class RouteFlowEdgeClass extends RouteGraphConnectionClass {\r
if (rg == null || renderer == null) {\r
cleanup(connection);\r
} else {\r
- RouteGraphNode rgn = connection.getHint(KEY_RG_NODE);\r
+ RouteFlowNode rgn = connection.getHint(KEY_RG_NODE);\r
if (rgn == null) {\r
- rgn = parent.addNode(ElementUtils.generateNodeId(connection), RouteGraphNode.class);\r
+ rgn = parent.addNode(ElementUtils.generateNodeId(connection), RouteFlowNode.class);\r
connection.setHint(KEY_RG_NODE, rgn);\r
}\r
rgn.setRouteGraph(rg);\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010, 2012 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.elements.connections;\r
+\r
+import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDragBegin;\r
+import org.simantics.scenegraph.g2d.nodes.connection.RouteGraphNode;\r
+import org.simantics.sysdyn.ui.elements.SysdynElementHints;\r
+import org.simantics.sysdyn.ui.utils.SysdynWorkbenchUtils;\r
+\r
+/**\r
+ * Node for flow arrows.\r
+ * @author Tuomas Miettinen\r
+ *\r
+ */\r
+public class RouteFlowNode extends RouteGraphNode {\r
+\r
+ private static final long serialVersionUID = 2576929364910319487L;\r
+ boolean isLock = false;\r
+\r
+ @Override\r
+ protected boolean mouseDragged(MouseDragBegin e) {\r
+ // Disable dragging if LockSketch is ON\r
+ if (SysdynElementHints.LOCK_TOOL.equals(SysdynWorkbenchUtils.getSysdynToolMode()))\r
+ return false;\r
+ else\r
+ return super.mouseDragged(e);\r
+ }\r
+}\r
else if ("flow".equals(value)) {\r
mode = SysdynElementHints.FLOW_TOOL;\r
}\r
+ else if ("lock".equals(value)) {\r
+ mode = SysdynElementHints.LOCK_TOOL;\r
+ }\r
else {\r
return null;\r
}\r
ThreadUtils.syncExec(context.getThreadAccess(), new Runnable() {\r
@Override\r
public void run() {\r
- if (mode.equals(SysdynElementHints.DEPENDENCY_TOOL) || mode.equals(SysdynElementHints.FLOW_TOOL)) {\r
+ if (mode.equals(SysdynElementHints.DEPENDENCY_TOOL) \r
+ || mode.equals(SysdynElementHints.FLOW_TOOL)) {\r
// if one of the connection modes is selected, use the\r
// default connection tool as the base and indicate the\r
// desired connection type in another hint (this is done\r
// as expected)\r
context.getDefaultHintContext().setHint(Hints.KEY_TOOL, Hints.CONNECTTOOL);\r
context.getDefaultHintContext().setHint(SysdynElementHints.SYSDYN_KEY_TOOL, mode);\r
- }\r
- else {\r
+ } else if (mode.equals(SysdynElementHints.LOCK_TOOL)) {\r
+ context.getDefaultHintContext().setHint(Hints.KEY_TOOL, Hints.POINTERTOOL);\r
+ context.getDefaultHintContext().setHint(SysdynElementHints.SYSDYN_KEY_TOOL, mode);\r
+ } else {\r
context.getDefaultHintContext().setHint(Hints.KEY_TOOL, mode);\r
context.getDefaultHintContext().removeHint(SysdynElementHints.SYSDYN_KEY_TOOL);\r
}\r
\r
package org.simantics.sysdyn.ui.utils;\r
\r
+import org.eclipse.ui.IEditorPart;\r
import org.eclipse.ui.IWorkbench;\r
import org.eclipse.ui.IWorkbenchPage;\r
import org.eclipse.ui.IWorkbenchWindow;\r
import org.eclipse.ui.PlatformUI;\r
+import org.simantics.g2d.canvas.ICanvasContext;\r
+import org.simantics.g2d.canvas.IToolMode;\r
import org.simantics.modeling.ui.diagramEditor.DiagramEditor;\r
+import org.simantics.sysdyn.ui.elements.SysdynElementHints;\r
+import org.simantics.utils.datastructures.hints.IHintContext;\r
+import org.simantics.utils.threads.ThreadUtils;\r
\r
/**\r
* Workbench utilities.\r
}\r
return page;\r
}\r
+ \r
+ public static IToolMode getSysdynToolMode() {\r
+ IWorkbenchPage p = SysdynWorkbenchUtils.getActivePageOfEditor();\r
+ IEditorPart editor = p.getActiveEditor();\r
+ final ICanvasContext context = (ICanvasContext)(editor.getAdapter(ICanvasContext.class));\r
+ ToolQuery toolQuery = new ToolQuery(context);\r
+ ThreadUtils.syncExec(context.getThreadAccess(), toolQuery);\r
+ return toolQuery.getSysdynToolMode();\r
+ }\r
+\r
+ static class ToolQuery implements Runnable {\r
+\r
+ private IToolMode mode;\r
+ private ICanvasContext context;\r
+ \r
+ ToolQuery(ICanvasContext context) {\r
+ this.context = context;\r
+ this.mode = null;\r
+ }\r
+ \r
+ @Override\r
+ public void run() {\r
+ IHintContext hc = context.getDefaultHintContext();\r
+ if (hc == null)\r
+ return;\r
+ IToolMode sysdynMode = hc.getHint(SysdynElementHints.SYSDYN_KEY_TOOL);\r
+ mode = sysdynMode;\r
+ }\r
+ \r
+ public IToolMode getSysdynToolMode() {\r
+ return mode;\r
+ }\r
+ \r
+ }\r
}\r