]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Better support for ontological profiles 19/919/5
authorAntti Villberg <antti.villberg@semantum.fi>
Tue, 5 Sep 2017 18:05:51 +0000 (21:05 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 6 Sep 2017 09:38:36 +0000 (12:38 +0300)
refs #7465

Change-Id: I6b832067db3a7db4903934c97b4c9e48ee301c0a

20 files changed:
bundles/org.simantics.diagram.ontology/graph/DiagramProfiles.pgraph
bundles/org.simantics.diagram.ontology/graph/ProfilesView.pgraph
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/function/All.java
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/DirectProfileEntries.java
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/EntryLabeler.java
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ProfileCheckContributor.java
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ProfileEntryChildren.java
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ProfileEntrySelectionListener.java
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ProfileSelectionProcessor.java
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ProfileTuple.java [new file with mode: 0644]
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/RemoveEntriesAction.java
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ResourcePair.java [deleted file]
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ResourcePairImageRule.java
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ResourcePairLabelRule.java
bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/RuntimeDirectProfileEntries.java
bundles/org.simantics.diagram/adapters.xml
bundles/org.simantics.diagram/src/org/simantics/diagram/profile/SCLTextGridStyle.java
bundles/org.simantics.diagram/src/org/simantics/diagram/profile/TextGridStyle.java
bundles/org.simantics.g2d.ontology/graph/G2D.pgraph
bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/ProfileUtils.java

index ef868a5043b604b8f94a566d07320ed35d05b7eb..ae177ce7d812f088beab575ae6dbb1def36e559b 100644 (file)
@@ -61,7 +61,7 @@ DIA.ConstantStyle <T DIA.Style
 DIA.ExpressionStyle <T DIA.Style
 
 DIA.SCLTextGridStyle <T DIA.Style
 DIA.ExpressionStyle <T DIA.Style
 
 DIA.SCLTextGridStyle <T DIA.Style
-  >-- DIA.SCLTextGridStyle.function ==> "Variable -> <ReadGraph> String" <R L0.HasProperty : L0.TotalFunction
+  >-- DIA.SCLTextGridStyle.texts ==> "Variable -> <ReadGraph> (String,String,String)" <R L0.HasProperty : L0.TotalFunction
 
 DIA.SCLTextStyle <T DIA.Style
 DIA.BasicExpressionTextStyle <T DIA.Style
 
 DIA.SCLTextStyle <T DIA.Style
 DIA.BasicExpressionTextStyle <T DIA.Style
index ae326ca88b0144df4f50930c6c99f500bb846519..7688a874cd82d96112c458f429dfad1cfd48f8c3 100644 (file)
@@ -10,7 +10,7 @@ BC = DIA.ProfilesBrowseContext : VP.BrowseContext
 // TODO: this .pgraph shouldn't be here, but in a separate "UI" ontology
 
 BC.Entry : VP.ResourceNodeType
 // TODO: this .pgraph shouldn't be here, but in a separate "UI" ontology
 
 BC.Entry : VP.ResourceNodeType
-  VP.HasContentType "org.simantics.diagram.profile.view.ResourcePair"
+  VP.HasContentType "org.simantics.diagram.profile.view.ProfileTuple"
   VP.HasBundle "org.simantics.diagram.profile"
 BC.EntryLabelRule : VP.LabelRule
 BC.EntryImageRule : VP.ImageRule
   VP.HasBundle "org.simantics.diagram.profile"
 BC.EntryLabelRule : VP.LabelRule
 BC.EntryImageRule : VP.ImageRule
index 51fed01b43436b9046e3f72dade1fcc8d6b7e322..998138765ca37aca0f850a08064fc03a0873f5ef 100644 (file)
@@ -26,7 +26,7 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.Instances;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.service.VirtualGraphSupport;
 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;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.layer0.Layer0;
 import org.simantics.scenegraph.loader.ScenegraphLoaderUtils;
@@ -171,7 +171,7 @@ public class All {
                    final Resource runtimeDiagram = (Resource)explorer.getRoot().getConstant(BuiltinKeys.INPUT);
                    final boolean checked = item.getChecked();
                    NodeContext context = (NodeContext)item.getData();
                    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);
                    try {
                        
                        VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class);
@@ -182,7 +182,7 @@ public class All {
                                
                                DiagramResource DIA = DiagramResource.getInstance(graph);
                                Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);
                                
                                DiagramResource DIA = DiagramResource.getInstance(graph);
                                Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);
-                               processRecursively(graph, runtimeDiagram, runtimeProfile, entry.getSecond(), checked);
+                               processRecursively(graph, runtimeDiagram, runtimeProfile, entry.getEntry(), checked);
                                
                            }
 
                                
                            }
 
index 3da411b0cec5be1fb89b9e2d8598e8a157139031..7ad7b0e6d5e81b536f286219e20a78eb0caa5325 100644 (file)
@@ -21,20 +21,20 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.scenegraph.profile.ProfileUtils;
 
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.scenegraph.profile.ProfileUtils;
 
