]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/TypicalCompositeCopyHandler.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / typicals / TypicalCompositeCopyHandler.java
index f0b3280a28b58541d5bd0aa96f10a34217e608ab..0513bd6bf9f56c7363e1af948a9ef5296042387d 100644 (file)
@@ -1,88 +1,88 @@
-/*******************************************************************************\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.modeling.typicals;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.NamedResource;\r
-import org.simantics.db.common.request.ObjectsWithType;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.util.TransferableGraphConfiguration2;\r
-import org.simantics.diagram.stubs.DiagramResource;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.modeling.ModelingResources;\r
-import org.simantics.modeling.ModelingUtils.CompositeInfo;\r
-import org.simantics.modeling.ModelingUtils.DiagramComponentInfo;\r
-import org.simantics.modeling.adapters.CompositeCopyHandler;\r
-import org.simantics.structural.stubs.StructuralResource2;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class TypicalCompositeCopyHandler extends CompositeCopyHandler {\r
-\r
-    public TypicalCompositeCopyHandler(Resource composite) {\r
-       super(composite);\r
-    }\r
-    \r
-    @Override\r
-    protected TransferableGraphConfiguration2 createConfiguration(ReadGraph graph, boolean cut) throws DatabaseException {\r
-       \r
-       Layer0 L0 = Layer0.getInstance(graph);\r
-       StructuralResource2 SR = StructuralResource2.getInstance(graph);\r
-       DiagramResource DIA = DiagramResource.getInstance(graph);\r
-       ModelingResources MOD = ModelingResources.getInstance(graph);\r
-\r
-       Resource resource = getResource();\r
-       \r
-       // Process joins\r
-       ArrayList<Resource> exclusions = new ArrayList<Resource>();\r
-       for(Resource join : graph.getObjects(resource, SR.HasConnectionJoin)) {\r
-               // Internals are included\r
-               if(graph.getPossibleObject(join, SR.JoinsComposite) != null) continue;\r
-               // Externals are omitted\r
-               exclusions.add(join);\r
-       }\r
-       // Exclude both composite and possible diagram types from copy\r
-       for (Resource type : graph.getObjects(resource, L0.InstanceOf)) {\r
-           if (graph.isInheritedFrom(type, MOD.TypicalComposite)) {\r
-               exclusions.add(type);\r
-           }\r
-       }\r
-       Resource diagram = graph.getPossibleObject(resource, MOD.CompositeToDiagram);\r
-       if (diagram != null) {\r
-            for (Resource type : graph.getObjects(diagram, L0.InstanceOf)) {\r
-                if (graph.isInheritedFrom(type, DIA.Diagram)) {\r
-                    exclusions.add(type);\r
-                }\r
-            }\r
-       }\r
-\r
-       ArrayList<NamedResource> roots = new ArrayList<NamedResource>();\r
-       // Include resource as root\r
-       CompositeInfo info = CompositeInfo.fromResource(graph, resource);\r
-       //String rootName = graph.getRelatedValue(resource, L0.HasName, Bindings.STRING);\r
-       roots.add(new NamedResource(info.getTGName(), resource));\r
-       // Include components as roots\r
-       for(Resource child : graph.sync(new ObjectsWithType(resource, L0.ConsistsOf, SR.Component))) {\r
-               DiagramComponentInfo cinfo = DiagramComponentInfo.fromResource(graph, info, child);\r
-               roots.add(new NamedResource(cinfo.getTGName(info), child));\r
-       }\r
-       \r
-       TransferableGraphConfiguration2 result = TransferableGraphConfiguration2.createWithNames(graph, roots, exclusions, true, false);\r
-       return  result;\r
-       \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.modeling.typicals;
+
+import java.util.ArrayList;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.NamedResource;
+import org.simantics.db.common.request.ObjectsWithType;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.util.TransferableGraphConfiguration2;
+import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.layer0.Layer0;
+import org.simantics.modeling.ModelingResources;
+import org.simantics.modeling.ModelingUtils.CompositeInfo;
+import org.simantics.modeling.ModelingUtils.DiagramComponentInfo;
+import org.simantics.modeling.adapters.CompositeCopyHandler;
+import org.simantics.structural.stubs.StructuralResource2;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class TypicalCompositeCopyHandler extends CompositeCopyHandler {
+
+    public TypicalCompositeCopyHandler(Resource composite) {
+       super(composite);
+    }
+    
+    @Override
+    protected TransferableGraphConfiguration2 createConfiguration(ReadGraph graph, boolean cut) throws DatabaseException {
+       
+       Layer0 L0 = Layer0.getInstance(graph);
+       StructuralResource2 SR = StructuralResource2.getInstance(graph);
+       DiagramResource DIA = DiagramResource.getInstance(graph);
+       ModelingResources MOD = ModelingResources.getInstance(graph);
+
+       Resource resource = getResource();
+       
+       // Process joins
+       ArrayList<Resource> exclusions = new ArrayList<Resource>();
+       for(Resource join : graph.getObjects(resource, SR.HasConnectionJoin)) {
+               // Internals are included
+               if(graph.getPossibleObject(join, SR.JoinsComposite) != null) continue;
+               // Externals are omitted
+               exclusions.add(join);
+       }
+       // Exclude both composite and possible diagram types from copy
+       for (Resource type : graph.getObjects(resource, L0.InstanceOf)) {
+           if (graph.isInheritedFrom(type, MOD.TypicalComposite)) {
+               exclusions.add(type);
+           }
+       }
+       Resource diagram = graph.getPossibleObject(resource, MOD.CompositeToDiagram);
+       if (diagram != null) {
+            for (Resource type : graph.getObjects(diagram, L0.InstanceOf)) {
+                if (graph.isInheritedFrom(type, DIA.Diagram)) {
+                    exclusions.add(type);
+                }
+            }
+       }
+
+       ArrayList<NamedResource> roots = new ArrayList<NamedResource>();
+       // Include resource as root
+       CompositeInfo info = CompositeInfo.fromResource(graph, resource);
+       //String rootName = graph.getRelatedValue(resource, L0.HasName, Bindings.STRING);
+       roots.add(new NamedResource(info.getTGName(), resource));
+       // Include components as roots
+       for(Resource child : graph.sync(new ObjectsWithType(resource, L0.ConsistsOf, SR.Component))) {
+               DiagramComponentInfo cinfo = DiagramComponentInfo.fromResource(graph, info, child);
+               roots.add(new NamedResource(cinfo.getTGName(info), child));
+       }
+       
+       TransferableGraphConfiguration2 result = TransferableGraphConfiguration2.createWithNames(graph, roots, exclusions, true, false);
+       return  result;
+       
+    }
+
+}