From: Antti Villberg Date: Sun, 7 May 2017 06:44:35 +0000 (+0300) Subject: Support VP.Test in action browse context contribution X-Git-Tag: v1.29.0~70^2~5 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=ef12da1a6651051f3674b593a732d253c9ea4461;p=simantics%2Fplatform.git Support VP.Test in action browse context contribution refs #7193 Change-Id: If8237793dda6f6191e0aec06c30573cc2f97134f --- diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/ContributedActionBrowseContexts.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/ContributedActionBrowseContexts.java index 51affb5fa..dd3fba2c7 100644 --- a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/ContributedActionBrowseContexts.java +++ b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/ContributedActionBrowseContexts.java @@ -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 result = new ArrayList(); 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; diff --git a/bundles/org.simantics.viewpoint.ontology/graph/Viewpoint.pgraph b/bundles/org.simantics.viewpoint.ontology/graph/Viewpoint.pgraph index ac276f08a..e7cfd1e93 100644 --- a/bundles/org.simantics.viewpoint.ontology/graph/Viewpoint.pgraph +++ b/bundles/org.simantics.viewpoint.ontology/graph/Viewpoint.pgraph @@ -38,6 +38,7 @@ VP.BrowseContextContribution -- VP.ActionBrowseContextContribution.HasType --> L0.Type -- VP.ActionBrowseContextContribution.HasTest --> VP.Test -- VP.ActionBrowseContextContribution.HasActionBrowseContext --> VP.BrowseContext -- VP.ActionBrowseContextContribution.allowedUIContexts --> L0.StringArray