]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/handler/CanvasCommandDelegate.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / handler / CanvasCommandDelegate.java
index 094fc8722316a47821ad55f954d72c2106cc89a4..9aac515a3f6dfb431f02364d98895b8dd5004fd3 100644 (file)
@@ -1,71 +1,71 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in 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.diagram.handler;\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.ui.IWorkbenchPart;\r
-import org.eclipse.ui.handlers.HandlerUtil;\r
-import org.simantics.g2d.canvas.ICanvasContext;\r
-import org.simantics.g2d.chassis.ICanvasChassis;\r
-import org.simantics.scenegraph.g2d.events.EventDebugPolicy;\r
-import org.simantics.scenegraph.g2d.events.EventQueue;\r
-import org.simantics.scenegraph.g2d.events.command.Command;\r
-import org.simantics.scenegraph.g2d.events.command.CommandEvent;\r
-\r
-/**\r
- * A handler for the Eclipse Command framework that delegates ID of the command\r
- * that triggered the event to the {@link EventQueue} of the\r
- * {@link ICanvasContext} where the event occurred.\r
- */\r
-public class CanvasCommandDelegate extends AbstractHandler {\r
-\r
-    private final boolean DEBUG = EventDebugPolicy.CANVAS_COMMAND_DELEGATION;\r
-\r
-    @Override\r
-    public Object execute(ExecutionEvent event) throws ExecutionException {\r
-        Event e = ((Event)event.getTrigger());\r
-        CommandEvent ce = new CommandEvent(null, e.time, new Command(event.getCommand().getId()));\r
-\r
-        if (DEBUG)\r
-            System.out.println(getClass().getSimpleName() + ": trigger event = " + e + " for command " + ce.command);\r
-\r
-        if (e.widget instanceof ICanvasChassis) {\r
-            ICanvasChassis chassis = (ICanvasChassis) e.widget;\r
-            ICanvasContext canvas = chassis.getCanvasContext();\r
-            if (canvas != null) {\r
-                if (DEBUG)\r
-                    System.out.println(getClass().getSimpleName() + ": sending command " + event.getCommand().getId() + " to " + chassis);\r
-                canvas.getEventQueue().queueEvent( ce );\r
-            }\r
-        } else {\r
-            ICanvasContext canvas = null;\r
-            IWorkbenchPart part = HandlerUtil.getActiveEditor(event);\r
-            if (part != null)\r
-                canvas = (ICanvasContext) part.getAdapter(ICanvasContext.class);\r
-            if (canvas == null) {\r
-                part = HandlerUtil.getActivePart(event);\r
-                if (part != null)\r
-                    canvas = (ICanvasContext) part.getAdapter(ICanvasContext.class);\r
-            }\r
-            if (canvas != null) {\r
-                if (DEBUG)\r
-                    System.out.println(getClass().getSimpleName() + ": sending command " + event.getCommand().getId() + " to " + part);\r
-                canvas.getEventQueue().queueEvent(ce);\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.diagram.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.simantics.g2d.canvas.ICanvasContext;
+import org.simantics.g2d.chassis.ICanvasChassis;
+import org.simantics.scenegraph.g2d.events.EventDebugPolicy;
+import org.simantics.scenegraph.g2d.events.EventQueue;
+import org.simantics.scenegraph.g2d.events.command.Command;
+import org.simantics.scenegraph.g2d.events.command.CommandEvent;
+
+/**
+ * A handler for the Eclipse Command framework that delegates ID of the command
+ * that triggered the event to the {@link EventQueue} of the
+ * {@link ICanvasContext} where the event occurred.
+ */
+public class CanvasCommandDelegate extends AbstractHandler {
+
+    private final boolean DEBUG = EventDebugPolicy.CANVAS_COMMAND_DELEGATION;
+
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        Event e = ((Event)event.getTrigger());
+        CommandEvent ce = new CommandEvent(null, e.time, new Command(event.getCommand().getId()));
+
+        if (DEBUG)
+            System.out.println(getClass().getSimpleName() + ": trigger event = " + e + " for command " + ce.command);
+
+        if (e.widget instanceof ICanvasChassis) {
+            ICanvasChassis chassis = (ICanvasChassis) e.widget;
+            ICanvasContext canvas = chassis.getCanvasContext();
+            if (canvas != null) {
+                if (DEBUG)
+                    System.out.println(getClass().getSimpleName() + ": sending command " + event.getCommand().getId() + " to " + chassis);
+                canvas.getEventQueue().queueEvent( ce );
+            }
+        } else {
+            ICanvasContext canvas = null;
+            IWorkbenchPart part = HandlerUtil.getActiveEditor(event);
+            if (part != null)
+                canvas = (ICanvasContext) part.getAdapter(ICanvasContext.class);
+            if (canvas == null) {
+                part = HandlerUtil.getActivePart(event);
+                if (part != null)
+                    canvas = (ICanvasContext) part.getAdapter(ICanvasContext.class);
+            }
+            if (canvas != null) {
+                if (DEBUG)
+                    System.out.println(getClass().getSimpleName() + ": sending command " + event.getCommand().getId() + " to " + part);
+                canvas.getEventQueue().queueEvent(ce);
+            }
+        }
+        return null;
+    }
+
 }
\ No newline at end of file