]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
9b2c37e23f9eea29208ea5af0df802c112ae1df9
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
2 \r
3 import java.util.ArrayList;\r
4 import java.util.Collection;\r
5 \r
6 import org.simantics.browsing.ui.common.node.AbstractNode;\r
7 import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContributorImpl;\r
8 import org.simantics.db.ReadGraph;\r
9 import org.simantics.db.Resource;\r
10 import org.simantics.db.common.request.ObjectsWithType;\r
11 import org.simantics.db.exception.DatabaseException;\r
12 import org.simantics.layer0.Layer0;\r
13 import org.simantics.sysdyn.SysdynResource;\r
14 \r
15 public class AvailableEnumerations extends ViewpointContributorImpl<Resource> {\r
16 \r
17         @Override\r
18         public Collection<?> getContribution(ReadGraph graph, Resource input)\r
19                         throws DatabaseException {\r
20                 if(input == null) return null;\r
21                 Layer0 l0 = Layer0.getInstance(graph);\r
22                 Resource configuration = graph.getPossibleObject(input, l0.PartOf);\r
23         ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
24         SysdynResource sr = SysdynResource.getInstance(graph);\r
25         if(configuration == null) \r
26                 return result;\r
27         for(Resource r : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Enumeration))) {\r
28                 result.add(new EnumerationNode(r));\r
29         }\r
30         return result;\r
31         }\r
32 \r
33         @Override\r
34         public String getViewpointId() {\r
35                 return "Used enumerations";\r
36         }\r
37 \r
38 \r
39 }\r