]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
91c46b6a9080f00e2402f5c0bc75c10254baa6a9
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.ui.browser.contributions;\r
2 \r
3 import java.util.ArrayList;\r
4 import java.util.Collection;\r
5 \r
6 import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
7 import org.simantics.db.ReadGraph;\r
8 import org.simantics.db.Resource;\r
9 import org.simantics.db.common.request.ObjectsWithType;\r
10 import org.simantics.db.exception.DatabaseException;\r
11 import org.simantics.layer0.Layer0;\r
12 import org.simantics.structural.ui.modelBrowser.nodes.AbstractNode;\r
13 import org.simantics.sysdyn.SysdynResource;\r
14 \r
15 public class SysdynProject  extends ViewpointContributor<Resource> {\r
16 \r
17     @Override\r
18     public Collection<?> getContribution(ReadGraph graph, Resource project)\r
19     throws DatabaseException {\r
20 \r
21         ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
22         Layer0 L0 = Layer0.getInstance(graph);\r
23         for(Resource r : graph.syncRequest(new ObjectsWithType(project, L0.ConsistsOf, SysdynResource.getInstance(graph).SysdynModel))) {\r
24             try {\r
25                 result.add(graph.adapt(r, AbstractNode.class));\r
26             } catch(DatabaseException e) {\r
27                 e.printStackTrace();\r
28             }\r
29         }\r
30         return result;\r
31 \r
32     }\r
33 \r
34     @Override\r
35     public String getViewpointId() {\r
36         return "Standard";\r
37     }\r
38 \r
39 }