]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/handler/PasteOperation.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / handler / PasteOperation.java
index d10fd2141adfb8565a0b3cf46fb26530047cac3d..7dee9635a446a790f3376d49deedb8cde4e10402 100644 (file)
-/*******************************************************************************\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 java.awt.geom.Point2D;\r
-import java.util.Collections;\r
-import java.util.Map;\r
-\r
-import org.simantics.db.Resource;\r
-import org.simantics.g2d.canvas.ICanvasContext;\r
-import org.simantics.g2d.diagram.IDiagram;\r
-import org.simantics.scenegraph.g2d.events.command.Command;\r
-\r
-/**\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-public final class PasteOperation {\r
-\r
-    /**\r
-     * Optional specifications for the paste operation that can be given through.\r
-     */\r
-    public static interface PasteOption {}\r
-\r
-    /**\r
-     * For forcing pasting of diagram reference elements even when the parent\r
-     * element of the reference element is not included in the copied material.\r
-     */\r
-    public static enum ForceCopyReferences implements PasteOption { INSTANCE }\r
-\r
-    // Input\r
-    public final Command                 command;\r
-    public final ICanvasContext          ctx;\r
-    public final Resource                sourceDiagram;\r
-    public final Resource                targetDiagram;\r
-    public final IDiagram                target;\r
-    public final ElementObjectAssortment ea;\r
-    public final boolean                 cut;\r
-    public final Point2D                 offset;\r
-\r
-    public Map<Resource, Resource>       initialNodeMap;\r
-\r
-    public PasteOption[]                 options;\r
-\r
-    // Output\r
-    public final Map<Object, Object>     copyMap;\r
-\r
-    public PasteOperation(\r
-            Command command,\r
-            ICanvasContext ctx,\r
-            Resource sourceDiagram,\r
-            Resource targetDiagram,\r
-            IDiagram target,\r
-            ElementObjectAssortment ea,\r
-            boolean cut,\r
-            Point2D offset,\r
-            Map<Resource, Resource> initialNodeMap,\r
-            Map<Object, Object> copyMap\r
-    ) {\r
-        if (sourceDiagram == null)\r
-            throw new IllegalArgumentException("null source diagram");\r
-        if (targetDiagram == null)\r
-            throw new IllegalArgumentException("null target diagram");\r
-\r
-        this.command = command;\r
-        this.ctx = ctx;\r
-        this.sourceDiagram = sourceDiagram;\r
-        this.targetDiagram = targetDiagram;\r
-        this.target = target;\r
-        this.ea = ea;\r
-        this.cut = cut;\r
-        this.offset = offset;\r
-        this.copyMap = copyMap;\r
-        this.initialNodeMap = initialNodeMap;\r
-    }\r
-\r
-    public PasteOperation(\r
-            Command command,\r
-            ICanvasContext ctx,\r
-            Resource sourceDiagram,\r
-            Resource targetDiagram,\r
-            IDiagram target,\r
-            ElementObjectAssortment ea,\r
-            boolean cut,\r
-            Point2D offset,\r
-            Map<Resource, Resource> initialNodeMap\r
-    ) {\r
-        this(command, ctx, sourceDiagram, targetDiagram, target, ea, cut, offset, initialNodeMap, null);\r
-    }\r
-\r
-    public PasteOperation(\r
-            Command command,\r
-            ICanvasContext ctx,\r
-            Resource sourceDiagram,\r
-            Resource targetDiagram,\r
-            IDiagram target,\r
-            ElementObjectAssortment ea,\r
-            boolean cut,\r
-            Point2D offset\r
-    ) {\r
-        this(command, ctx, sourceDiagram, targetDiagram, target, ea, cut, offset, Collections.<Resource, Resource>emptyMap());\r
-    }\r
-\r
-    public PasteOperation options(PasteOption... options) {\r
-        this.options = options;\r
-        return this;\r
-    }\r
-\r
-    public boolean sameDiagram() {\r
-        return sourceDiagram.equals(targetDiagram);\r
-    }\r
-\r
-    @SuppressWarnings("unchecked")\r
-    public <T extends PasteOption> T getOption(Class<T> clazz) {\r
-        if (options == null)\r
-            return null;\r
-        for (PasteOption option : options) {\r
-            if (clazz.isInstance(option))\r
-                return (T) option;\r
-        }\r
-        return null;\r
-    }\r
-\r
-    public <T extends PasteOption> boolean hasOption(Class<T> clazz) {\r
-        return getOption(clazz) != null;\r
-    }\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 java.awt.geom.Point2D;
+import java.util.Collections;
+import java.util.Map;
+
+import org.simantics.db.Resource;
+import org.simantics.g2d.canvas.ICanvasContext;
+import org.simantics.g2d.diagram.IDiagram;
+import org.simantics.scenegraph.g2d.events.command.Command;
+
+/**
+ * 
+ * @author Tuukka Lehtonen
+ */
+public final class PasteOperation {
+
+    /**
+     * Optional specifications for the paste operation that can be given through.
+     */
+    public static interface PasteOption {}
+
+    /**
+     * For forcing pasting of diagram reference elements even when the parent
+     * element of the reference element is not included in the copied material.
+     */
+    public static enum ForceCopyReferences implements PasteOption { INSTANCE }
+
+    // Input
+    public final Command                 command;
+    public final ICanvasContext          ctx;
+    public final Resource                sourceDiagram;
+    public final Resource                targetDiagram;
+    public final IDiagram                target;
+    public final ElementObjectAssortment ea;
+    public final boolean                 cut;
+    public final Point2D                 offset;
+
+    public Map<Resource, Resource>       initialNodeMap;
+
+    public PasteOption[]                 options;
+
+    // Output
+    public final Map<Object, Object>     copyMap;
+
+    public PasteOperation(
+            Command command,
+            ICanvasContext ctx,
+            Resource sourceDiagram,
+            Resource targetDiagram,
+            IDiagram target,
+            ElementObjectAssortment ea,
+            boolean cut,
+            Point2D offset,
+            Map<Resource, Resource> initialNodeMap,
+            Map<Object, Object> copyMap
+    ) {
+        if (sourceDiagram == null)
+            throw new IllegalArgumentException("null source diagram");
+        if (targetDiagram == null)
+            throw new IllegalArgumentException("null target diagram");
+
+        this.command = command;
+        this.ctx = ctx;
+        this.sourceDiagram = sourceDiagram;
+        this.targetDiagram = targetDiagram;
+        this.target = target;
+        this.ea = ea;
+        this.cut = cut;
+        this.offset = offset;
+        this.copyMap = copyMap;
+        this.initialNodeMap = initialNodeMap;
+    }
+
+    public PasteOperation(
+            Command command,
+            ICanvasContext ctx,
+            Resource sourceDiagram,
+            Resource targetDiagram,
+            IDiagram target,
+            ElementObjectAssortment ea,
+            boolean cut,
+            Point2D offset,
+            Map<Resource, Resource> initialNodeMap
+    ) {
+        this(command, ctx, sourceDiagram, targetDiagram, target, ea, cut, offset, initialNodeMap, null);
+    }
+
+    public PasteOperation(
+            Command command,
+            ICanvasContext ctx,
+            Resource sourceDiagram,
+            Resource targetDiagram,
+            IDiagram target,
+            ElementObjectAssortment ea,
+            boolean cut,
+            Point2D offset
+    ) {
+        this(command, ctx, sourceDiagram, targetDiagram, target, ea, cut, offset, Collections.<Resource, Resource>emptyMap());
+    }
+
+    public PasteOperation options(PasteOption... options) {
+        this.options = options;
+        return this;
+    }
+
+    public boolean sameDiagram() {
+        return sourceDiagram.equals(targetDiagram);
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T extends PasteOption> T getOption(Class<T> clazz) {
+        if (options == null)
+            return null;
+        for (PasteOption option : options) {
+            if (clazz.isInstance(option))
+                return (T) option;
+        }
+        return null;
+    }
+
+    public <T extends PasteOption> boolean hasOption(Class<T> clazz) {
+        return getOption(clazz) != null;
+    }
+
+}