]> gerrit.simantics Code Review - simantics/3d.git/blob
91f65baa962870bdb250dcf20311074c8d71f486
[simantics/3d.git] /
1 package fi.vtt.simantics.processeditor.tools;\r
2 \r
3 import java.util.ArrayList;\r
4 import java.util.Collection;\r
5 import java.util.List;\r
6 \r
7 import org.eclipse.jface.action.Action;\r
8 import org.eclipse.jface.action.IContributionItem;\r
9 import org.eclipse.jface.action.IMenuManager;\r
10 import org.eclipse.jface.action.IToolBarManager;\r
11 import org.eclipse.swt.SWT;\r
12 import org.eclipse.swt.layout.FillLayout;\r
13 import org.eclipse.swt.layout.FormAttachment;\r
14 import org.eclipse.swt.layout.FormData;\r
15 import org.eclipse.swt.layout.FormLayout;\r
16 import org.eclipse.swt.widgets.Button;\r
17 import org.eclipse.swt.widgets.Composite;\r
18 import org.eclipse.swt.widgets.Label;\r
19 import org.eclipse.swt.widgets.Text;\r
20 import org.simantics.db.Graph;\r
21 import org.simantics.db.Resource;\r
22 import org.simantics.proconf.g3d.actions.ContextAction;\r
23 import org.simantics.proconf.g3d.base.EditorContribution;\r
24 import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase;\r
25 import org.simantics.proconf.g3d.common.StructuredResourceSelection;\r
26 \r
27 import fi.vtt.simantics.processeditor.ProcessResource;\r
28 \r
29 public class NozzleContribution implements EditorContribution {\r
30         private List<ContextAction> actions = new ArrayList<ContextAction>();\r
31         private ThreeDimensionalEditorBase parent;\r
32         private Resource equipmentResource;\r
33         private Composite sideComposite;\r
34         \r
35         public NozzleContribution(ThreeDimensionalEditorBase parent) {\r
36                 this.parent = parent;\r
37         }\r
38         \r
39         @Override\r
40         public void createControl(Composite parent) {\r
41                 FormLayout flayout = new FormLayout();\r
42                 parent.setLayout(flayout);\r
43                 sideComposite = new Composite(parent,SWT.BORDER);\r
44                 FormData data = new FormData();\r
45                 data.top = new FormAttachment(0, 0);\r
46                 data.left = new FormAttachment(0, 0);\r
47                 data.right = new FormAttachment(sideComposite, 0, SWT.LEFT);\r
48                 data.bottom = new FormAttachment(100,0);\r
49                 this.parent.getRenderingComposite().setLayoutData(data);\r
50                 sideComposite.setLayout(new FillLayout(SWT.VERTICAL));\r
51                 data = new FormData();\r
52                 data.top = new FormAttachment(0, 0);\r
53                 data.bottom = new FormAttachment(100,0);\r
54                 data.right = new FormAttachment(100,0);\r
55                 sideComposite.setLayoutData(data);\r
56                 showNozzles(true);\r
57                 \r
58                 Button addButton = new Button(sideComposite,SWT.PUSH);\r
59                 addButton.setText("Add Nozzle");\r
60                 Label label = new Label(sideComposite,SWT.NONE);\r
61                 label.setText("Restrictions:");\r
62                 Button minButton = new Button(sideComposite,SWT.CHECK);\r
63                 minButton.setText("Min");\r
64                 Text minText = new Text(sideComposite,SWT.SINGLE | SWT.BORDER);\r
65                 Button maxButton = new Button(sideComposite,SWT.CHECK);\r
66                 maxButton.setText("Max");\r
67                 Text maxText = new Text(sideComposite,SWT.SINGLE | SWT.BORDER);\r
68                 minText.setToolTipText("Enter minimum number of nozzles");\r
69                 maxText.setToolTipText("Enter maximum number of nozzles");\r
70 \r
71         }\r
72         \r
73         @Override\r
74         public void disposeControl() {\r
75                 sideComposite.dispose();\r
76                 \r
77         }\r
78         @Override\r
79         public void fillContextMenu(Graph graph, IMenuManager manager,\r
80                         StructuredResourceSelection selection) {\r
81 \r
82         }\r
83         \r
84         @Override\r
85         public void fillLocalPullDown(IMenuManager manager) {\r
86 \r
87         }\r
88         \r
89         @Override\r
90         public void fillLocalToolBar(IToolBarManager manager) {\r
91 \r
92         }\r
93         \r
94         @Override\r
95         public Collection<ContextAction> getActions() {\r
96                 return actions;\r
97         }\r
98         \r
99         @Override\r
100         public String getName() {\r
101                 return "Nozzles";\r
102         }\r
103         \r
104         private void showNozzles(boolean show) {\r
105                 \r
106         }\r
107         \r
108         @Override\r
109         public void initialize(Graph graph) {\r
110                 Resource modelResource = parent.getInputResource();\r
111                 Resource inverse = graph.getInverse(ProcessResource.plant3Dresource.HasGraphics);\r
112                 Collection<Resource> equipment = graph.getObjects(modelResource, inverse);\r
113                 if (equipment.size() != 1)\r
114                         throw new RuntimeException("Cannot find equipment");\r
115                 equipmentResource = equipment.iterator().next();\r
116         }\r
117         \r
118         @Override\r
119         public void dispose() {\r
120                 showNozzles(false);\r
121         }\r
122         \r
123         @Override\r
124         public void run() {\r
125 \r
126         }\r
127         \r
128         \r
129 }\r