-public class DirectProfileEntries extends UnaryRead<ResourcePair, List<ResourcePair>> {
+public class DirectProfileEntries extends UnaryRead<ProfileTuple, List<ProfileTuple>> {
 
 
-       public DirectProfileEntries(ResourcePair resource) {
-               super(resource);
+       public DirectProfileEntries(ProfileTuple tuple) {
+               super(tuple);
        }
 
        @Override
        }
 
        @Override
-       public List<ResourcePair> perform(ReadGraph graph) throws DatabaseException {
+       public List<ProfileTuple> perform(ReadGraph graph) throws DatabaseException {
                DiagramResource dr = DiagramResource.getInstance(graph);
                DiagramResource dr = DiagramResource.getInstance(graph);
-               ArrayList<ResourcePair> entries = new ArrayList<ResourcePair>();
-               Resource list = graph.getPossibleObject(parameter.getSecond(), dr.HasEntries);
+               List<ProfileTuple> entries = new ArrayList<>();
+               Resource list = graph.getPossibleObject(parameter.getEntry(), dr.HasEntries);
                if(list == null) return entries;
                for(Resource entry : ProfileUtils.getProfileChildrenFromEntries(graph, list)) {
                if(list == null) return entries;
                for(Resource entry : ProfileUtils.getProfileChildrenFromEntries(graph, list)) {
-                       entries.add(new ResourcePair(parameter.getFirst(), entry));
+                       entries.add(new ProfileTuple(parameter.getBaseProfile(), entry, parameter.getRuntimeDiagram()));
                }
                return entries;
        }
                }
                return entries;
        }
index 00a9b7a58f7f028456d6582b10efbd005b00e75b..b05f0e449a3fdac36f2279d5c34da37d61e9d384 100644 (file)
@@ -15,11 +15,11 @@ import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.exception.DatabaseException;
 
 import org.simantics.db.ReadGraph;
 import org.simantics.db.exception.DatabaseException;
 
-public class EntryLabeler extends LabelerContributor<ResourcePair> {
+public class EntryLabeler extends LabelerContributor<ProfileTuple> {
 
     @Override
 
     @Override
-    public String getLabel(ReadGraph graph, ResourcePair entry) throws DatabaseException {
-       return graph.adapt(entry.getSecond(), String.class);
+    public String getLabel(ReadGraph graph, ProfileTuple entry) throws DatabaseException {
+       return graph.adapt(entry.getEntry(), String.class);
     }
 
 }
     }
 
 }
index 544c394c52714373d7746b71d1e8b3f60d4667a8..37e6d81e394a11070a363b86a407a14ede3d1e35 100644 (file)
@@ -19,28 +19,28 @@ 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.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.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) {
 
 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 {
 
     }
 
     @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);
         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> activeEntries = graph.syncRequest( new ProfileActiveEntryResources(activeProfile, list) );
             if (activeEntries.isEmpty()) {
                 return CheckedState.NOT_CHECKED;
@@ -48,11 +48,10 @@ public class ProfileCheckContributor implements CheckedStateRule {
                 Collection<Resource> entries = graph.syncRequest( new ProfileEntryResources(activeProfile, list) );
                 return entries.equals(activeEntries) ? CheckedState.CHECKED : CheckedState.GRAYED;
             }
                 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;
 
     }
         return CheckedState.NOT_CHECKED;
 
     }
index d16a776c7c1e24826fb59ff26e4d3c334ab65f14..712bd50fb6f3fa8ce0ce72265328f06e07e90ac5 100644 (file)
@@ -18,7 +18,6 @@ import java.util.Collections;
 import org.simantics.browsing.ui.model.children.ChildRule;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.browsing.ui.model.children.ChildRule;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
-import org.simantics.db.common.utils.ListUtils;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.scenegraph.profile.ProfileUtils;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.scenegraph.profile.ProfileUtils;
@@ -27,28 +26,28 @@ public class ProfileEntryChildren implements ChildRule {
 
        @Override
        public boolean isCompatible(Class<?> contentType) {
 
        @Override
        public boolean isCompatible(Class<?> contentType) {
-               return contentType.equals(ResourcePair.class);
+               return contentType.equals(ProfileTuple.class);
        }
 
        @Override
        public Collection<?> getChildren(ReadGraph graph, Object parent)
                        throws DatabaseException {
        }
 
        @Override
        public Collection<?> getChildren(ReadGraph graph, Object parent)
                        throws DatabaseException {
-
-               ResourcePair entry = (ResourcePair)parent;
-       ArrayList<ResourcePair> entries = new ArrayList<ResourcePair>();
-       DiagramResource DIA = DiagramResource.getInstance(graph);
-       Resource children = graph.getPossibleObject(entry.getSecond(), DIA.HasEntries);
-       if(children == null) return Collections.emptyList();
-       else {
-               for(Resource entry2 : ProfileUtils.getProfileChildrenFromEntries(graph, children)) entries.add(new ResourcePair(entry.getFirst(), entry2));
-               return entries;
-       }
-    }
+               ProfileTuple entry = (ProfileTuple) parent;
+               ArrayList<ProfileTuple> entries = new ArrayList<>();
+               DiagramResource DIA = DiagramResource.getInstance(graph);
+               Resource children = graph.getPossibleObject(entry.getEntry(), DIA.HasEntries);
+               if (children != null) {
+                       for (Resource entry2 : ProfileUtils.getProfileChildrenFromEntries(graph, children))
+                               entries.add(new ProfileTuple(entry.getBaseProfile(), entry2, entry.getRuntimeDiagram()));
+                       return entries;
+               }
+               return Collections.emptyList();
+       }
 
        @Override
        public Collection<?> getParents(ReadGraph graph, Object child)
                        throws DatabaseException {
 
        @Override
        public Collection<?> getParents(ReadGraph graph, Object child)
                        throws DatabaseException {
-               return new ArrayList<Resource>();
+               return Collections.emptyList();
        }
 
 }
        }
 
 }
