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