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%2Ffunction%2FAll.java;h=51fed01b43436b9046e3f72dade1fcc8d6b7e322;hp=0a3245b52268fb79e4c0a180a80dabae15dda206;hb=11532e91770beadd55d85037c4b5e00bbcace69f;hpb=d0f755ad31c06641f8e9a9010a79356f483340c5 diff --git a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/function/All.java b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/function/All.java index 0a3245b52..51fed01b4 100644 --- a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/function/All.java +++ b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/function/All.java @@ -93,7 +93,7 @@ public class All { return new FunctionImpl1() { - public void processRecursively(WriteGraph graph, Resource runtimeProfile, Resource entry, boolean checked) throws DatabaseException { + public void processRecursively(WriteGraph graph, Resource runtimeDiagram, Resource runtimeProfile, Resource entry, boolean checked) throws DatabaseException { DiagramResource DIA = DiagramResource.getInstance(graph); @@ -110,7 +110,7 @@ public class All { singleSelGroups.add(group); } } - processRecursively(graph, runtimeProfile, child, checked); + processRecursively(graph, runtimeDiagram, runtimeProfile, child, checked); } } else if(graph.isInstanceOf(entry, DIA.ProfileEntry)) { @@ -120,23 +120,43 @@ public class All { //enable selected item from single selection groups, disable the rest. Collection entries = graph.getObjects(group, DIA.ProfileEntry_HasGroup_Inverse); for (Resource e : entries) { - graph.denyStatement(runtimeProfile, SimulationResource.getInstance(graph).IsActive, e); + deactivate(graph, runtimeDiagram, runtimeProfile, e); } - graph.claim(runtimeProfile, SimulationResource.getInstance(graph).IsActive, null, entry); + activate(graph, runtimeDiagram, runtimeProfile, entry); } else { - graph.denyStatement(runtimeProfile, SimulationResource.getInstance(graph).IsActive, entry); + deactivate(graph, runtimeDiagram, runtimeProfile, entry); } } else { if(checked) { - graph.claim(runtimeProfile, SimulationResource.getInstance(graph).IsActive, null, entry); + activate(graph, runtimeDiagram, runtimeProfile, entry); } else { - graph.denyStatement(runtimeProfile, SimulationResource.getInstance(graph).IsActive, entry); + deactivate(graph, runtimeDiagram, runtimeProfile, entry); } } } } + + private void activate(WriteGraph graph, Resource runtimeDiagram, Resource runtimeProfile, Resource entry) throws DatabaseException { + if(graph.isImmutable(runtimeProfile)) { + Resource activationState = ProfileUtils.claimProfileActivationState(graph, runtimeDiagram, runtimeProfile, entry); + if(activationState != null) + graph.claim(activationState, SimulationResource.getInstance(graph).IsActive, null, entry); + } else { + graph.claim(runtimeProfile, SimulationResource.getInstance(graph).IsActive, null, entry); + } + } + + private void deactivate(WriteGraph graph, Resource runtimeDiagram, Resource runtimeProfile, Resource entry) throws DatabaseException { + if(graph.isImmutable(runtimeProfile)) { + Resource activationState = ProfileUtils.claimProfileActivationState(graph, runtimeDiagram, runtimeProfile, entry); + if(activationState != null) + graph.denyStatement(activationState, SimulationResource.getInstance(graph).IsActive, entry); + } else { + graph.denyStatement(runtimeProfile, SimulationResource.getInstance(graph).IsActive, entry); + } + } @Override public Boolean apply(Object _event) { @@ -162,7 +182,7 @@ public class All { DiagramResource DIA = DiagramResource.getInstance(graph); Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile); - processRecursively(graph, runtimeProfile, entry.getSecond(), checked); + processRecursively(graph, runtimeDiagram, runtimeProfile, entry.getSecond(), checked); }