X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.diagram.profile%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fprofile%2Fview%2FProfileCheckContributor.java;h=37e6d81e394a11070a363b86a407a14ede3d1e35;hb=08dc7080753f3ea35985e76e9effb9d3ff92c3b5;hp=2bc9f320fc84b49dd911f906bd627a086be71758;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ProfileCheckContributor.java b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ProfileCheckContributor.java index 2bc9f320f..37e6d81e3 100644 --- a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ProfileCheckContributor.java +++ b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ProfileCheckContributor.java @@ -19,40 +19,39 @@ import org.simantics.db.ReadGraph; 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; + 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); - Collection activeEntries = graph.syncRequest( new ProfileActiveEntryResources(entry.getFirst(), list) ); + if(graph.isInstanceOf(entry, DIA.Profile)) { + Resource list = graph.getPossibleObject(entry, DIA.HasEntries); + Collection activeEntries = graph.syncRequest( new ProfileActiveEntryResources(activeProfile, list) ); if (activeEntries.isEmpty()) { return CheckedState.NOT_CHECKED; } else { - Collection entries = graph.syncRequest( new ProfileEntryResources(entry.getFirst(), list) ); + Collection 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(entry.getFirst(), SIMU.IsActive, entry.getSecond())) return CheckedState.CHECKED; } + if(ProfileUtils.isActive(graph, tuple.getRuntimeDiagram(), activeProfile, entry)) return CheckedState.CHECKED; + return CheckedState.NOT_CHECKED; }