import org.simantics.db.layer0.adapter.Instances;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.service.VirtualGraphSupport;
-import org.simantics.diagram.profile.view.ResourcePair;
+import org.simantics.diagram.profile.view.ProfileTuple;
import org.simantics.diagram.stubs.DiagramResource;
import org.simantics.layer0.Layer0;
import org.simantics.scenegraph.loader.ScenegraphLoaderUtils;
return new FunctionImpl1<Object, Boolean>() {
- 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);
singleSelGroups.add(group);
}
}
- processRecursively(graph, runtimeProfile, child, checked);
+ processRecursively(graph, runtimeDiagram, runtimeProfile, child, checked);
}
} else if(graph.isInstanceOf(entry, DIA.ProfileEntry)) {
//enable selected item from single selection groups, disable the rest.
Collection<Resource> 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) {
final Resource runtimeDiagram = (Resource)explorer.getRoot().getConstant(BuiltinKeys.INPUT);
final boolean checked = item.getChecked();
NodeContext context = (NodeContext)item.getData();
- final ResourcePair entry = (ResourcePair)context.getConstant(BuiltinKeys.INPUT);
+ final ProfileTuple entry = (ProfileTuple)context.getConstant(BuiltinKeys.INPUT);
try {
VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class);
DiagramResource DIA = DiagramResource.getInstance(graph);
Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);
- processRecursively(graph, runtimeProfile, entry.getSecond(), checked);
+ processRecursively(graph, runtimeDiagram, runtimeProfile, entry.getEntry(), checked);
}