X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.model%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fmodel%2Fbrowsecontexts%2FContributedBrowseContexts.java;h=3fb20eeb939d067bb111935eefc5c799818ce47d;hp=f2015257f1fb33997425b174a3c3c1a3f10ff025;hb=9bf20adbd213c9dff8aee036f5c2e5cff9e37baa;hpb=1ae3cacae664befed5dfafbb51d337d209d206d7 diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/ContributedBrowseContexts.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/ContributedBrowseContexts.java index f2015257f..3fb20eeb9 100644 --- a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/ContributedBrowseContexts.java +++ b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/browsecontexts/ContributedBrowseContexts.java @@ -2,6 +2,7 @@ package org.simantics.browsing.ui.model.browsecontexts; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; @@ -20,25 +21,26 @@ public class ContributedBrowseContexts extends TernaryRead perform(ReadGraph graph) throws DatabaseException { - ViewpointResource VP = ViewpointResource.getInstance(graph); Instances query = graph.adapt(VP.BrowseContextContribution, Instances.class); - Collection result = new ArrayList(); + Collection result = new ArrayList<>(); for(Resource contribution : query.find(graph, parameter)) { - Resource type = graph.getPossibleObject(contribution, VP.BrowseContextContribution_HasType); - if(type == null) continue; - if(graph.isInstanceOf(parameter2, type)) { - Resource context = graph.getPossibleObject(contribution, VP.BrowseContextContribution_HasBrowseContext); - if(context == null) continue; - String[] allowedContexts = graph.getPossibleRelatedValue(contribution, VP.BrowseContextContribution_allowedUIContexts, Bindings.STRING_ARRAY); - if(allowedContexts != null) - if(!Arrays.contains(allowedContexts, parameter3)) - continue; - result.add(context); - } + Collection acceptedTypes = graph.getObjects(contribution, VP.BrowseContextContribution_HasType); + Collection allTypes = graph.getTypes(parameter2); + if(Collections.disjoint(acceptedTypes, allTypes)) + continue; + + Resource context = graph.getPossibleObject(contribution, VP.BrowseContextContribution_HasBrowseContext); + if(context == null) + continue; + + String[] allowedContexts = graph.getPossibleRelatedValue(contribution, VP.BrowseContextContribution_allowedUIContexts, Bindings.STRING_ARRAY); + if(allowedContexts != null && !Arrays.contains(allowedContexts, parameter3)) + continue; + + result.add(context); } return result; - } }