X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2FNewSymbol.java;h=73c92474f801cfc128c044e94bfc0aea070e4aa7;hb=76061fee3ffb1b66ed4d78ce711ab44f38b7ffdf;hp=9d66219fe2d8caf196a92144c2d5f24453fd49ea;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/NewSymbol.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/NewSymbol.java index 9d66219fe..73c92474f 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/NewSymbol.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/NewSymbol.java @@ -1,44 +1,44 @@ -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; - } - +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