]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Mouse release event to h2d. Context menu uses that event ( release(right) )
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 15 Mar 2010 14:46:47 +0000 (14:46 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 15 Mar 2010 14:46:47 +0000 (14:46 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@14926 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.h2d/src/org/simantics/h2d/canvas/EditorCanvas.java
org.simantics.h2d/src/org/simantics/h2d/event/ReleaseEvent.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/OpenContextMenu.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/TextElement.java

index b2d8e4ddb15e9d2e6c1610dc001b7ce9eb3a01b5..f3df5fff915f6b862c78ea72756c4de3ac3178ae 100644 (file)
@@ -16,7 +16,6 @@ import java.awt.Color;
 import java.awt.Dimension;\r
 import java.awt.Graphics;\r
 import java.awt.Graphics2D;\r
-import java.awt.Rectangle;\r
 import java.awt.RenderingHints;\r
 import java.awt.event.ComponentAdapter;\r
 import java.awt.event.ComponentEvent;\r
@@ -31,12 +30,12 @@ import java.awt.geom.Point2D;
 import java.awt.image.VolatileImage;\r
 \r
 import org.simantics.h2d.editor.IDiagramEditor;\r
-import org.simantics.h2d.editor.impl.DiagramEditor;\r
 import org.simantics.h2d.event.ClickEvent;\r
 import org.simantics.h2d.event.DragEvent;\r
 import org.simantics.h2d.event.DragEventPhase;\r
 import org.simantics.h2d.event.KeyboardEvent;\r
 import org.simantics.h2d.event.Modifiers;\r
+import org.simantics.h2d.event.ReleaseEvent;\r
 import org.simantics.h2d.event.WheelEvent;\r
 import org.simantics.scenegraph.g2d.G2DRenderingHints;\r
 \r
@@ -166,7 +165,15 @@ public class EditorCanvas extends Canvas {
                        if(dragEvent != null && dragEvent.phase == DragEventPhase.dragUpdate) {\r
                                dragEvent.phase = DragEventPhase.dragEnd;\r
                                editor.handleEvent(dragEvent);\r
-                       }\r
+                       } \r
+                       \r
+            ReleaseEvent event = new ReleaseEvent(\r
+                    Modifiers.modifierString(e.getButton(), e.isControlDown(), e.isAltDown(), e.isShiftDown()),\r
+                    editor.screenToDiagram(e.getPoint()),\r
+                    e.getLocationOnScreen()\r
+                    );\r
+            event.pickedElements = dragEvent.pickedElements;\r
+            editor.handleEvent(event);\r
                }\r
 \r
                @Override\r
diff --git a/org.simantics.h2d/src/org/simantics/h2d/event/ReleaseEvent.java b/org.simantics.h2d/src/org/simantics/h2d/event/ReleaseEvent.java
new file mode 100644 (file)
index 0000000..c6d57de
--- /dev/null
@@ -0,0 +1,42 @@
+package org.simantics.h2d.event;\r
+\r
+import java.awt.geom.Point2D;\r
+import java.util.List;\r
+\r
+import org.simantics.h2d.element.IElement;\r
+\r
+public class ReleaseEvent implements ILocatableEvent {\r
+    final public String modifiers;\r
+\r
+    // Release location in diagram coordinates\r
+    final public Point2D point;\r
+    final public Point2D dispPoint;\r
+\r
+    public List<IElement> pickedElements;\r
+\r
+    public ReleaseEvent(String modifiers, Point2D point, Point2D dispPoint) {\r
+        this.modifiers = modifiers;\r
+        this.dispPoint = dispPoint;\r
+        this.point = point;\r
+    }\r
+    \r
+    @Override\r
+    public Point2D getLocation() {\r
+        return point;\r
+    }\r
+\r
+    @Override\r
+    public List<IElement> getPickedElements() {\r
+        return pickedElements;\r
+    }\r
+\r
+    @Override\r
+    public String getType() {\r
+        return getType(modifiers);\r
+    }\r
+    \r
+    public static String getType(String modifiers) {\r
+        return "release(" + modifiers + ")";\r
+    }\r
+\r
+}\r
index 37e856fb58abcdae601a6fe155c9284f5cee8a0e..f2a092e5327b4f0e93fb023736e69c9093ce195a 100644 (file)
@@ -22,8 +22,8 @@ import org.eclipse.swt.widgets.Menu;
 import org.eclipse.ui.IWorkbenchActionConstants;\r
 import org.eclipse.ui.IWorkbenchPartSite;\r
 import org.simantics.h2d.editor.IDiagramEditor;\r
-import org.simantics.h2d.event.ClickEvent;\r
 import org.simantics.h2d.event.IEvent;\r
+import org.simantics.h2d.event.ReleaseEvent;\r
 import org.simantics.h2d.event.handler.IEventHandler;\r
 import org.simantics.ui.action.GraphMenuManager;\r
 \r
@@ -54,7 +54,7 @@ public class OpenContextMenu implements IEventHandler {
 \r
     @Override\r
        public boolean handle(final IDiagramEditor editor, IEvent _event) {\r
-        final ClickEvent event = (ClickEvent)_event;\r
+        final ReleaseEvent event = (ReleaseEvent)_event;\r
         control.getDisplay().asyncExec(new Runnable() {\r
 \r
             @Override\r
index 190b6b2ecb65bf973247d377f2499be8c6a36b34..3333f3949f0872fae784cd692108ca2016f07c93 100644 (file)
@@ -202,7 +202,7 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
                        editor.addEventHandler(1, "key(C)", new CreateCloud());\r
                        editor.addEventHandler(1, "drag(alt+left)", new ConnectDependency());\r
                        editor.addEventHandler(1, "drag(alt+right)", new ConnectFlow());\r
-                       editor.addEventHandler(1, "click(right)", openContextMenu); \r
+                       editor.addEventHandler(1, "release(right)", openContextMenu); \r
                        \r
                canvas = new EditorCanvas(editor);\r
                 frame.add(canvas);\r
index ad45140436c789fc6eeb56bf2d9726981cc107ef..8e1e82a1858ada752059cb9f9ad1dd53f38abee5 100644 (file)
@@ -17,10 +17,6 @@ import java.awt.font.FontRenderContext;
 import java.awt.geom.AffineTransform;\r
 import java.awt.geom.Rectangle2D;\r
 import java.util.List;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.h2d.action.IAction;\r
 import org.simantics.h2d.editor.IDiagramEditor;\r
 import org.simantics.h2d.element.IElement;\r
@@ -34,9 +30,7 @@ import org.simantics.h2d.node.ITextListener;
 import org.simantics.h2d.node.TextNode;\r
 import org.simantics.objmap.annotations.GraphType;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
-import org.simantics.objmap.annotations.UpdateMethod;\r
 import org.simantics.scenegraph.g2d.G2DParentNode;\r
-import org.simantics.sysdyn.SysdynResource;\r
 \r
 @GraphType("http://www.simantics.org/Sysdyn-1.0/Auxiliary")\r
 public class TextElement extends RectangularElement implements Movable, Connectable, IEventHandler {\r
@@ -212,6 +206,8 @@ public class TextElement extends RectangularElement implements Movable, Connecta
     }  \r
 \r
     boolean oldHasEquation = false;\r
+    boolean hasEquation = true;\r
+    /*\r
     boolean hasEquation = false;\r
 \r
     @UpdateMethod\r
@@ -228,4 +224,5 @@ public class TextElement extends RectangularElement implements Movable, Connecta
         }       \r
         return false;\r
     }\r
+    */\r
 }\r