import org.simantics.db.Resource;
import org.simantics.db.exception.DatabaseException;
import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.scenegraph.profile.ProfileUtils;
import org.simantics.scenegraph.profile.request.ProfileActiveEntryResources;
import org.simantics.scenegraph.profile.request.ProfileEntryResources;
-import org.simantics.simulation.ontology.SimulationResource;
public class ProfileCheckContributor implements CheckedStateRule {
@Override
public boolean isCompatible(Class<?> contentType) {
- return contentType.equals(ResourcePair.class);
+ return contentType.equals(ProfileTuple.class);
}
@Override
public CheckedState getCheckedState(ReadGraph graph, Object parent)
throws DatabaseException {
- ResourcePair entry = (ResourcePair)parent;
- Resource activeProfile = entry.getFirst();
+ ProfileTuple tuple = (ProfileTuple)parent;
+ Resource activeProfile = tuple.getBaseProfile();
+ Resource entry = tuple.getEntry();
DiagramResource DIA = DiagramResource.getInstance(graph);
- SimulationResource SIMU = SimulationResource.getInstance(graph);
- if(graph.isInstanceOf(entry.getSecond(), DIA.Profile)) {
- Resource list = graph.getPossibleObject(entry.getSecond(), DIA.HasEntries);
+ if(graph.isInstanceOf(entry, DIA.Profile)) {
+ Resource list = graph.getPossibleObject(entry, DIA.HasEntries);
Collection<Resource> activeEntries = graph.syncRequest( new ProfileActiveEntryResources(activeProfile, list) );
if (activeEntries.isEmpty()) {
return CheckedState.NOT_CHECKED;
Collection<Resource> entries = graph.syncRequest( new ProfileEntryResources(activeProfile, list) );
return entries.equals(activeEntries) ? CheckedState.CHECKED : CheckedState.GRAYED;
}
-
- } else if(graph.isInstanceOf(entry.getSecond(), DIA.ProfileEntry)) {
- if(graph.hasStatement(activeProfile, SIMU.IsActive, entry.getSecond())) return CheckedState.CHECKED;
}
+ if(ProfileUtils.isActive(graph, tuple.getRuntimeDiagram(), activeProfile, entry)) return CheckedState.CHECKED;
+
return CheckedState.NOT_CHECKED;
}