]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/NewComponentType.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / NewComponentType.java
index b0b2e06e1fa1f33f4c1112d9eaf3ade30bd2a7e7..920c30453f36d54f4befbb97f8115a392f67a21e 100644 (file)
@@ -1,76 +1,76 @@
-package org.simantics.modeling;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.CommentMetadata;\r
-import org.simantics.db.common.request.PossibleIndexRoot;\r
-import org.simantics.db.common.utils.CommonDBUtils;\r
-import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.request.InstantiateRequest;\r
-import org.simantics.diagram.stubs.DiagramResource;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.operation.Layer0X;\r
-import org.simantics.structural.stubs.StructuralResource2;\r
-\r
-public class NewComponentType {\r
-       \r
-       public static Resource createComponentType(WriteGraph graph, Resource library) throws DatabaseException {\r
-\r
-        ModelingResources MOD = ModelingResources.getInstance(graph);\r
-        Layer0 L0 = Layer0.getInstance(graph);\r
-        Layer0X L0X = Layer0X.getInstance(graph);\r
-        StructuralResource2 STR = StructuralResource2.getInstance(graph);\r
-        DiagramResource DIA = DiagramResource.getInstance(graph);\r
-\r
-        // New component type\r
-        CommonDBUtils.selectClusterSet(graph, library);\r
-        Resource componentType = graph.newResource();\r
-        graph.newClusterSet(componentType);\r
-        CommonDBUtils.selectClusterSet(graph, componentType);\r
-        \r
-        graph.claim(componentType, L0.PartOf, library);\r
-        \r
-        Resource indexRoot = graph.sync(new PossibleIndexRoot(library));\r
-\r
-        // Supertype\r
-        Resource supertype = graph.getSingleObject(indexRoot, MOD.StructuralModel_HasComponentTypeSupertype);\r
-        graph.claim(componentType, L0.Inherits, null, supertype);\r
-\r
-        // Name\r
-        String defaultName = graph.getRelatedValue(indexRoot, MOD.StructuralModel_HasDefaultComponentTypeName, Bindings.STRING);\r
-        String name = NameUtils.findFreshName(graph, defaultName, library);\r
-        graph.claimLiteral(componentType, L0.HasName, name + "@1");\r
-        graph.claimLiteral(componentType, L0X.HasGeneratedNamePrefix, "");\r
-\r
-        // Substructure\r
-        Resource substructureType = graph.getSingleObject(indexRoot, MOD.StructuralModel_HasComponentTypeSubstructureType);\r
-        Resource composite = new InstantiateRequest(substructureType).perform(graph);\r
-        graph.claim(componentType, STR.IsDefinedBy, composite);\r
-        // These are added to give the configuration a proper URI.\r
-        graph.claimLiteral(composite, L0.HasName, "Configuration");\r
-        graph.claim(componentType, L0.ConsistsOf, composite);\r
-\r
-        // Attach trigger to keep component type interface structures up-to-date\r
-        Resource diagram = graph.getPossibleObject(composite, MOD.CompositeToDiagram);\r
-        if (diagram != null) {\r
-            Resource componentTypeUpdater = graph.newResource();\r
-            graph.claim(componentTypeUpdater, L0.InstanceOf, null, MOD.ComponentTypeUpdater);\r
-            graph.claim(diagram, L0X.HasTrigger, componentTypeUpdater);\r
-        }\r
-\r
-        Resource symbolDiagramType = graph.getPossibleObject(indexRoot, MOD.StructuralModel_HasSymbolDiagramType);\r
-        if(symbolDiagramType == null) symbolDiagramType = DIA.Composite;\r
-        \r
-        // Symbol\r
-        Resource symbol = new ModelingUtils(graph).createSymbol2("Symbol", symbolDiagramType);\r
-        graph.claim(componentType, MOD.ComponentTypeToSymbol, symbol);\r
-        graph.claim(componentType, L0.ConsistsOf, symbol);\r
-        \r
-        CommentMetadata cm = graph.getMetadata(CommentMetadata.class);\r
-        graph.addMetadata(cm.add("Created new user component " + name + ", resource " + componentType));\r
-        \r
-        return componentType;\r
-    }\r
+package org.simantics.modeling;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.CommentMetadata;
+import org.simantics.db.common.request.PossibleIndexRoot;
+import org.simantics.db.common.utils.CommonDBUtils;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.request.InstantiateRequest;
+import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.layer0.Layer0;
+import org.simantics.operation.Layer0X;
+import org.simantics.structural.stubs.StructuralResource2;
+
+public class NewComponentType {
+       
+       public static Resource createComponentType(WriteGraph graph, Resource library) throws DatabaseException {
+
+        ModelingResources MOD = ModelingResources.getInstance(graph);
+        Layer0 L0 = Layer0.getInstance(graph);
+        Layer0X L0X = Layer0X.getInstance(graph);
+        StructuralResource2 STR = StructuralResource2.getInstance(graph);
+        DiagramResource DIA = DiagramResource.getInstance(graph);
+
+        // New component type
+        CommonDBUtils.selectClusterSet(graph, library);
+        Resource componentType = graph.newResource();
+        graph.newClusterSet(componentType);
+        CommonDBUtils.selectClusterSet(graph, componentType);
+        
+        graph.claim(componentType, L0.PartOf, library);
+        
+        Resource indexRoot = graph.sync(new PossibleIndexRoot(library));
+
+        // Supertype
+        Resource supertype = graph.getSingleObject(indexRoot, MOD.StructuralModel_HasComponentTypeSupertype);
+        graph.claim(componentType, L0.Inherits, null, supertype);
+
+        // Name
+        String defaultName = graph.getRelatedValue(indexRoot, MOD.StructuralModel_HasDefaultComponentTypeName, Bindings.STRING);
+        String name = NameUtils.findFreshName(graph, defaultName, library);
+        graph.claimLiteral(componentType, L0.HasName, name + "@1");
+        graph.claimLiteral(componentType, L0X.HasGeneratedNamePrefix, "");
+
+        // Substructure
+        Resource substructureType = graph.getSingleObject(indexRoot, MOD.StructuralModel_HasComponentTypeSubstructureType);
+        Resource composite = new InstantiateRequest(substructureType).perform(graph);
+        graph.claim(componentType, STR.IsDefinedBy, composite);
+        // These are added to give the configuration a proper URI.
+        graph.claimLiteral(composite, L0.HasName, "Configuration");
+        graph.claim(componentType, L0.ConsistsOf, composite);
+
+        // Attach trigger to keep component type interface structures up-to-date
+        Resource diagram = graph.getPossibleObject(composite, MOD.CompositeToDiagram);
+        if (diagram != null) {
+            Resource componentTypeUpdater = graph.newResource();
+            graph.claim(componentTypeUpdater, L0.InstanceOf, null, MOD.ComponentTypeUpdater);
+            graph.claim(diagram, L0X.HasTrigger, componentTypeUpdater);
+        }
+
+        Resource symbolDiagramType = graph.getPossibleObject(indexRoot, MOD.StructuralModel_HasSymbolDiagramType);
+        if(symbolDiagramType == null) symbolDiagramType = DIA.Composite;
+        
+        // Symbol
+        Resource symbol = new ModelingUtils(graph).createSymbol2("Symbol", symbolDiagramType);
+        graph.claim(componentType, MOD.ComponentTypeToSymbol, symbol);
+        graph.claim(componentType, L0.ConsistsOf, symbol);
+        
+        CommentMetadata cm = graph.getMetadata(CommentMetadata.class);
+        graph.addMetadata(cm.add("Created new user component " + name + ", resource " + componentType));
+        
+        return componentType;
+    }
 }
\ No newline at end of file