id="org.simantics.sysdyn.ui.trend.view.pin.state">\r
</state>\r
</command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.RemoveHandler"\r
+ id="org.simantics.sysdyn.ui.remove"\r
+ name="Remove">\r
+ </command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.CreateAuxiliaryHandler"\r
+ id="org.simantics.sysdyn.ui.createAuxiliary"\r
+ name="Create Auxiliary">\r
+ </command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.CreateCloudHandler"\r
+ id="org.simantics.sysdyn.ui.createCloud"\r
+ name="Create Cloud">\r
+ </command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.CreateStockHandler"\r
+ id="org.simantics.sysdyn.ui.createStock"\r
+ name="Create Stock">\r
+ </command>\r
+ <command\r
+ defaultHandler="org.simantics.sysdyn.ui.handlers.RenameHandler"\r
+ id="org.simantics.sysdyn.ui.rename"\r
+ name="Rename">\r
+ </command>\r
</extension>\r
<extension\r
point="org.eclipse.ui.handlers">\r
commandId="org.simantics.sysdyn.ui.trend.view.pin">\r
</handler>\r
</extension>\r
+ <extension\r
+ point="org.eclipse.ui.menus">\r
+ <menuContribution\r
+ locationURI="popup:#SysdynDiagramPopup?after=wbStart">\r
+ <menu\r
+ label="New...">\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.createAuxiliary"\r
+ label="Auxiliary"\r
+ style="push">\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.createStock"\r
+ label="Stock"\r
+ style="push">\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.createCloud"\r
+ label="Cloud"\r
+ style="push">\r
+ </command>\r
+ </menu>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.rename"\r
+ label="Rename"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ <command\r
+ commandId="org.simantics.sysdyn.ui.remove"\r
+ label="Remove"\r
+ style="push">\r
+ <visibleWhen\r
+ checkEnabled="true">\r
+ </visibleWhen>\r
+ </command>\r
+ </menuContribution>\r
+ </extension>\r
</plugin>\r
getSite().setSelectionProvider(selectionProvider);\r
\r
final OpenContextMenu openContextMenu = new OpenContextMenu(\r
- parent, getSite(), "#ModelingDiagramPopup");\r
+ parent, getSite(), "#SysdynDiagramPopup");\r
\r
SwingUtilities.invokeLater(new Runnable() {\r
\r
--- /dev/null
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.event.IEvent;\r
+import org.simantics.sysdyn.ui.actions.CreateAuxiliary;\r
+\r
+public class CreateAuxiliaryHandler extends DiagramContextMenuActionHandler {\r
+ \r
+ protected void handleEvent(IDiagramEditor editor, IEvent event) {\r
+ CreateAuxiliary ca = new CreateAuxiliary();\r
+ ca.handle(editor, event);\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.event.IEvent;\r
+import org.simantics.sysdyn.ui.actions.CreateCloud;\r
+\r
+public class CreateCloudHandler extends DiagramContextMenuActionHandler {\r
+\r
+ protected void handleEvent(IDiagramEditor editor, IEvent event) {\r
+ CreateCloud cc = new CreateCloud();\r
+ cc.handle(editor, event);\r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.event.IEvent;\r
+import org.simantics.sysdyn.ui.actions.CreateStock;\r
+\r
+public class CreateStockHandler extends DiagramContextMenuActionHandler {\r
+ \r
+ protected void handleEvent(IDiagramEditor editor, IEvent event) {\r
+ CreateStock cs = new CreateStock();\r
+ cs.handle(editor, event);\r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Menu;\r
+import org.eclipse.swt.widgets.MenuItem;\r
+import org.eclipse.ui.IWorkbenchPart;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.event.IEvent;\r
+import org.simantics.sysdyn.ui.actions.DiagramContextMenuData;\r
+import org.simantics.sysdyn.ui.editor.SysdynDiagramEditor;\r
+\r
+public abstract class DiagramContextMenuActionHandler extends AbstractHandler {\r
+ \r
+ @Override\r
+ public Object execute(ExecutionEvent event) throws ExecutionException {\r
+ IWorkbenchPart ap = HandlerUtil.getActivePart(event);\r
+ if(ap instanceof SysdynDiagramEditor) {\r
+ Event ci = (Event)event.getTrigger();\r
+ MenuItem mi = (MenuItem) ci.widget;\r
+ Menu m = mi.getParent();\r
+ while(m.getParentMenu() != null)\r
+ m = m.getParentMenu();\r
+ DiagramContextMenuData cmd = (DiagramContextMenuData) m.getData();\r
+ IDiagramEditor de = cmd.diagramEditor;\r
+ IEvent evnt = cmd.event;\r
+ handleEvent(de, evnt);\r
+ }\r
+ return null;\r
+ }\r
+\r
+ \r
+ protected void handleEvent(IDiagramEditor editor, IEvent event) {\r
+ // Implement in another class\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.event.IEvent;\r
+import org.simantics.h2d.event.handler.Delete;\r
+\r
+public class RemoveHandler extends DiagramContextMenuActionHandler {\r
+ \r
+ protected void handleEvent(IDiagramEditor editor, IEvent event) {\r
+ Delete d = new Delete();\r
+ d.handle(editor, event);\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.simantics.h2d.editor.IDiagramEditor;\r
+import org.simantics.h2d.element.IElement;\r
+import org.simantics.h2d.event.IEvent;\r
+import org.simantics.h2d.event.ILocatableEvent;\r
+import org.simantics.sysdyn.ui.elements.TextElement;\r
+\r
+public class RenameHandler extends DiagramContextMenuActionHandler {\r
+ \r
+ protected void handleEvent(IDiagramEditor editor, IEvent event) {\r
+ ILocatableEvent e = (ILocatableEvent)event;\r
+ if(e.getPickedElements().size() <= 0) return;\r
+ IElement element = e.getPickedElements().get(0);\r
+ if(element instanceof TextElement) {\r
+ TextElement te = (TextElement)element;\r
+ te.beginRenameAction(editor);\r
+ }\r
+ }\r
+\r
+}\r