]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
623f1a307ce9e575a4056596b94d9413741a260f
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.ui.wizards.functions;\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 FunctionTreeModels 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                 Resource sharedlibrary = graph.getPossibleResource("http://SharedOntologies");\r
30                 if (sharedlibrary != null)\r
31                 result.add(new SharedFunctionsFolderNode(sharedlibrary));\r
32                 \r
33                 return result;\r
34         }\r
35 \r
36         @Override\r
37         public String getViewpointId() {\r
38                 return "Function Library Import";\r
39         }\r
40         \r
41 \r
42 \r
43 }\r