]> gerrit.simantics Code Review - simantics/3d.git/blob
2523fa1ecb5e77cba2945d50f42dde27b83a7f5e
[simantics/3d.git] /
1 package fi.vtt.simantics.processeditor.handlers;\r
2 \r
3 import org.simantics.db.Graph;\r
4 import org.simantics.db.Resource;\r
5 import org.simantics.proconf.ui.workbench.ResourceEditorInput;\r
6 import org.simantics.proconf.ui.workbench.editor.SimpleEditorAdapter;\r
7 import org.simantics.utils.ui.BundleUtils;\r
8 import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
9 \r
10 import fi.vtt.simantics.processeditor.Activator;\r
11 import fi.vtt.simantics.processeditor.ProcessResource;\r
12 \r
13 /**\r
14  * EditorAdapter for PipeLineComponentEditor\r
15  * \r
16  * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>\r
17  *\r
18  */\r
19 public class PipelineComponentEditorAdapter extends SimpleEditorAdapter {\r
20         public PipelineComponentEditorAdapter() {\r
21                 super("Component Editor",\r
22                         BundleUtils.getImageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/Component.png"),\r
23                         null,null,null);\r
24         }\r
25 \r
26         @Override\r
27         public boolean canHandle(Graph g, Resource r) {\r
28                 if(ProcessResource.plant3Dresource == null) return false; \r
29                 if(ProcessResource.plant3Dresource.Plant == null) return false; \r
30                 if(!g.isInstanceOf(r, ProcessResource.plant3Dresource.PipelineComponent)) {\r
31                         if (g.isInstanceOf(r, ProcessResource.plant3Dresource.Nozzle))\r
32                                 return true;\r
33                         return false;\r
34                 }\r
35                 if(g.isInstanceOf(r, ProcessResource.plant3Dresource.CodedComponent)) return false;\r
36                 return true;\r
37         }\r
38 \r
39 \r
40         @Override\r
41         public void openEditor(Resource r) throws Exception {\r
42                 WorkbenchUtils.openEditor("org.simantics.proconf.processeditor.componenteditor", new ResourceEditorInput("org.simantics.proconf.processeditor.componenteditor",r));\r
43         }\r
44 \r
45 }\r