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;
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;