-package org.simantics.modeling;\r
-\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.diagram.stubs.DiagramResource;\r
-import org.simantics.layer0.Layer0;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class NewSymbol {\r
-\r
- public static Resource createSymbol(WriteGraph graph, Resource componentType) throws DatabaseException {\r
-\r
- ModelingResources MOD = ModelingResources.getInstance(graph);\r
- Layer0 L0 = Layer0.getInstance(graph);\r
- DiagramResource DIA = DiagramResource.getInstance(graph);\r
-\r
- // New component type\r
- CommonDBUtils.selectClusterSet(graph, componentType);\r
-\r
- Resource indexRoot = graph.sync(new PossibleIndexRoot(componentType));\r
-\r
- Resource symbolDiagramType = graph.getPossibleObject(indexRoot, MOD.StructuralModel_HasSymbolDiagramType);\r
- if(symbolDiagramType == null) symbolDiagramType = DIA.Composite;\r
-\r
- // Symbol\r
- String symbolName = NameUtils.findFreshName(graph, "Symbol", componentType);\r
- Resource symbol = new ModelingUtils(graph).createSymbol2(symbolName, 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 symbol " + symbolName + ", resource " + symbol));\r
-\r
- return componentType;\r
- }\r
-\r
+package org.simantics.modeling;
+
+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.diagram.stubs.DiagramResource;
+import org.simantics.layer0.Layer0;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class NewSymbol {
+
+ public static Resource createSymbol(WriteGraph graph, Resource componentType) throws DatabaseException {
+
+ ModelingResources MOD = ModelingResources.getInstance(graph);
+ Layer0 L0 = Layer0.getInstance(graph);
+ DiagramResource DIA = DiagramResource.getInstance(graph);
+
+ // New component type
+ CommonDBUtils.selectClusterSet(graph, componentType);
+
+ Resource indexRoot = graph.sync(new PossibleIndexRoot(componentType));
+
+ Resource symbolDiagramType = graph.getPossibleObject(indexRoot, MOD.StructuralModel_HasSymbolDiagramType);
+ if(symbolDiagramType == null) symbolDiagramType = DIA.Composite;
+
+ // Symbol
+ String symbolName = NameUtils.findFreshName(graph, "Symbol", componentType);
+ Resource symbol = new ModelingUtils(graph).createSymbol2(symbolName, 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 symbol " + symbolName + ", resource " + symbol));
+
+ return componentType;
+ }
+
}
\ No newline at end of file