1 package org.simantics.selectionview;
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.exception.DatabaseException;
6 import org.simantics.db.layer0.variable.Variable;
8 abstract public class AbstractTypedVariableTabContribution extends AbstractVariableTabContribution {
10 public AbstractTypedVariableTabContribution(ReadGraph graph, Resource configuration) throws DatabaseException {
11 super(graph, configuration);
15 public boolean accept(ReadGraph graph, Variable variable, Object selection) throws DatabaseException {
17 SelectionViewResources SEL = SelectionViewResources.getInstance(graph);
19 Resource type = graph.getPossibleObject(configuration, SEL.AbstractTypedVariableTabContribution_HasType);
20 if(type == null) throw new DatabaseException("No type for " + graph.getPossibleURI(configuration));
22 Resource resource = variable.getPossibleRepresents(graph);
23 if(resource == null) return false;
25 if(!graph.isInstanceOf(resource, type)) return false;
27 return super.accept(graph, variable, selection);