]> gerrit.simantics Code Review - simantics/platform.git/blob
06c0e1e3737ced5cc350a5e9275f7366414c0164
[simantics/platform.git] /
1 package org.simantics.selectionview;
2
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.exception.DatabaseException;
6
7 abstract public class AbstractTypedResourceTabContribution extends AbstractResourceTabContribution {
8
9         public AbstractTypedResourceTabContribution(ReadGraph graph, Resource configuration) throws DatabaseException {
10                 super(graph, configuration);
11         }
12
13         
14         @Override
15         public boolean accept(ReadGraph graph, Object input) throws DatabaseException {
16
17                 if (!(input instanceof Resource))
18                         return false;
19                 Resource resource = (Resource) input;
20
21                 SelectionViewResources SEL = SelectionViewResources.getInstance(graph);
22
23                 Resource type = graph.getPossibleObject(configuration, SEL.AbstractTypedResourceTabContribution_HasType);
24                 if(type == null) throw new DatabaseException("No type for " + graph.getPossibleURI(configuration));
25
26                 if(!graph.isInstanceOf(resource, type)) return false;
27                 
28                 return super.accept(graph, resource);
29                 
30         }
31         
32 }