]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
35d094f0ef05039bce4e5b674746f495fbb6ac04
[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 UsedEnumerations extends ViewpointContributorImpl<Resource> {\r
15 \r
16                 @Override\r
17                 public Collection<?> getContribution(ReadGraph graph, Resource input)\r
18                                 throws DatabaseException {\r
19                 SysdynResource sr = SysdynResource.getInstance(graph);\r
20                 \r
21                 ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
22                 \r
23                 Resource arrayIndexes = graph.getPossibleObject(input, sr.HasArrayIndexes);\r
24                 if(arrayIndexes == null) {\r
25                         return result;\r
26                 }\r
27                 for(Resource r : OrderedSetUtils.toList(graph, arrayIndexes)) {\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 "Available enumerations";\r
36                 }\r
37 }\r