]>
Commit | Line | Data |
---|---|---|
06a19cee | 1 | /** @file\r |
2 | \r | |
3 | The file is used to create, update Event of MSA/MBD file\r | |
4 | \r | |
5 | Copyright (c) 2006, Intel Corporation\r | |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | package org.tianocore.frameworkwizard.module.ui.dialog;\r | |
16 | \r | |
17 | import java.awt.event.ActionEvent;\r | |
18 | import java.util.Vector;\r | |
19 | \r | |
20 | import javax.swing.JButton;\r | |
21 | import javax.swing.JComboBox;\r | |
22 | import javax.swing.JLabel;\r | |
23 | import javax.swing.JPanel;\r | |
24 | import javax.swing.JScrollPane;\r | |
25 | import javax.swing.JTextField;\r | |
26 | \r | |
27 | import org.tianocore.frameworkwizard.common.DataType;\r | |
28 | import org.tianocore.frameworkwizard.common.DataValidation;\r | |
29 | import org.tianocore.frameworkwizard.common.EnumerationData;\r | |
30 | import org.tianocore.frameworkwizard.common.Log;\r | |
31 | import org.tianocore.frameworkwizard.common.Tools;\r | |
32 | import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;\r | |
33 | import org.tianocore.frameworkwizard.common.ui.IDialog;\r | |
34 | import org.tianocore.frameworkwizard.common.ui.IFrame;\r | |
35 | import org.tianocore.frameworkwizard.common.ui.StarLabel;\r | |
36 | import org.tianocore.frameworkwizard.module.Identifications.Events.EventsIdentification;\r | |
37 | import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r | |
38 | \r | |
39 | /**\r | |
40 | The class is used to create, update Event of MSA/MBD file\r | |
41 | It extends IInternalFrame\r | |
42 | \r | |
43 | @since ModuleEditor 1.0\r | |
44 | \r | |
45 | **/\r | |
46 | public class EventsDlg extends IDialog {\r | |
47 | \r | |
48 | ///\r | |
49 | /// Define class Serial Version UID\r | |
50 | ///\r | |
51 | private static final long serialVersionUID = -4396143706422842331L;\r | |
52 | \r | |
53 | //\r | |
54 | //Define class members\r | |
55 | //\r | |
56 | private JPanel jContentPane = null;\r | |
57 | \r | |
58 | private JLabel jLabelEventType = null;\r | |
59 | \r | |
60 | private JLabel jLabelC_Name = null;\r | |
61 | \r | |
62 | private JComboBox jComboBoxGuidC_Name = null;\r | |
63 | \r | |
64 | private JLabel jLabelUsage = null;\r | |
65 | \r | |
66 | private JComboBox jComboBoxUsage = null;\r | |
67 | \r | |
68 | private StarLabel jStarLabel1 = null;\r | |
69 | \r | |
70 | private StarLabel jStarLabel2 = null;\r | |
71 | \r | |
72 | private JComboBox jComboBoxEventsType = null;\r | |
73 | \r | |
74 | private JScrollPane jScrollPane = null;\r | |
75 | \r | |
76 | private JLabel jLabelArch = null;\r | |
77 | \r | |
78 | private JLabel jLabelHelpText = null;\r | |
79 | \r | |
80 | private JTextField jTextFieldHelpText = null;\r | |
81 | \r | |
82 | private JLabel jLabelFeatureFlag = null;\r | |
83 | \r | |
84 | private JTextField jTextFieldFeatureFlag = null;\r | |
85 | \r | |
86 | private ArchCheckBox jArchCheckBox = null;\r | |
87 | \r | |
88 | private JButton jButtonOk = null;\r | |
89 | \r | |
90 | private JButton jButtonCancel = null;\r | |
91 | \r | |
92 | //\r | |
93 | // Not used by UI\r | |
94 | //\r | |
95 | private EventsIdentification id = null;\r | |
96 | \r | |
97 | private EnumerationData ed = new EnumerationData();\r | |
98 | \r | |
99 | private WorkspaceTools wt = new WorkspaceTools();\r | |
100 | \r | |
101 | /**\r | |
102 | This method initializes jTextFieldC_Name \r | |
103 | \r | |
104 | @return javax.swing.JTextField jTextFieldC_Name\r | |
105 | \r | |
106 | **/\r | |
107 | private JComboBox getJComboBoxGuidC_Name() {\r | |
108 | if (jComboBoxGuidC_Name == null) {\r | |
109 | jComboBoxGuidC_Name = new JComboBox();\r | |
110 | jComboBoxGuidC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));\r | |
111 | jComboBoxGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
112 | jComboBoxGuidC_Name.setToolTipText("Select the GUID C Name of the Event");\r | |
113 | }\r | |
114 | return jComboBoxGuidC_Name;\r | |
115 | }\r | |
116 | \r | |
117 | /**\r | |
118 | This method initializes jComboBoxUsage \r | |
119 | \r | |
120 | @return javax.swing.JComboBox jComboBoxUsage\r | |
121 | \r | |
122 | **/\r | |
123 | private JComboBox getJComboBoxUsage() {\r | |
124 | if (jComboBoxUsage == null) {\r | |
125 | jComboBoxUsage = new JComboBox();\r | |
126 | jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));\r | |
127 | jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
128 | }\r | |
129 | return jComboBoxUsage;\r | |
130 | }\r | |
131 | \r | |
132 | /**\r | |
133 | * This method initializes jComboBoxEventsType \r | |
134 | * \r | |
135 | * @return javax.swing.JComboBox \r | |
136 | */\r | |
137 | private JComboBox getJComboBoxEventsType() {\r | |
138 | if (jComboBoxEventsType == null) {\r | |
139 | jComboBoxEventsType = new JComboBox();\r | |
140 | jComboBoxEventsType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));\r | |
141 | jComboBoxEventsType.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
142 | jComboBoxEventsType\r | |
143 | .setToolTipText("Select Create event if the Module has an event that is waiting to be signaled. Select Signal if the Module will signal all events in an event group. Signal Event The events are named by GUID.");\r | |
144 | }\r | |
145 | return jComboBoxEventsType;\r | |
146 | }\r | |
147 | \r | |
148 | /**\r | |
149 | This method initializes jScrollPane \r | |
150 | \r | |
151 | @return javax.swing.JScrollPane \r | |
152 | */\r | |
153 | private JScrollPane getJScrollPane() {\r | |
154 | if (jScrollPane == null) {\r | |
155 | jScrollPane = new JScrollPane();\r | |
156 | jScrollPane.setViewportView(getJContentPane());\r | |
157 | }\r | |
158 | return jScrollPane;\r | |
159 | }\r | |
160 | \r | |
161 | /**\r | |
162 | * This method initializes jTextFieldFeatureFlag \r | |
163 | * \r | |
164 | * @return javax.swing.JTextField \r | |
165 | */\r | |
166 | private JTextField getJTextFieldFeatureFlag() {\r | |
167 | if (jTextFieldFeatureFlag == null) {\r | |
168 | jTextFieldFeatureFlag = new JTextField();\r | |
169 | jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));\r | |
170 | jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
171 | }\r | |
172 | return jTextFieldFeatureFlag;\r | |
173 | }\r | |
174 | \r | |
175 | /**\r | |
176 | This method initializes jTextFieldHelpText \r | |
177 | \r | |
178 | @return javax.swing.JTextField \r | |
179 | \r | |
180 | **/\r | |
181 | private JTextField getJTextFieldHelpText() {\r | |
182 | if (jTextFieldHelpText == null) {\r | |
183 | jTextFieldHelpText = new JTextField();\r | |
184 | jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));\r | |
185 | jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
186 | }\r | |
187 | return jTextFieldHelpText;\r | |
188 | }\r | |
189 | \r | |
190 | /**\r | |
191 | This method initializes jButtonOk \r | |
192 | \r | |
193 | @return javax.swing.JButton \r | |
194 | \r | |
195 | **/\r | |
196 | private JButton getJButtonOk() {\r | |
197 | if (jButtonOk == null) {\r | |
198 | jButtonOk = new JButton();\r | |
199 | jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20));\r | |
200 | jButtonOk.setText("Ok");\r | |
201 | jButtonOk.addActionListener(this);\r | |
202 | }\r | |
203 | return jButtonOk;\r | |
204 | }\r | |
205 | \r | |
206 | /**\r | |
207 | This method initializes jButtonCancel \r | |
208 | \r | |
209 | @return javax.swing.JButton \r | |
210 | \r | |
211 | **/\r | |
212 | private JButton getJButtonCancel() {\r | |
213 | if (jButtonCancel == null) {\r | |
214 | jButtonCancel = new JButton();\r | |
215 | jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20));\r | |
216 | jButtonCancel.setText("Cancel");\r | |
217 | jButtonCancel.addActionListener(this);\r | |
218 | }\r | |
219 | return jButtonCancel;\r | |
220 | }\r | |
221 | \r | |
222 | public static void main(String[] args) {\r | |
223 | \r | |
224 | }\r | |
225 | \r | |
226 | /**\r | |
227 | This method initializes this\r | |
228 | \r | |
229 | **/\r | |
230 | private void init() {\r | |
231 | this.setSize(500, 225);\r | |
232 | this.setContentPane(getJScrollPane());\r | |
233 | this.setTitle("Events");\r | |
234 | initFrame();\r | |
235 | this.setViewMode(false);\r | |
236 | this.centerWindow();\r | |
237 | }\r | |
238 | \r | |
239 | /**\r | |
240 | This method initializes this\r | |
241 | Fill values to all fields if these values are not empty\r | |
242 | \r | |
243 | @param inEventsId\r | |
244 | \r | |
245 | **/\r | |
246 | private void init(EventsIdentification inEventsId) {\r | |
247 | init();\r | |
248 | this.id = inEventsId;\r | |
249 | \r | |
250 | if (this.id != null) {\r | |
251 | this.jComboBoxGuidC_Name.setSelectedItem(id.getName());\r | |
252 | this.jComboBoxEventsType.setSelectedItem(id.getType());\r | |
253 | this.jComboBoxUsage.setSelectedItem(id.getUsage());\r | |
254 | this.jTextFieldHelpText.setText(id.getHelp());\r | |
255 | \r | |
256 | jTextFieldFeatureFlag.setText(id.getFeatureFlag());\r | |
257 | this.jArchCheckBox.setSelectedItems(id.getSupArchList());\r | |
258 | }\r | |
259 | }\r | |
260 | \r | |
261 | /**\r | |
262 | This is the override edit constructor\r | |
263 | \r | |
264 | @param inEventsIdentification\r | |
265 | @param iFrame\r | |
266 | \r | |
267 | **/\r | |
268 | public EventsDlg(EventsIdentification inEventsIdentification, IFrame iFrame) {\r | |
269 | super(iFrame, true);\r | |
270 | init(inEventsIdentification);\r | |
271 | }\r | |
272 | \r | |
273 | /**\r | |
274 | Disable all components when the mode is view\r | |
275 | \r | |
276 | @param isView true - The view mode; false - The non-view mode\r | |
277 | \r | |
278 | **/\r | |
279 | public void setViewMode(boolean isView) {\r | |
280 | if (isView) {\r | |
281 | this.jComboBoxGuidC_Name.setEnabled(!isView);\r | |
282 | this.jComboBoxUsage.setEnabled(!isView);\r | |
283 | }\r | |
284 | }\r | |
285 | \r | |
286 | /**\r | |
287 | This method initializes jContentPane\r | |
288 | \r | |
289 | @return javax.swing.JPanel jContentPane\r | |
290 | \r | |
291 | **/\r | |
292 | private JPanel getJContentPane() {\r | |
293 | if (jContentPane == null) {\r | |
294 | jArchCheckBox = new ArchCheckBox();\r | |
295 | jArchCheckBox.setBounds(new java.awt.Rectangle(160, 135, 320, 20));\r | |
296 | jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
297 | jLabelFeatureFlag = new JLabel();\r | |
298 | jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));\r | |
299 | jLabelFeatureFlag.setText("Feature Flag");\r | |
300 | jLabelArch = new JLabel();\r | |
301 | jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));\r | |
302 | jLabelArch.setText("Arch");\r | |
303 | jLabelUsage = new JLabel();\r | |
304 | jLabelUsage.setText("Usage");\r | |
305 | jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));\r | |
306 | jLabelC_Name = new JLabel();\r | |
307 | jLabelC_Name.setText("Guid C_Name");\r | |
308 | jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));\r | |
309 | jLabelEventType = new JLabel();\r | |
310 | jLabelEventType.setText("Event Type");\r | |
311 | jLabelEventType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));\r | |
312 | jLabelHelpText = new JLabel();\r | |
313 | jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));\r | |
314 | jLabelHelpText.setText("Help Text");\r | |
315 | \r | |
316 | jContentPane = new JPanel();\r | |
317 | jContentPane.setLayout(null);\r | |
318 | jContentPane.setPreferredSize(new java.awt.Dimension(490, 190));\r | |
319 | \r | |
320 | jContentPane.add(jLabelEventType, null);\r | |
321 | jContentPane.add(jLabelC_Name, null);\r | |
322 | jContentPane.add(getJComboBoxGuidC_Name(), null);\r | |
323 | jContentPane.add(jLabelUsage, null);\r | |
324 | jContentPane.add(getJComboBoxUsage(), null);\r | |
325 | jStarLabel1 = new StarLabel();\r | |
326 | jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));\r | |
327 | jStarLabel2 = new StarLabel();\r | |
328 | jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));\r | |
329 | \r | |
330 | jContentPane.add(jStarLabel1, null);\r | |
331 | jContentPane.add(jStarLabel2, null);\r | |
332 | jContentPane.add(getJComboBoxEventsType(), null);\r | |
333 | \r | |
334 | jContentPane.add(jLabelArch, null);\r | |
335 | jContentPane.add(jLabelFeatureFlag, null);\r | |
336 | jContentPane.add(getJTextFieldFeatureFlag(), null);\r | |
337 | jContentPane.add(jLabelHelpText, null);\r | |
338 | jContentPane.add(getJTextFieldHelpText(), null);\r | |
339 | jContentPane.add(jArchCheckBox, null);\r | |
340 | jContentPane.add(getJButtonOk(), null);\r | |
341 | jContentPane.add(getJButtonCancel(), null);\r | |
342 | }\r | |
343 | return jContentPane;\r | |
344 | }\r | |
345 | \r | |
346 | /**\r | |
347 | This method initializes events groups and usage type\r | |
348 | \r | |
349 | **/\r | |
350 | private void initFrame() {\r | |
351 | Tools.generateComboBoxByVector(jComboBoxEventsType, ed.getVEventType());\r | |
352 | Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVEventUsage());\r | |
353 | Tools.generateComboBoxByVector(jComboBoxGuidC_Name, wt.getAllGuidDeclarationsFromWorkspace());\r | |
354 | }\r | |
355 | \r | |
356 | /* (non-Javadoc)\r | |
357 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r | |
358 | *\r | |
359 | * Override actionPerformed to listen all actions\r | |
360 | * \r | |
361 | */\r | |
362 | public void actionPerformed(ActionEvent arg0) {\r | |
363 | if (arg0.getSource() == jButtonOk) {\r | |
364 | if (checkAdd()) {\r | |
365 | getCurrentEvents();\r | |
366 | this.returnType = DataType.RETURN_TYPE_OK;\r | |
367 | this.setVisible(false);\r | |
368 | }\r | |
369 | }\r | |
370 | \r | |
371 | if (arg0.getSource() == jButtonCancel) {\r | |
372 | this.returnType = DataType.RETURN_TYPE_CANCEL;\r | |
373 | this.setVisible(false);\r | |
374 | }\r | |
375 | }\r | |
376 | \r | |
377 | /**\r | |
378 | Data validation for all fields\r | |
379 | \r | |
380 | @retval true - All datas are valid\r | |
381 | @retval false - At least one data is invalid\r | |
382 | \r | |
383 | **/\r | |
384 | public boolean checkAdd() {\r | |
385 | //\r | |
386 | // Check if all fields have correct data types \r | |
387 | //\r | |
388 | \r | |
389 | //\r | |
390 | // Check Name \r | |
391 | //\r | |
392 | if (isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {\r | |
393 | Log.err("Event Name couldn't be empty");\r | |
394 | return false;\r | |
395 | }\r | |
396 | \r | |
397 | if (!isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {\r | |
398 | if (!DataValidation.isC_NameType(this.jComboBoxGuidC_Name.getSelectedItem().toString())) {\r | |
399 | Log.err("Incorrect data type for Event Name");\r | |
400 | return false;\r | |
401 | }\r | |
402 | }\r | |
403 | \r | |
404 | //\r | |
405 | // Check FeatureFlag\r | |
406 | //\r | |
407 | if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {\r | |
408 | if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {\r | |
409 | Log.err("Incorrect data type for Feature Flag");\r | |
410 | return false;\r | |
411 | }\r | |
412 | }\r | |
413 | \r | |
414 | return true;\r | |
415 | }\r | |
416 | \r | |
417 | private EventsIdentification getCurrentEvents() {\r | |
418 | String arg0 = this.jComboBoxGuidC_Name.getSelectedItem().toString();\r | |
419 | String arg1 = this.jComboBoxEventsType.getSelectedItem().toString();\r | |
420 | String arg2 = this.jComboBoxUsage.getSelectedItem().toString();\r | |
421 | \r | |
422 | String arg3 = this.jTextFieldFeatureFlag.getText();\r | |
423 | Vector<String> arg4 = this.jArchCheckBox.getSelectedItemsVector();\r | |
424 | String arg5 = this.jTextFieldHelpText.getText();\r | |
425 | id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);\r | |
426 | return id;\r | |
427 | }\r | |
428 | \r | |
429 | public EventsIdentification getId() {\r | |
430 | return id;\r | |
431 | }\r | |
432 | \r | |
433 | public void setId(EventsIdentification id) {\r | |
434 | this.id = id;\r | |
435 | }\r | |
436 | }\r |