1 package org.simantics.sysdyn.ui.properties.widgets.arrays;
\r
3 import java.util.ArrayList;
\r
4 import java.util.Collection;
\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
15 public class AvailableEnumerations extends ViewpointContributorImpl<Resource> {
\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
27 for(Resource r : graph.syncRequest(new ObjectsWithType(configuration, l0.ConsistsOf, sr.Enumeration))) {
\r
28 result.add(new EnumerationNode(r));
\r
34 public String getViewpointId() {
\r
35 return "Used enumerations";
\r