X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.diagram.profile%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fprofile%2Fview%2FActiveProfileModifier.java;h=2045fece906881cbdc374afde81b7843ade39b73;hp=4a3f0e462390d0b1a59bd5981f8b9e8fd086acc6;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ActiveProfileModifier.java b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ActiveProfileModifier.java index 4a3f0e462..2045fece9 100644 --- a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ActiveProfileModifier.java +++ b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ActiveProfileModifier.java @@ -1,47 +1,47 @@ -package org.simantics.diagram.profile.view; - -import org.simantics.Simantics; -import org.simantics.browsing.ui.swt.widgets.impl.ModifyComboListenerImpl; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.common.request.WriteRequest; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.service.VirtualGraphSupport; -import org.simantics.diagram.stubs.DiagramResource; - -public class ActiveProfileModifier extends ModifyComboListenerImpl { - - @Override - public void applySelection(WriteGraph graph, final Resource runtimeDiagram, final Resource profile) throws DatabaseException { - - VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class); - Simantics.getSession().asyncRequest(new WriteRequest(support.getWorkspacePersistent("profiles")) { - - @Override - public void perform(WriteGraph graph) throws DatabaseException { - - DiagramResource DIA = DiagramResource.getInstance(graph); - Resource current = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile); - if(profile.equals(current)) return; - - graph.deny(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile, null, current); - graph.claim(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile, null, profile); - - // Set this profile as the default profile for this model - String modelURI = graph.getRelatedValue(runtimeDiagram, DIA.RuntimeDiagram_HasModelURI); - Resource model = graph.getResource(modelURI); - graph.deny(model, DIA.HasActiveProfile); - graph.claim(model, DIA.HasActiveProfile, profile); - - // Set this profile as the default profile for this diagram - Resource configuration = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasConfiguration); - graph.deny(configuration, DIA.HasActiveProfile); - graph.claim(configuration, DIA.HasActiveProfile, profile); - - } - - }); - - } - -} +package org.simantics.diagram.profile.view; + +import org.simantics.Simantics; +import org.simantics.browsing.ui.swt.widgets.impl.ModifyComboListenerImpl; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.service.VirtualGraphSupport; +import org.simantics.diagram.stubs.DiagramResource; + +public class ActiveProfileModifier extends ModifyComboListenerImpl { + + @Override + public void applySelection(WriteGraph graph, final Resource runtimeDiagram, final Resource profile) throws DatabaseException { + + VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class); + Simantics.getSession().asyncRequest(new WriteRequest(support.getWorkspacePersistent("profiles")) { + + @Override + public void perform(WriteGraph graph) throws DatabaseException { + + DiagramResource DIA = DiagramResource.getInstance(graph); + Resource current = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile); + if(profile.equals(current)) return; + + graph.deny(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile, null, current); + graph.claim(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile, null, profile); + + // Set this profile as the default profile for this model + String modelURI = graph.getRelatedValue(runtimeDiagram, DIA.RuntimeDiagram_HasModelURI); + Resource model = graph.getResource(modelURI); + graph.deny(model, DIA.HasActiveProfile); + graph.claim(model, DIA.HasActiveProfile, profile); + + // Set this profile as the default profile for this diagram + Resource configuration = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasConfiguration); + graph.deny(configuration, DIA.HasActiveProfile); + graph.claim(configuration, DIA.HasActiveProfile, profile); + + } + + }); + + } + +}