X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scenegraph.profile%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Fprofile%2FProfileUtils.java;fp=bundles%2Forg.simantics.scenegraph.profile%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Fprofile%2FProfileUtils.java;h=92326248f26007b4eccfda3772ff72d99c6155a5;hp=88a69065be58d358294c0238f263a755ad38aa45;hb=08dc7080753f3ea35985e76e9effb9d3ff92c3b5;hpb=7399881afbe82eb7020ac279604eaa0316724672 diff --git a/bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/ProfileUtils.java b/bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/ProfileUtils.java index 88a69065b..92326248f 100644 --- a/bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/ProfileUtils.java +++ b/bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/ProfileUtils.java @@ -13,7 +13,7 @@ import org.simantics.db.common.request.PossibleIndexRoot; import org.simantics.db.exception.DatabaseException; import org.simantics.diagram.stubs.DiagramResource; import org.simantics.layer0.Layer0; -import org.simantics.scenegraph.profile.request.ProfileActiveEntryResources; +import org.simantics.simulation.ontology.SimulationResource; public class ProfileUtils { @@ -43,9 +43,9 @@ public class ProfileUtils { if(profile.equals(ref)) return state; } return null; - + } - + public static Resource claimProfileActivationState(WriteGraph graph, Resource runtimeDiagram, Resource runtimeProfile, Resource entry) throws DatabaseException { Layer0 L0 = Layer0.getInstance(graph); DiagramResource DIA = DiagramResource.getInstance(graph); @@ -66,6 +66,19 @@ public class ProfileUtils { graph.claim(indexRoot, L0.ConsistsOf, state); return state; } - - + + public static boolean isActive(ReadGraph graph, Resource runtimeDiagram, Resource profile, Resource entry) throws DatabaseException { + DiagramResource DIA = DiagramResource.getInstance(graph); + SimulationResource SIMU = SimulationResource.getInstance(graph); + if(graph.isInstanceOf(entry, DIA.ProfileEntry)) { + if(graph.isImmutable(profile)) { + Resource state = getPossibleProfileActivationState(graph, runtimeDiagram, profile); + if(state != null && graph.hasStatement(state, SIMU.IsActive, entry)) return true; + } else { + if(graph.hasStatement(profile, SIMU.IsActive, entry)) return true; + } + } + return false; + } + }