]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
dc9c290a4e19178806b8b59b86e2117bea16292f
[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.utils.OrderedSetUtils;\r
11 import org.simantics.db.exception.DatabaseException;\r
12 import org.simantics.sysdyn.SysdynResource;\r
13 \r
14 public class EnumerationIndexes extends ViewpointContributorImpl<Resource> {\r
15 \r
16         @Override\r
17         public Collection<?> getContribution(ReadGraph graph, Resource input)\r
18                         throws DatabaseException {\r
19                 if(input == null) \r
20                         return null;\r
21                 SysdynResource sr = SysdynResource.getInstance(graph);\r
22                 if(!graph.isInstanceOf(input, sr.Enumeration))\r
23                         return null;\r
24                 Resource enumerationIndexList = graph.getPossibleObject(input, sr.Enumeration_enumerationIndexes);\r
25                 if(enumerationIndexList == null)\r
26                         return null;\r
27         ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
28         for(Resource r : OrderedSetUtils.toList(graph, enumerationIndexList)) {\r
29             result.add(new EnumerationIndexNode(r));\r
30     }\r
31         return result;\r
32         }\r
33 \r
34         @Override\r
35         public String getViewpointId() {\r
36                 return "Enumeration indexes";\r
37         }\r
38 \r
39 \r
40 }\r