X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2FNewSymbolGroupRequest.java;h=71a8c87cf97bbd060e6bcf28478aaf026fe12e1f;hb=76061fee3ffb1b66ed4d78ce711ab44f38b7ffdf;hp=0f3cb7d943af4b8216669d4e1156201e943808a3;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/NewSymbolGroupRequest.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/NewSymbolGroupRequest.java index 0f3cb7d94..71a8c87cf 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/NewSymbolGroupRequest.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/NewSymbolGroupRequest.java @@ -1,38 +1,38 @@ -package org.simantics.modeling; - -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.common.request.WriteResultRequest; -import org.simantics.db.exception.DatabaseException; -import org.simantics.diagram.stubs.DiagramResource; -import org.simantics.layer0.Layer0; - -public class NewSymbolGroupRequest extends WriteResultRequest { - String name; - Resource model; - Resource symbolGroup; - - public NewSymbolGroupRequest(String name, Resource model) { - this.name = name; - this.model = model; - } - - @Override - public Resource perform(WriteGraph graph) throws DatabaseException { - return createNewSymbolGroup(graph, model, name); - } - - public static Resource createNewSymbolGroup(WriteGraph graph, Resource model, String name) throws DatabaseException { - Layer0 L0 = Layer0.getInstance(graph); - DiagramResource DIA = DiagramResource.getInstance(graph); - - // Symbol group - Resource symbolGroup = graph.newResource(); - graph.claim(symbolGroup, L0.PartOf, model); - graph.claim(symbolGroup, L0.InstanceOf, DIA.SymbolReferenceLibrary); - - // Name - graph.claimLiteral(symbolGroup, L0.HasName, name); - return symbolGroup; - } +package org.simantics.modeling; + +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.WriteResultRequest; +import org.simantics.db.exception.DatabaseException; +import org.simantics.diagram.stubs.DiagramResource; +import org.simantics.layer0.Layer0; + +public class NewSymbolGroupRequest extends WriteResultRequest { + String name; + Resource model; + Resource symbolGroup; + + public NewSymbolGroupRequest(String name, Resource model) { + this.name = name; + this.model = model; + } + + @Override + public Resource perform(WriteGraph graph) throws DatabaseException { + return createNewSymbolGroup(graph, model, name); + } + + public static Resource createNewSymbolGroup(WriteGraph graph, Resource model, String name) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + DiagramResource DIA = DiagramResource.getInstance(graph); + + // Symbol group + Resource symbolGroup = graph.newResource(); + graph.claim(symbolGroup, L0.PartOf, model); + graph.claim(symbolGroup, L0.InstanceOf, DIA.SymbolReferenceLibrary); + + // Name + graph.claimLiteral(symbolGroup, L0.HasName, name); + return symbolGroup; + } } \ No newline at end of file