]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Support VP.Test in action browse context contribution 89/489/1
authorAntti Villberg <antti.villberg@semantum.fi>
Sun, 7 May 2017 06:44:35 +0000 (09:44 +0300)
committerAntti Villberg <antti.villberg@semantum.fi>
Sun, 7 May 2017 06:44:35 +0000 (09:44 +0300)
refs #7193

Change-Id: If8237793dda6f6191e0aec06c30573cc2f97134f

bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/ContributedActionBrowseContexts.java
bundles/org.simantics.viewpoint.ontology/graph/Viewpoint.pgraph

index 51affb5faf7c3e5525833d8feae06ee3c6cf9a96..dd3fba2c750f068b7835445429452d1905fdc356 100644 (file)
@@ -3,6 +3,7 @@ package org.simantics.browsing.ui.model.browsecontexts;
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.simantics.browsing.ui.model.tests.Test;
 import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
@@ -26,16 +27,25 @@ public class ContributedActionBrowseContexts extends TernaryRead<Resource,Resour
         Collection<Resource> result = new ArrayList<Resource>();
         for(Resource contribution : query.find(graph, parameter)) {
             Resource type = graph.getPossibleObject(contribution, VP.ActionBrowseContextContribution_HasType);
-            if(type == null) continue;
-            if(graph.isInstanceOf(parameter2, type)) {
-                Resource context = graph.getPossibleObject(contribution, VP.ActionBrowseContextContribution_HasActionBrowseContext);
-                if(context == null) continue;
-                String[] allowedContexts = graph.getPossibleRelatedValue(contribution, VP.ActionBrowseContextContribution_allowedUIContexts, Bindings.STRING_ARRAY);
-                if(allowedContexts != null)
-                       if(!Arrays.contains(allowedContexts, parameter3))
-                               continue;
-                result.add(context);
+            if(type != null) {
+                   if(!graph.isInstanceOf(parameter2, type)) continue;
             }
+            Resource testResource = graph.getPossibleObject(contribution, VP.ActionBrowseContextContribution_HasTest);
+            if(testResource != null) {
+               Test test = graph.getPossibleAdapter(testResource, Test.class);
+               if(test != null) {
+                       if(!test.test(graph, parameter2)) continue;
+               }
+            }
+                       
+            Resource context = graph.getPossibleObject(contribution, VP.ActionBrowseContextContribution_HasActionBrowseContext);
+            if(context == null) continue;
+            String[] allowedContexts = graph.getPossibleRelatedValue(contribution, VP.ActionBrowseContextContribution_allowedUIContexts, Bindings.STRING_ARRAY);
+            if(allowedContexts != null)
+               if(!Arrays.contains(allowedContexts, parameter3))
+                       continue;
+            result.add(context);
+            
         }
         return result;
         
index ac276f08a3d74f29ba86f67dd8a163444d52ad9c..e7cfd1e93428b98e892a71de01a735e512744b83 100644 (file)
@@ -38,6 +38,7 @@ VP.BrowseContextContribution <T L0.Entity
 
 VP.ActionBrowseContextContribution <T L0.Entity
     >-- VP.ActionBrowseContextContribution.HasType --> L0.Type <R L0.IsRelatedTo
+    >-- VP.ActionBrowseContextContribution.HasTest --> VP.Test <R L0.IsRelatedTo
     >-- VP.ActionBrowseContextContribution.HasActionBrowseContext --> VP.BrowseContext <R L0.IsRelatedTo
     >-- VP.ActionBrowseContextContribution.allowedUIContexts --> L0.StringArray <R L0.HasProperty : L0.FunctionalRelation