index c67558b2733323f25053b134778e8bef974f65e6..f87a8286bb43fa8c06e8006c4d416847003b9b13 100644 (file)
@@ -20,52 +20,41 @@ import org.simantics.simulation.ontology.SimulationResource;
 
 public class ProfileEntrySelectionListener implements Listener {
 
 
 public class ProfileEntrySelectionListener implements Listener {
 
-       public void processRecursively(WriteGraph graph, Resource runtimeProfile, Resource entry, boolean checked) throws DatabaseException {
+    public void processRecursively(WriteGraph graph, Resource runtimeProfile, Resource entry, boolean checked) throws DatabaseException {
+        DiagramResource DIA = DiagramResource.getInstance(graph);
 
 
-       DiagramResource DIA = DiagramResource.getInstance(graph);
-               
-       if(graph.isInstanceOf(entry, DIA.Profile)) {
-               
-               for(Resource child : ProfileUtils.getProfileChildren(graph, entry)) {
-                       processRecursively(graph, runtimeProfile, child, checked);
-               }
-               
-       } else if(graph.isInstanceOf(entry, DIA.ProfileEntry)) {
-
-            if(checked) {
+        if (graph.isInstanceOf(entry, DIA.Profile)) {
+            for (Resource child : ProfileUtils.getProfileChildren(graph, entry)) {
+                processRecursively(graph, runtimeProfile, child, checked);
+            }
+        } else if (graph.isInstanceOf(entry, DIA.ProfileEntry)) {
+            if (checked) {
                 graph.claim(runtimeProfile, SimulationResource.getInstance(graph).IsActive, null, entry);
             } else {
                 graph.denyStatement(runtimeProfile, SimulationResource.getInstance(graph).IsActive, entry);
             }
                 graph.claim(runtimeProfile, SimulationResource.getInstance(graph).IsActive, null, entry);
             } else {
                 graph.denyStatement(runtimeProfile, SimulationResource.getInstance(graph).IsActive, entry);
             }
+        }
+    }
 
 
-               }
-               
-       }
-       
     @Override
     public void handleEvent (Event event) {
     @Override
     public void handleEvent (Event event) {
-       
         if(event.detail == SWT.CHECK) {
         if(event.detail == SWT.CHECK) {
-               
             final TreeItem item = (TreeItem)event.item;
             Tree tree = item.getParent();
             GraphExplorer explorer = (GraphExplorer)tree.getData(GraphExplorer.KEY_GRAPH_EXPLORER);
             final Resource runtimeDiagram = (Resource)explorer.getRoot().getConstant(BuiltinKeys.INPUT);
             final boolean checked = item.getChecked();
             NodeContext context = (NodeContext)item.getData();
             final TreeItem item = (TreeItem)event.item;
             Tree tree = item.getParent();
             GraphExplorer explorer = (GraphExplorer)tree.getData(GraphExplorer.KEY_GRAPH_EXPLORER);
             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 {
             try {
-               
                 VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class);
                 Simantics.getSession().syncRequest(new WriteRequest(support.getWorkspacePersistent("profiles")) {
 
                     @Override
                     public void perform(WriteGraph graph) throws DatabaseException {
                 VirtualGraphSupport support = Simantics.getSession().getService(VirtualGraphSupport.class);
                 Simantics.getSession().syncRequest(new WriteRequest(support.getWorkspacePersistent("profiles")) {
 
                     @Override
                     public void perform(WriteGraph graph) throws DatabaseException {
-                       
-                       DiagramResource DIA = DiagramResource.getInstance(graph);
-                       Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);
-                       processRecursively(graph, runtimeProfile, entry.getSecond(), checked);
-                        
+                        DiagramResource DIA = DiagramResource.getInstance(graph);
+                        Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, DIA.RuntimeDiagram_HasRuntimeProfile);
+                        processRecursively(graph, runtimeProfile, entry.getEntry(), checked);
                     }
 
                 });
                     }
 
                 });
index 118d46f8e7c9edba9c88782b1730e0d5b9dbbe6e..c060f067ae22cd02ffd19becde47358d63cb8a19 100644 (file)
@@ -25,7 +25,7 @@ public class ProfileSelectionProcessor implements SelectionProcessor<Object, Rea
     public Collection<?> process(Object selection, ReadGraph g) {
         try {
             Resource object = ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MAIN, Resource.class);
     public Collection<?> process(Object selection, ReadGraph g) {
         try {
             Resource object = ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MAIN, Resource.class);
-            ResourcePair object2 = ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MAIN, ResourcePair.class);
+            ProfileTuple object2 = ISelectionUtils.getSinglePossibleKey(selection, SelectionHints.KEY_MAIN, ProfileTuple.class);
 
             return processInternal(g, object, object2, selection);
                
 
             return processInternal(g, object, object2, selection);
                
@@ -36,7 +36,7 @@ public class ProfileSelectionProcessor implements SelectionProcessor<Object, Rea
         return Collections.emptyList();
     }
 
         return Collections.emptyList();
     }
 
-    private Collection<?> processInternal(ReadGraph g, Resource object, ResourcePair pair, Object selection) throws DatabaseException {
+    private Collection<?> processInternal(ReadGraph g, Resource object, ProfileTuple pair, Object selection) throws DatabaseException {
 
        Collection<Object> inputs = new ArrayList<Object>();
        
 
        Collection<Object> inputs = new ArrayList<Object>();
        
@@ -59,11 +59,11 @@ public class ProfileSelectionProcessor implements SelectionProcessor<Object, Rea
         return result;
     }
 
         return result;
     }
 
-    private void parseResourceInput(ReadGraph g, Resource part, ResourcePair pair, Collection<Object> inputs) throws DatabaseException {
+    private void parseResourceInput(ReadGraph g, Resource part, ProfileTuple pair, Collection<Object> inputs) throws DatabaseException {
         getGroups(g, part, pair, inputs);
     }
 
         getGroups(g, part, pair, inputs);
     }
 
-    void getGroups(ReadGraph g, Resource r, ResourcePair p, Collection<Object> result) throws DatabaseException {
+    void getGroups(ReadGraph g, Resource r, ProfileTuple p, Collection<Object> result) throws DatabaseException {
         DiagramResource dr = DiagramResource.getInstance(g);
         if (r != null && g.isInstanceOf(r, dr.SCLGroup)) {
             result.add(new SCLInput(r, 1, "SCL Group"));
         DiagramResource dr = DiagramResource.getInstance(g);
         if (r != null && g.isInstanceOf(r, dr.SCLGroup)) {
             result.add(new SCLInput(r, 1, "SCL Group"));
@@ -71,12 +71,12 @@ public class ProfileSelectionProcessor implements SelectionProcessor<Object, Rea
         if (r != null && g.isInstanceOf(r, dr.SCLTextStyle)) {
             result.add(new SCLInput(r, 2, "SCL Text Style"));
         }
         if (r != null && g.isInstanceOf(r, dr.SCLTextStyle)) {
             result.add(new SCLInput(r, 2, "SCL Text Style"));
         }
-        if (p != null && g.isInstanceOf(p.getSecond(), dr.GroupStyleProfileEntry)) {
-               Resource group = g.getPossibleObject(p.getSecond(), dr.ProfileEntry_HasGroup);
+        if (p != null && g.isInstanceOf(p.getEntry(), dr.GroupStyleProfileEntry)) {
+               Resource group = g.getPossibleObject(p.getEntry(), dr.ProfileEntry_HasGroup);
                        if (group != null && g.isInstanceOf(group, dr.SCLGroup)) {
                 result.add(new SCLInput(group, 1, "SCL Group"));
             }
                        if (group != null && g.isInstanceOf(group, dr.SCLGroup)) {
                 result.add(new SCLInput(group, 1, "SCL Group"));
             }
-               Resource style = g.getPossibleObject(p.getSecond(), dr.ProfileEntry_HasStyle);
+               Resource style = g.getPossibleObject(p.getEntry(), dr.ProfileEntry_HasStyle);
                        if (style != null && g.isInstanceOf(style, dr.SCLTextStyle)) {
                 result.add(new SCLInput(style, 2, "SCL Text Style"));
             }
                        if (style != null && g.isInstanceOf(style, dr.SCLTextStyle)) {
                 result.add(new SCLInput(style, 2, "SCL Text Style"));
             }
diff --git a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ProfileTuple.java b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ProfileTuple.java
new file mode 100644 (file)
index 0000000..ce4bff8
--- /dev/null
@@ -0,0 +1,26 @@
+package org.simantics.diagram.profile.view;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.simantics.db.Resource;
+import org.simantics.utils.datastructures.map.Tuple;
+
+public class ProfileTuple extends Tuple implements IAdaptable {
+
+    ProfileTuple(Resource baseProfile, Resource entry, Resource runtimeDiagram) {
+        super(baseProfile, entry, runtimeDiagram);
+    }
+
+    public Resource getBaseProfile()    { return (Resource) getField(0); }
+    public Resource getEntry()          { return (Resource) getField(1); }
+    public Resource getRuntimeDiagram() { return (Resource) getField(2); }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> T getAdapter(Class<T> adapter) {
+        if (adapter == Resource.class) {
+            return (T) getEntry();
+        }
+        return null;
+    }
+
+}
\ No newline at end of file
index 0e51deac1225d2a6ae6744e9849ecaf8748de202..f83bbf928f76bf7678f6bc70d1ad297b70ccaa0c 100644 (file)
@@ -23,9 +23,8 @@ public class RemoveEntriesAction extends ModelledActionImpl<Resource> {
        public void run(Resource runtimeDiagram) {
 
                ISelection selection = getParameter(DiagramResource.URIs.ProfilesView_SelectedEntries);
        public void run(Resource runtimeDiagram) {
 
                ISelection selection = getParameter(DiagramResource.URIs.ProfilesView_SelectedEntries);
-        final List<ResourcePair> selectedEntries = ISelectionUtils.getPossibleKeys(selection, SelectionHints.KEY_MAIN, ResourcePair.class);
+        final List<ProfileTuple> selectedEntries = ISelectionUtils.getPossibleKeys(selection, SelectionHints.KEY_MAIN, ProfileTuple.class);
         if(selectedEntries != null && !selectedEntries.isEmpty()) {
         if(selectedEntries != null && !selectedEntries.isEmpty()) {
-               System.err.println("RemoveEntriesAction has " + selection + " for " + runtimeDiagram);
             try {
                 Simantics.getSession().syncRequest(new WriteRequest() {
 
             try {
                 Simantics.getSession().syncRequest(new WriteRequest() {
 
@@ -33,9 +32,9 @@ public class RemoveEntriesAction extends ModelledActionImpl<Resource> {
                     public void perform(WriteGraph graph) throws DatabaseException {
                        
                        DiagramResource DIA = DiagramResource.getInstance(graph);
                     public void perform(WriteGraph graph) throws DatabaseException {
                        
                        DiagramResource DIA = DiagramResource.getInstance(graph);
-                       for(ResourcePair entry : selectedEntries) {
-                               Resource list = graph.getPossibleObject(entry.getFirst(), DIA.HasEntries);
-                               OrderedSetUtils.remove(graph, list, entry.getSecond());
+                       for(ProfileTuple entry : selectedEntries) {
+                               Resource list = graph.getPossibleObject(entry.getBaseProfile(), DIA.HasEntries);
+                               OrderedSetUtils.remove(graph, list, entry.getEntry());
                        }
                         
                     }
                        }
                         
                     }
diff --git a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ResourcePair.java b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/ResourcePair.java
deleted file mode 100644 (file)
index c641499..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.simantics.diagram.profile.view;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.simantics.db.Resource;
-import org.simantics.utils.datastructures.map.Tuple;
-
-public class ResourcePair extends Tuple implements IAdaptable{
-    ResourcePair(Resource first, Resource second) { super(first ,second); }
-    public Resource getFirst() { return (Resource) getField(0); }
-    public Resource getSecond() { return (Resource) getField(1); }
-       
-    @SuppressWarnings("rawtypes")
-       @Override
-       public Object getAdapter(Class adapter) {
-               if (adapter == Resource.class) {
-                       return getSecond();
-               }
-               return null;
-       }
-    
-    
-}
\ No newline at end of file
index 6f8ebe0a618210ead71616f49587fd34a5b4d710..daf038a3972940a53b06637844ef0aa67b83fcdf 100644 (file)
@@ -25,13 +25,13 @@ public class ResourcePairImageRule implements ImageRule {
 
     @Override
     public boolean isCompatible(Class<?> contentType) {
 
     @Override
     public boolean isCompatible(Class<?> contentType) {
-        return contentType.equals(ResourcePair.class);
+        return contentType.equals(ProfileTuple.class);
     }
 
     @Override
     public Map<String, ImageDescriptor> getImage(ReadGraph graph, Object content) throws DatabaseException {
         
     }
 
     @Override
     public Map<String, ImageDescriptor> getImage(ReadGraph graph, Object content) throws DatabaseException {
         
-        ImageDescriptorProvider provider = graph.getPossibleAdapter(((ResourcePair)content).getSecond(), ImageDescriptorProvider.class);
+        ImageDescriptorProvider provider = graph.getPossibleAdapter(((ProfileTuple)content).getEntry(), ImageDescriptorProvider.class);
         return provider != null ? Collections.singletonMap(ColumnKeys.SINGLE, provider.get()) : null;
         
     }
         return provider != null ? Collections.singletonMap(ColumnKeys.SINGLE, provider.get()) : null;
         
     }
index 1810722ae52be316f130c2c83bfc7d60ec067e1e..3e07a9e01b988f716fbc0120070137d4a0e89605 100644 (file)
@@ -18,13 +18,13 @@ public class ResourcePairLabelRule implements LabelRule {
 
     @Override
     public boolean isCompatible(Class<?> contentType) {
 
     @Override
     public boolean isCompatible(Class<?> contentType) {
-        return contentType.equals(ResourcePair.class);
+        return contentType.equals(ProfileTuple.class);
     }
 
     @Override
     public Map<String,String> getLabel(ReadGraph graph, Object content) throws DatabaseException {
         return Collections.singletonMap(ColumnKeys.SINGLE, 
     }
 
     @Override
     public Map<String,String> getLabel(ReadGraph graph, Object content) throws DatabaseException {
         return Collections.singletonMap(ColumnKeys.SINGLE, 
-                NameUtils.getSafeLabel(graph, ((ResourcePair)content).getSecond())
+                NameUtils.getSafeLabel(graph, ((ProfileTuple)content).getEntry())
                 );
     }
 }
                 );
     }
 }
index 6ec408ecd17ddd4794d0f90cf185a18d65cc41ba..86b20df53219a68c63d71d48b297d8b4d4eade20 100644 (file)
@@ -36,7 +36,7 @@ public class RuntimeDirectProfileEntries implements ChildRule {
        DiagramResource dr = DiagramResource.getInstance(graph);
        Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, dr.RuntimeDiagram_HasRuntimeProfile);
        if(runtimeProfile == null) return Collections.emptyList();
        DiagramResource dr = DiagramResource.getInstance(graph);
        Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, dr.RuntimeDiagram_HasRuntimeProfile);
        if(runtimeProfile == null) return Collections.emptyList();
-       return graph.syncRequest(new DirectProfileEntries(new ResourcePair(runtimeProfile, runtimeProfile)));
+       return graph.syncRequest(new DirectProfileEntries(new ProfileTuple(runtimeProfile, runtimeProfile, runtimeDiagram)));
        
     }
 
        
     }
 
index c7e65bfadcc27c5111186253da84a7c14d702770..9a91eca4f28f733c158b6918117d0e3eda6840dd 100644 (file)
@@ -37,6 +37,7 @@
                <type
                        uri="http://www.simantics.org/Diagram-0.0/SCLTextGridStyle"
                        class="org.simantics.diagram.profile.SCLTextGridStyle">
                <type
                        uri="http://www.simantics.org/Diagram-0.0/SCLTextGridStyle"
                        class="org.simantics.diagram.profile.SCLTextGridStyle">
+                       <graph />
                        <this />
                </type>
        </target>
                        <this />
                </type>
        </target>
index 5850ffb3778407b39805c439d31fabde2b2b22ab..4401f2213c51aa0a58b0b0c8170ab5e9636d281c 100644 (file)
@@ -1,12 +1,9 @@
 package org.simantics.diagram.profile;
 
 package org.simantics.diagram.profile;
 
+import java.awt.Font;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.AffineTransform;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.util.Locale;
 
 import org.simantics.Simantics;
 
 import org.simantics.Simantics;
-import org.simantics.common.format.Formatter;
 import org.simantics.databoard.Bindings;
 import org.simantics.datatypes.literal.Vec2d;
 import org.simantics.db.ReadGraph;
 import org.simantics.databoard.Bindings;
 import org.simantics.datatypes.literal.Vec2d;
 import org.simantics.db.ReadGraph;
@@ -14,10 +11,13 @@ import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.layer0.variable.Variables;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.layer0.variable.Variables;
+import org.simantics.diagram.G2DUtils;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.diagram.stubs.G2DResource;
 import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;
 import org.simantics.modeling.ModelingResources;
 import org.simantics.scl.runtime.function.Function1;
 import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;
 import org.simantics.modeling.ModelingResources;
 import org.simantics.scl.runtime.function.Function1;
+import org.simantics.scl.runtime.tuple.Tuple3;
 import org.simantics.utils.datastructures.Pair;
 
 /**
 import org.simantics.utils.datastructures.Pair;
 
 /**
@@ -26,9 +26,24 @@ import org.simantics.utils.datastructures.Pair;
 public class SCLTextGridStyle extends TextGridStyle {
 
        final Resource style;
 public class SCLTextGridStyle extends TextGridStyle {
 
        final Resource style;
+       final Font font;
 
 
-       public SCLTextGridStyle(Resource style) {
+       public SCLTextGridStyle(ReadGraph graph, Resource style) throws DatabaseException {
                this.style = style;
                this.style = style;
+               G2DResource G2D = G2DResource.getInstance(graph);
+        Resource fontR = graph.getPossibleObject(style, G2D.HasFont);
+               if(fontR != null) {
+                       font = G2DUtils.getFont(graph, fontR);
+               } else {
+                       font = null;
+               }
+
+       }
+
+       @Override
+       protected Font getFont() {
+               if(font != null) return font;
+               return super.getFont();
        }
 
        @Override
        }
 
        @Override
@@ -67,16 +82,16 @@ public class SCLTextGridStyle extends TextGridStyle {
                        return null;
 
                Variable styleVariable = Variables.getVariable(graph, style);
                        return null;
 
                Variable styleVariable = Variables.getVariable(graph, style);
-               Function1<Variable,String> function = styleVariable.getPossiblePropertyValue(graph, "function");
-               String result = Simantics.applySCLRead(graph, function, moduleVariable);
-
+               Function1<Variable,Tuple3> function = styleVariable.getPossiblePropertyValue(graph, DIA.SCLTextGridStyle_texts);
+               Tuple3 result = Simantics.applySCLRead(graph, function, moduleVariable);
+               
                AffineTransform transform = DiagramGraphUtil.getAffineTransform(graph, element);
                Vec2d offset = DiagramGraphUtil.getOffset(graph, element);
                boolean enabled = !DiagramGraphUtil.getProfileMonitorsHidden(graph, element);
                boolean up = DiagramGraphUtil.getProfileMonitorsUp(graph, element);
                double spacing = DiagramGraphUtil.getProfileMonitorSpacing(graph, element);
 
                AffineTransform transform = DiagramGraphUtil.getAffineTransform(graph, element);
                Vec2d offset = DiagramGraphUtil.getOffset(graph, element);
                boolean enabled = !DiagramGraphUtil.getProfileMonitorsHidden(graph, element);
                boolean up = DiagramGraphUtil.getProfileMonitorsUp(graph, element);
                double spacing = DiagramGraphUtil.getProfileMonitorSpacing(graph, element);
 
-               return new MonitorTextGridResult(rowId(), result, "", "", enabled, up, spacing, null, null, ElementTranslation.function(element), transform, offset);
+               return new MonitorTextGridResult(rowId(), (String)result.c0, (String)result.c1, (String)result.c2, enabled, up, spacing, null, null, ElementTranslation.function(element), transform, offset);
 
        }
 
 
        }
 
index d660d47a5be007f7e33acd9349c820cd1d1c7615..54972155d8d69579294e4d6e49718a453e14e66d 100644 (file)
@@ -94,7 +94,7 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                String name = graph.getPossibleRelatedValue(config, getPropertyRelation(graph,element), Bindings.STRING);
                return name;
        }
                String name = graph.getPossibleRelatedValue(config, getPropertyRelation(graph,element), Bindings.STRING);
                return name;
        }
-       
+
        public AffineTransform getTransform(INode node, AffineTransform parentTransform, Rectangle2D elementBounds, int location, boolean up) {
                return getTransform(parentTransform, elementBounds, location, up);
        }
        public AffineTransform getTransform(INode node, AffineTransform parentTransform, Rectangle2D elementBounds, int location, boolean up) {
                return getTransform(parentTransform, elementBounds, location, up);
        }
@@ -110,7 +110,7 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                at.scale(0.15, 0.15);
 
                return at;
                at.scale(0.15, 0.15);
 
                return at;
-               
+
        }
 
        protected String rowId() {
        }
 
        protected String rowId() {
@@ -161,7 +161,7 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
 
                        String value2 = result != null ? result.getText2() : null;
                        String value3 = result != null ? result.getText3() : null;
 
                        String value2 = result != null ? result.getText2() : null;
                        String value3 = result != null ? result.getText3() : null;
-                       
+
                        double spacing = result.getSpacing();
 
                        final Function1<String, String> modifier = result != null ? result.getModifier() : null;
                        double spacing = result.getSpacing();
 
                        final Function1<String, String> modifier = result != null ? result.getModifier() : null;
@@ -209,7 +209,7 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                        node.setCache(1, row, result);
 
                        boolean isConnection = _node instanceof ConnectionNode;
                        node.setCache(1, row, result);
 
                        boolean isConnection = _node instanceof ConnectionNode;
-                       
+
                        Rectangle2D elementBounds = isConnection ? EMPTY_BOUNDS : NodeUtil.getLocalElementBounds(_node);
                        if(elementBounds == null) {
                                new Exception("Cannot get local element bounds for node " + _node.toString()).printStackTrace();
                        Rectangle2D elementBounds = isConnection ? EMPTY_BOUNDS : NodeUtil.getLocalElementBounds(_node);
                        if(elementBounds == null) {
                                new Exception("Cannot get local element bounds for node " + _node.toString()).printStackTrace();
@@ -225,14 +225,14 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                        Vec2d offset = result.getOffset();
 
                        Point2D[] cellOffsets = getCellOffsets();
                        Vec2d offset = result.getOffset();
 
                        Point2D[] cellOffsets = getCellOffsets();
-                       
+
                        AffineTransform at1 = new AffineTransform(at);
                        at1.translate(cellOffsets[0].getX(),cellOffsets[0].getY());
                        AffineTransform at2 = new AffineTransform(at);
                        at2.translate(cellOffsets[1].getX()+spacing,cellOffsets[1].getY());
                        AffineTransform at3 = new AffineTransform(at);
                        at3.translate(cellOffsets[2].getX()+spacing,cellOffsets[2].getY());
                        AffineTransform at1 = new AffineTransform(at);
                        at1.translate(cellOffsets[0].getX(),cellOffsets[0].getY());
                        AffineTransform at2 = new AffineTransform(at);
                        at2.translate(cellOffsets[1].getX()+spacing,cellOffsets[1].getY());
                        AffineTransform at3 = new AffineTransform(at);
                        at3.translate(cellOffsets[2].getX()+spacing,cellOffsets[2].getY());
-                       
+
                        at1.translate(offset.x, offset.y);
                        at2.translate(offset.x, offset.y);
                        at3.translate(offset.x, offset.y);
                        at1.translate(offset.x, offset.y);
                        at2.translate(offset.x, offset.y);
                        at3.translate(offset.x, offset.y);
@@ -251,7 +251,7 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                                node.setHorizontalAlignment(2, row, (byte) getAlignment(2).ordinal());
                                node.setHorizontalAlignment(3, row, (byte) getAlignment(3).ordinal());
                        }
                                node.setHorizontalAlignment(2, row, (byte) getAlignment(2).ordinal());
                                node.setHorizontalAlignment(3, row, (byte) getAlignment(3).ordinal());
                        }
-                       
+
                        Alignment[] verticalAlignments = result.getVerticalAlignments();
                        if(verticalAlignments != null) {
                                node.setVerticalAlignment(1, row, (byte) verticalAlignments[0].ordinal());
                        Alignment[] verticalAlignments = result.getVerticalAlignments();
                        if(verticalAlignments != null) {
                                node.setVerticalAlignment(1, row, (byte) verticalAlignments[0].ordinal());
@@ -266,11 +266,13 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                        node.setZIndex(3000);
 
                        org.simantics.common.color.Color color = result.getColor();
                        node.setZIndex(3000);
 
                        org.simantics.common.color.Color color = result.getColor();
-                       java.awt.Color awtColor = color != null ? Colors.awt(color) : Color.DARK_GRAY;
+                       Color awtColor = color != null ? Colors.awt(color) : Color.DARK_GRAY;
+                       Color bgColor = getBackgroundColor();
+                       Font font = getFont();
 
 
-                       setTextNodeData(node, 1, row, value, FONT, awtColor, BACKGROUND_COLOR);
-                       setTextNodeData(node, 2, row, value2, result.getPending(), FONT, awtColor, BACKGROUND_COLOR);
-                       setTextNodeData(node, 3, row, value3, FONT, awtColor, BACKGROUND_COLOR);
+                       setTextNodeData(node, 1, row, value, font, awtColor, bgColor);
+                       setTextNodeData(node, 2, row, value2, result.getPending(), font, awtColor, bgColor);
+                       setTextNodeData(node, 3, row, value3, font, awtColor, bgColor);
 
                        node.setEditable(1, row, false);
                        node.setForceEventListening(2, row, true);
 
                        node.setEditable(1, row, false);
                        node.setForceEventListening(2, row, true);
@@ -309,7 +311,7 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
 
                        node.setInputValidator(2, row, validator);
                        node.setTranslator(translator);
 
                        node.setInputValidator(2, row, validator);
                        node.setTranslator(translator);
-                       
+
                        node.setRVI(2, row, rvi);
 
                        postProcessNode(node, row);
                        node.setRVI(2, row, rvi);
 
                        postProcessNode(node, row);
@@ -336,6 +338,14 @@ public abstract class TextGridStyle extends StyleBase<MonitorTextGridResult> {
                node.setPending(x, y, pending);
        }
 
                node.setPending(x, y, pending);
        }
 
+       protected Font getFont() {
+               return FONT;
+       }
+
+       protected Color getBackgroundColor() {
+               return BACKGROUND_COLOR;
+       }
+
        protected Alignment getAlignment(int column) {
                switch(column) {
                case 1: return Alignment.TRAILING;
        protected Alignment getAlignment(int column) {
                switch(column) {
                case 1: return Alignment.TRAILING;
index fc58ade46911d32717b362fb7bc6a319767f1c47..15506f545bdeef7cddd13824033b870e085a8937 100644 (file)
@@ -261,3 +261,20 @@ G2D.HasSVGScript <R L0.HasProperty : L0.FunctionalRelation
 
 G2D.IsVisible <R L0.HasProperty : L0.FunctionalRelation
     --> L0.Boolean
 
 G2D.IsVisible <R L0.HasProperty : L0.FunctionalRelation
     --> L0.Boolean
+
+G2D.fontProperty : L0.Template
+    @template %subject %predicate %family %size %style
+        %subject
+            %predicate _ : G2D.Font
+              G2D.HasFontFamily %family
+              G2D.HasFontSize %size
+              G2D.HasFontStyle %style
+              
+G2D.font : L0.Template
+    @template %subject %family %size %style
+        %subject : G2D.Font
+          G2D.HasFontFamily %family
+          G2D.HasFontSize %size
+          G2D.HasFontStyle %style
+              
+    
\ No newline at end of file
index 88a69065be58d358294c0238f263a755ad38aa45..92326248f26007b4eccfda3772ff72d99c6155a5 100644 (file)
@@ -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.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 {
 
 
 public class ProfileUtils {
 
@@ -43,9 +43,9 @@ public class ProfileUtils {
                        if(profile.equals(ref)) return state;
                }
                return null;
                        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);
        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;
        }
                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;
+       }
+
 }
 }