]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
272a2af5caa7a5df38be666224c0abf032f693d0
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.ui.wizards.modules;\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 import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
15 \r
16 public class ModuleTreeModels extends ViewpointContributorImpl<Resource> {\r
17 \r
18         @Override\r
19         public Collection<?> getContribution(ReadGraph graph, Resource input)\r
20                         throws DatabaseException {\r
21                 \r
22 \r
23                 SysdynResource sr = SysdynResource.getInstance(graph);\r
24                 Layer0 l0 = Layer0.getInstance(graph);\r
25                 ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
26                 for(Resource r : graph.syncRequest(new ObjectsWithType(input, l0.ConsistsOf, sr.SysdynModel))) {\r
27                         result.add(new ModelNode(r));\r
28                 }\r
29                 \r
30                 return result;\r
31         }\r
32 \r
33         @Override\r
34         public String getViewpointId() {\r
35                 return "Module Import";\r
36         }\r
37         \r
38 \r
39 \r
40 }\r