]> gerrit.simantics Code Review - simantics/3d.git/blob
2848c424e22d38b54472f3cb15402523063a595c
[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.processeditor.views;\r
12 \r
13 import java.util.Collection;\r
14 \r
15 import org.eclipse.swt.widgets.Display;\r
16 import org.simantics.db.Graph;\r
17 import org.simantics.db.Resource;\r
18 import org.simantics.db.management.ISessionContext;\r
19 import org.simantics.processeditor.ProcessResource;\r
20 import org.simantics.processeditor.tools.ControlPointContribution;\r
21 import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase;\r
22 import org.simantics.proconf.g3d.base.ThreeDimensionalEditorPart;\r
23 import org.simantics.proconf.g3d.shapeeditor.views.ShapeEditorBase;\r
24 \r
25 \r
26 public class PipelineComponentEditorPart extends ThreeDimensionalEditorPart {\r
27         \r
28         @Override\r
29         protected ThreeDimensionalEditorBase createEditor(ISessionContext session) {\r
30                 ShapeEditorBase base = new ShapeEditorBase(session);\r
31                 base.addEditorContribution(new ControlPointContribution(base));\r
32                 return base;\r
33         }\r
34         \r
35         @Override\r
36         public void reload(Graph g) {\r
37                 Resource inputResource = getInputResource();\r
38                 Collection<Resource> model = g.getObjects(inputResource, ProcessResource.plant3Dresource.HasGraphics);\r
39                 if (model.size() != 1)\r
40                         throw new RuntimeException("Cannot find model for pipeline component " + inputResource);\r
41                 Resource modelResource = model.iterator().next();\r
42                 if (modelResource != null) {\r
43                         editor.reload(g,modelResource);\r
44                 } else {\r
45                         \r
46                          Display d = getSite().getShell().getDisplay();\r
47                     d.asyncExec(new Runnable() {\r
48                         public void run() {\r
49                                 editor.showMessage("Failed to load model.");\r
50                             getSite().getPage().closeEditor(PipelineComponentEditorPart.this,false);\r
51                         }\r
52                     });\r
53                 }\r
54         }\r
55 \r
56 }\r