import org.simantics.diagram.adapter.GraphToDiagramSynchronizer;\r
import org.simantics.diagram.elements.TextNode;\r
import org.simantics.diagram.query.DiagramRequests;\r
+import org.simantics.g2d.canvas.Hints;\r
import org.simantics.g2d.canvas.SGDesignation;\r
import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency;\r
import org.simantics.g2d.canvas.impl.SGNodeReflection.SGInit;\r
import org.simantics.sysdyn.ui.elements.LoopFactory;\r
import org.simantics.sysdyn.ui.elements.ShadowFactory;\r
import org.simantics.sysdyn.ui.elements.StockFactory;\r
+import org.simantics.sysdyn.ui.elements.SysdynElementHints;\r
import org.simantics.sysdyn.ui.elements.ValveFactory;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.utils.datastructures.Callback;\r
\r
@EventHandler(priority = -10)\r
public boolean handleKeyboardEvent(KeyEvent ke) {\r
+ \r
+ // ignore this event if we are not in the unmodified pointer tool mode\r
+ if (!Hints.POINTERTOOL.equals(getHint(Hints.KEY_TOOL)) || getHint(SysdynElementHints.SYSDYN_KEY_TOOL) != null) {\r
+ return false;\r
+ }\r
\r
KeyPressedEvent kpe;\r
if (ke instanceof KeyPressedEvent) {\r
} else {\r
return false;\r
}\r
+ \r
+ // only create a variable if we are in the unmodified pointer tool mode\r
+ if (!Hints.POINTERTOOL.equals(getHint(Hints.KEY_TOOL)) || getHint(SysdynElementHints.SYSDYN_KEY_TOOL) != null) {\r
+ return false;\r
+ }\r
\r
if (!\r
(\r
import org.eclipse.ui.handlers.RadioState;\r
import org.simantics.g2d.canvas.Hints;\r
import org.simantics.g2d.canvas.ICanvasContext;\r
-import org.simantics.g2d.canvas.IToolMode;\r
import org.simantics.sysdyn.ui.elements.SysdynElementHints;\r
-import org.simantics.utils.threads.ThreadUtils;\r
\r
public class DiagramToolHandler extends AbstractHandler {\r
\r
\r
String value = (String)event.getCommand().getState(RadioState.STATE_ID).getValue();\r
\r
- final IToolMode mode;\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
+ // to make sure all features of the connection tool work\r
+ // as expected)\r
if ("pointer".equals(value)) {\r
- mode = Hints.POINTERTOOL;\r
+ context.getDefaultHintContext().setHint(Hints.KEY_TOOL, Hints.POINTERTOOL);\r
+ context.getDefaultHintContext().removeHint(SysdynElementHints.SYSDYN_KEY_TOOL);\r
}\r
else if ("dependency".equals(value)) {\r
- mode = SysdynElementHints.DEPENDENCY_TOOL;\r
+ context.getDefaultHintContext().setHint(Hints.KEY_TOOL, Hints.CONNECTTOOL);\r
+ context.getDefaultHintContext().setHint(SysdynElementHints.SYSDYN_KEY_TOOL, SysdynElementHints.DEPENDENCY_TOOL);\r
}\r
else if ("flow".equals(value)) {\r
- mode = SysdynElementHints.FLOW_TOOL;\r
+ context.getDefaultHintContext().setHint(Hints.KEY_TOOL, Hints.CONNECTTOOL);\r
+ context.getDefaultHintContext().setHint(SysdynElementHints.SYSDYN_KEY_TOOL, SysdynElementHints.FLOW_TOOL);\r
}\r
else if ("lock".equals(value)) {\r
- mode = SysdynElementHints.LOCK_TOOL;\r
+ context.getDefaultHintContext().setHint(Hints.KEY_TOOL, Hints.POINTERTOOL);\r
+ context.getDefaultHintContext().setHint(SysdynElementHints.SYSDYN_KEY_TOOL, SysdynElementHints.LOCK_TOOL);\r
}\r
- else {\r
- return null;\r
- }\r
- \r
- ThreadUtils.syncExec(context.getThreadAccess(), new Runnable() {\r
- @Override\r
- public void run() {\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
- // to make sure all features of the connection tool work\r
- // as expected)\r
- context.getDefaultHintContext().setHint(Hints.KEY_TOOL, Hints.CONNECTTOOL);\r
- context.getDefaultHintContext().setHint(SysdynElementHints.SYSDYN_KEY_TOOL, mode);\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
- });\r
\r
return null;\r
}\r