]> gerrit.simantics Code Review - simantics/3d.git/blob
7d12b5b5d9419fee2fb798be7052753d0c9e31a6
[simantics/3d.git] /
1 /*******************************************************************************\r
2  * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * which accompanies this distribution, and is available at\r
6  * http://www.eclipse.org/legal/epl-v10.html\r
7  *\r
8  * Contributors:\r
9  *     VTT Technical Research Centre of Finland - initial API and implementation\r
10  *******************************************************************************/\r
11 package org.simantics.proconf.g3d.shapeeditor.handlers;\r
12 \r
13 import java.util.ArrayList;\r
14 import java.util.Collection;\r
15 \r
16 import org.simantics.db.Builtins;\r
17 import org.simantics.db.Graph;\r
18 import org.simantics.db.Resource;\r
19 import org.simantics.layer0.utils.direct.GraphUtils;\r
20 import org.simantics.proconf.ui.projects.IProject;\r
21 import org.simantics.proconf.ui.projects.ProjectType;\r
22 \r
23 public class CSGProjectType extends ProjectType {\r
24 \r
25         public CSGProjectType(Graph graph, Resource projectTypeResource) {\r
26                 super(graph, projectTypeResource);\r
27         }\r
28 \r
29         @Override\r
30         public Resource createProject(Graph g, String name) throws Exception {\r
31                 Resource project = super.createProject(g, name);\r
32                 Builtins b = g.getBuiltins();\r
33                 \r
34                 {   // Models\r
35           Resource modelLibrary = g.newResource();                \r
36           g.addStatement(modelLibrary, b.InstanceOf, b.ModelLibrary);\r
37           GraphUtils.addRelatedScalarString(g, modelLibrary, b.HasName, "Models");\r
38           g.addStatement(project, b.ConsistsOf, modelLibrary);        \r
39                 }\r
40         \r
41                 \r
42                 \r
43                 return project;\r
44         }\r
45         \r
46         @Override\r
47         public IProject loadProject(Graph g, Resource r) {\r
48                 IProject project = super.loadProject(g, r);\r
49                 project.set(DefaultPerspective, "org.simantics.proconf.shapeeditor.perspectives.csg");\r
50                 Collection<String> perspectives = new ArrayList<String>();\r
51                 perspectives.add("org.simantics.proconf.shapeeditor.perspectives.csg");\r
52                 project.set(Perspectives, perspectives);\r
53                 \r
54                 return project;\r
55         }\r
56         \r
57 }\r