]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
SysdynDiagramPopup. Rename, remove and new auxiliary, stock and cloud
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 15 Feb 2010 16:22:14 +0000 (16:22 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 15 Feb 2010 16:22:14 +0000 (16:22 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@14127 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateAuxiliaryHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateCloudHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateStockHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/DiagramContextMenuActionHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/RemoveHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/RenameHandler.java [new file with mode: 0644]

index 123919d6eb4694aba33abf2312cc9ce5adf1b3a3..a88112075d1ed17ef793eb7004ed4916b6064be8 100644 (file)
                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
index 3d145457295234a78e01d73b4a126d661e004db1..1ec2b9234bcdbc8a3f09ef3c1d4ba84549b7b0dd 100644 (file)
@@ -157,7 +157,7 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
         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
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateAuxiliaryHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateAuxiliaryHandler.java
new file mode 100644 (file)
index 0000000..27c16ad
--- /dev/null
@@ -0,0 +1,14 @@
+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
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateCloudHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateCloudHandler.java
new file mode 100644 (file)
index 0000000..9d814ab
--- /dev/null
@@ -0,0 +1,13 @@
+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
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateStockHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/CreateStockHandler.java
new file mode 100644 (file)
index 0000000..97ac9ef
--- /dev/null
@@ -0,0 +1,13 @@
+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
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/DiagramContextMenuActionHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/DiagramContextMenuActionHandler.java
new file mode 100644 (file)
index 0000000..a0f8b93
--- /dev/null
@@ -0,0 +1,40 @@
+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
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/RemoveHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/RemoveHandler.java
new file mode 100644 (file)
index 0000000..5a3eb4e
--- /dev/null
@@ -0,0 +1,14 @@
+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
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/RenameHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/RenameHandler.java
new file mode 100644 (file)
index 0000000..df91645
--- /dev/null
@@ -0,0 +1,21 @@
+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