]> gerrit.simantics Code Review - simantics/3d.git/blob
c01b1e4edff93984701607cb7fb0e9e5d3c2712b
[simantics/3d.git] /
1 package org.simantics.processeditor.handlers;\r
2 \r
3 import java.util.ArrayList;\r
4 import java.util.Collection;\r
5 \r
6 import org.simantics.db.Builtins;\r
7 import org.simantics.db.Graph;\r
8 import org.simantics.db.Resource;\r
9 import org.simantics.layer0.utils.direct.GraphUtils;\r
10 import org.simantics.proconf.ui.projects.IProject;\r
11 import org.simantics.proconf.ui.projects.ProjectType;\r
12 \r
13 public class Plant3DProjectType extends ProjectType{\r
14 \r
15         public Plant3DProjectType(Graph graph, Resource projectTypeResource) {\r
16                 super(graph, projectTypeResource);\r
17         }\r
18 \r
19         @Override\r
20         public Resource createProject(Graph g, String name) throws Exception {\r
21                 Resource project = super.createProject(g, name);\r
22                 Builtins b = g.getBuiltins();\r
23                 {   // Plants\r
24                         Resource modelLibrary = g.newResource();                \r
25                 g.addStatement(modelLibrary, b.InstanceOf, b.ModelLibrary);\r
26                 GraphUtils.addRelatedScalarString(g, modelLibrary, b.HasName, "Plants");\r
27                 g.addStatement(project, b.ConsistsOf, modelLibrary);        \r
28                 }\r
29                 {   // Equipment\r
30                         Resource modelLibrary = g.newResource();                \r
31                 g.addStatement(modelLibrary, b.InstanceOf, b.ModelLibrary);\r
32                 GraphUtils.addRelatedScalarString(g, modelLibrary, b.HasName, "Equipment");\r
33                 g.addStatement(project, b.ConsistsOf, modelLibrary);        \r
34                 }\r
35                 return project;\r
36         \r
37         }\r
38         \r
39         @Override\r
40         public IProject loadProject(Graph g, Resource r) {\r
41                 \r
42                 IProject project = super.loadProject(g, r);\r
43                 project.set(DefaultPerspective, "org.simantics.proconf.processeditor.plantmodelling");\r
44                 Collection<String> perspectives = new ArrayList<String>();\r
45                 perspectives.add("org.simantics.proconf.processeditor.plantmodelling");\r
46                 project.set(Perspectives, perspectives);\r
47                 \r
48                 return project;\r
49         }\r
50         \r
51 \r
52         \r
53 }\r