06a19cee |
1 | /** @file\r |
2 | \r |
3f62225f |
3 | The file is used to create, update Events section of the MSA file\r |
06a19cee |
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 |
7ab6baa9 |
26 | import javax.swing.JTextArea;\r |
06a19cee |
27 | \r |
28 | import org.tianocore.frameworkwizard.common.DataType;\r |
29 | import org.tianocore.frameworkwizard.common.DataValidation;\r |
30 | import org.tianocore.frameworkwizard.common.EnumerationData;\r |
31 | import org.tianocore.frameworkwizard.common.Log;\r |
32 | import org.tianocore.frameworkwizard.common.Tools;\r |
33 | import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;\r |
55683eab |
34 | import org.tianocore.frameworkwizard.common.ui.IComboBox;\r |
06a19cee |
35 | import org.tianocore.frameworkwizard.common.ui.IDialog;\r |
36 | import org.tianocore.frameworkwizard.common.ui.IFrame;\r |
37 | import org.tianocore.frameworkwizard.common.ui.StarLabel;\r |
e08433ef |
38 | import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r |
06a19cee |
39 | import org.tianocore.frameworkwizard.module.Identifications.Events.EventsIdentification;\r |
d48c170d |
40 | import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r |
06a19cee |
41 | import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r |
42 | \r |
43 | /**\r |
3f62225f |
44 | * The class is used to create, update Events section of the MSA file \r |
45 | * It extends IDialog\r |
7ab6baa9 |
46 | * \r |
47 | * @since ModuleEditor 1.0\r |
48 | * \r |
49 | */\r |
06a19cee |
50 | public class EventsDlg extends IDialog {\r |
51 | \r |
a929458e |
52 | // /\r |
53 | // / Define class Serial Version UID\r |
54 | // /\r |
55 | private static final long serialVersionUID = -4396143706422842331L;\r |
06a19cee |
56 | \r |
a929458e |
57 | //\r |
58 | // Define class members\r |
59 | //\r |
60 | private JPanel jContentPane = null;\r |
06a19cee |
61 | \r |
a929458e |
62 | private JLabel jLabelEventType = null;\r |
06a19cee |
63 | \r |
a929458e |
64 | private JLabel jLabelC_Name = null;\r |
06a19cee |
65 | \r |
55683eab |
66 | private IComboBox iComboBoxGuidC_Name = null;\r |
06a19cee |
67 | \r |
a929458e |
68 | private JLabel jLabelUsage = null;\r |
06a19cee |
69 | \r |
a929458e |
70 | private JLabel jLabelGroup = null;\r |
06a19cee |
71 | \r |
a929458e |
72 | private JComboBox jComboBoxUsage = null;\r |
06a19cee |
73 | \r |
a929458e |
74 | private JComboBox jComboBoxEventGroup = null;\r |
06a19cee |
75 | \r |
a929458e |
76 | private StarLabel jStarLabel1 = null;\r |
06a19cee |
77 | \r |
a929458e |
78 | private StarLabel jStarLabel2 = null;\r |
06a19cee |
79 | \r |
a929458e |
80 | private StarLabel jStarLabel3 = null;\r |
06a19cee |
81 | \r |
a929458e |
82 | private StarLabel jStarLabel4 = null;\r |
06a19cee |
83 | \r |
a929458e |
84 | private JComboBox jComboBoxEventsType = null;\r |
06a19cee |
85 | \r |
a929458e |
86 | private JScrollPane jScrollPane = null;\r |
06a19cee |
87 | \r |
a929458e |
88 | private JLabel jLabelArch = null;\r |
06a19cee |
89 | \r |
a929458e |
90 | private JLabel jLabelHelpText = null;\r |
06a19cee |
91 | \r |
a929458e |
92 | private JTextArea jTextAreaHelpText = null;\r |
06a19cee |
93 | \r |
a929458e |
94 | private JScrollPane jScrollPaneHelpText = null;\r |
06a19cee |
95 | \r |
a929458e |
96 | private JLabel jLabelFeatureFlag = null;\r |
06a19cee |
97 | \r |
a929458e |
98 | private JTextField jTextFieldFeatureFlag = null;\r |
06a19cee |
99 | \r |
a929458e |
100 | private ArchCheckBox jArchCheckBox = null;\r |
06a19cee |
101 | \r |
a929458e |
102 | private JButton jButtonOk = null;\r |
06a19cee |
103 | \r |
a929458e |
104 | private JButton jButtonCancel = null;\r |
06a19cee |
105 | \r |
a929458e |
106 | //\r |
107 | // Not used by UI\r |
108 | //\r |
109 | private EventsIdentification id = null;\r |
110 | \r |
111 | private EnumerationData ed = new EnumerationData();\r |
112 | \r |
113 | private WorkspaceTools wt = new WorkspaceTools();\r |
114 | \r |
115 | /**\r |
116 | * This method initializes jComboBoxType\r |
117 | * \r |
118 | * @return javax.swing.JComboBox jComboBoxType\r |
119 | * \r |
120 | */\r |
121 | private JComboBox getJComboBoxEventsType() {\r |
122 | if (jComboBoxEventsType == null) {\r |
123 | jComboBoxEventsType = new JComboBox();\r |
3f62225f |
124 | jComboBoxEventsType.setBounds(new java.awt.Rectangle(168, 12, 320, 20));\r |
a929458e |
125 | jComboBoxEventsType.setPreferredSize(new java.awt.Dimension(320, 20));\r |
126 | jComboBoxEventsType\r |
9e857952 |
127 | .setToolTipText("<html>Select CreateEvents if the Module has an event that is waiting to be signaled.<br>"\r |
128 | + "Select SignalEvents if the Module will signal all events in an event group.<br>"\r |
129 | + "NOTE: Signal events are named by GUID.</html>");\r |
a929458e |
130 | }\r |
131 | return jComboBoxEventsType;\r |
132 | }\r |
06a19cee |
133 | \r |
a929458e |
134 | /**\r |
135 | * This method initializes jTextFieldC_Name\r |
136 | * \r |
137 | * @return javax.swing.JTextField jTextFieldC_Name\r |
138 | * \r |
139 | */\r |
55683eab |
140 | private IComboBox getIComboBoxGuidC_Name() {\r |
141 | if (iComboBoxGuidC_Name == null) {\r |
142 | iComboBoxGuidC_Name = new IComboBox();\r |
143 | iComboBoxGuidC_Name.setBounds(new java.awt.Rectangle(168, 37, 320, 20));\r |
144 | iComboBoxGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20));\r |
145 | iComboBoxGuidC_Name.setToolTipText("Select the GUID C Name of the Event");\r |
a929458e |
146 | }\r |
55683eab |
147 | return iComboBoxGuidC_Name;\r |
a929458e |
148 | }\r |
06a19cee |
149 | \r |
a929458e |
150 | /**\r |
151 | * This method initializes jComboBoxEventsType\r |
152 | * \r |
153 | * @return javax.swing.JComboBox\r |
154 | */\r |
155 | private JComboBox getJComboBoxEventGroup() {\r |
156 | if (jComboBoxEventGroup == null) {\r |
157 | jComboBoxEventGroup = new JComboBox();\r |
3f62225f |
158 | jComboBoxEventGroup.setBounds(new java.awt.Rectangle(168, 62, 320, 20));\r |
a929458e |
159 | jComboBoxEventGroup.setPreferredSize(new java.awt.Dimension(320, 20));\r |
160 | jComboBoxEventGroup.setToolTipText("Select Type of Event: Guid or Timer.");\r |
161 | \r |
162 | }\r |
163 | return jComboBoxEventGroup;\r |
164 | }\r |
06a19cee |
165 | \r |
a929458e |
166 | /**\r |
167 | * This method initializes jComboBoxUsage\r |
168 | * \r |
169 | * @return javax.swing.JComboBox jComboBoxUsage\r |
170 | * \r |
171 | */\r |
172 | private JComboBox getJComboBoxUsage() {\r |
173 | if (jComboBoxUsage == null) {\r |
174 | jComboBoxUsage = new JComboBox();\r |
3f62225f |
175 | jComboBoxUsage.setBounds(new java.awt.Rectangle(168, 87, 320, 20));\r |
a929458e |
176 | jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));\r |
177 | jComboBoxUsage\r |
9e857952 |
178 | .setToolTipText("<html><table>"\r |
179 | + "<tr><td colspan=2 align=center><b>Create Events</b></td></tr>"\r |
180 | + "<tr><td>ALWAYS_CONSUMED</td><td>Module registers a notification function and REQUIRES that it be<br>"\r |
181 | + "executed for the module to fully function.</td></tr>"\r |
182 | + "<tr><td>SOMETIMES_CONSUMED</td><td>Module registers a notification function and calls the function<br>"\r |
183 | + "when it is signaled</td></tr><tr><td colspan=2 align=center><b>Signal Events</b></td></tr>"\r |
184 | + "<tr><td>ALWAYS_PRODUCED</td><td>Module will Always signal the event</td></tr>"\r |
185 | + "<tr><td>SOMETIMES_PRODUCED</td><td>Module will sometimes signal the event</td></tr>"\r |
186 | + "</table></html>");\r |
a929458e |
187 | }\r |
188 | return jComboBoxUsage;\r |
06a19cee |
189 | }\r |
a929458e |
190 | \r |
191 | /**\r |
192 | * This method initializes jScrollPane\r |
193 | * \r |
194 | * @return javax.swing.JScrollPane\r |
195 | */\r |
196 | private JScrollPane getJScrollPane() {\r |
197 | if (jScrollPane == null) {\r |
198 | jScrollPane = new JScrollPane();\r |
199 | jScrollPane.setViewportView(getJContentPane());\r |
200 | }\r |
201 | return jScrollPane;\r |
06a19cee |
202 | }\r |
203 | \r |
a929458e |
204 | /**\r |
205 | * This method initializes jTextFieldFeatureFlag\r |
206 | * \r |
207 | * @return javax.swing.JTextField\r |
208 | */\r |
209 | private JTextField getJTextFieldFeatureFlag() {\r |
210 | if (jTextFieldFeatureFlag == null) {\r |
211 | jTextFieldFeatureFlag = new JTextField();\r |
21b42c66 |
212 | jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(168, 182, 320, 20));\r |
a929458e |
213 | jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));\r |
214 | jTextFieldFeatureFlag.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");\r |
21b42c66 |
215 | jTextFieldFeatureFlag.setEnabled(false);\r |
a929458e |
216 | }\r |
217 | return jTextFieldFeatureFlag;\r |
06a19cee |
218 | }\r |
a929458e |
219 | \r |
220 | /**\r |
221 | * This method initializes jTextAreaHelpText\r |
222 | * \r |
223 | * @return javax.swing.JTextArea\r |
224 | * \r |
225 | */\r |
226 | private JTextArea getJTextAreaHelpText() {\r |
227 | if (jTextAreaHelpText == null) {\r |
228 | jTextAreaHelpText = new JTextArea();\r |
229 | jTextAreaHelpText.setLineWrap(true);\r |
230 | jTextAreaHelpText.setWrapStyleWord(true);\r |
231 | }\r |
232 | return jTextAreaHelpText;\r |
06a19cee |
233 | }\r |
a929458e |
234 | \r |
235 | /**\r |
236 | * This method initializes jScrollPaneHelpText\r |
237 | * \r |
238 | * @return javax.swing.JScrollPane\r |
239 | * \r |
240 | */\r |
241 | private JScrollPane getJScrollPaneHelpText() {\r |
242 | if (jScrollPaneHelpText == null) {\r |
243 | jScrollPaneHelpText = new JScrollPane();\r |
244 | jScrollPaneHelpText.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r |
245 | jScrollPaneHelpText.setSize(new java.awt.Dimension(320, 40));\r |
246 | jScrollPaneHelpText.setPreferredSize(new java.awt.Dimension(320, 40));\r |
3f62225f |
247 | jScrollPaneHelpText.setLocation(new java.awt.Point(168, 112));\r |
a929458e |
248 | jScrollPaneHelpText.setViewportView(getJTextAreaHelpText());\r |
249 | }\r |
250 | return jScrollPaneHelpText;\r |
06a19cee |
251 | }\r |
a929458e |
252 | \r |
253 | /**\r |
254 | * This method initializes jButtonOk\r |
255 | * \r |
256 | * @return javax.swing.JButton\r |
257 | * \r |
258 | */\r |
259 | private JButton getJButtonOk() {\r |
260 | if (jButtonOk == null) {\r |
261 | jButtonOk = new JButton();\r |
3f62225f |
262 | jButtonOk.setBounds(new java.awt.Rectangle(290, 212, 90, 20));\r |
a929458e |
263 | jButtonOk.setText("Ok");\r |
264 | jButtonOk.addActionListener(this);\r |
265 | }\r |
266 | return jButtonOk;\r |
06a19cee |
267 | }\r |
a929458e |
268 | \r |
269 | /**\r |
270 | * This method initializes jButtonCancel\r |
271 | * \r |
272 | * @return javax.swing.JButton\r |
273 | * \r |
274 | */\r |
275 | private JButton getJButtonCancel() {\r |
276 | if (jButtonCancel == null) {\r |
277 | jButtonCancel = new JButton();\r |
3f62225f |
278 | jButtonCancel.setBounds(new java.awt.Rectangle(390, 212, 90, 20));\r |
a929458e |
279 | jButtonCancel.setText("Cancel");\r |
280 | jButtonCancel.addActionListener(this);\r |
281 | }\r |
282 | return jButtonCancel;\r |
7ab6baa9 |
283 | }\r |
a929458e |
284 | \r |
285 | public static void main(String[] args) {\r |
286 | \r |
7ab6baa9 |
287 | }\r |
a929458e |
288 | \r |
289 | /**\r |
290 | * This method initializes this\r |
291 | * \r |
292 | */\r |
293 | private void init() {\r |
3f62225f |
294 | this.setSize(505, 280);\r |
a929458e |
295 | this.setContentPane(getJScrollPane());\r |
296 | this.setTitle("Events");\r |
297 | initFrame();\r |
298 | this.setViewMode(false);\r |
299 | this.centerWindow();\r |
7ab6baa9 |
300 | }\r |
a929458e |
301 | \r |
302 | /**\r |
303 | * This method initializes this Fill values to all fields if these values are\r |
304 | * not empty\r |
305 | * \r |
306 | * @param inEventsId\r |
307 | * \r |
308 | */\r |
e08433ef |
309 | private void init(EventsIdentification inEventsId, ModuleIdentification mid) {\r |
a929458e |
310 | init();\r |
311 | this.id = inEventsId;\r |
d48c170d |
312 | \r |
e08433ef |
313 | //\r |
314 | // Init arch with module's arch\r |
315 | //\r |
316 | this.jArchCheckBox.setEnabledItems(wt.getModuleArch(mid));\r |
d48c170d |
317 | \r |
318 | //\r |
319 | // Get defined guids from dependent packages\r |
320 | //\r |
321 | Vector<PackageIdentification> vpid = wt.getPackageDependenciesOfModule(mid);\r |
322 | if (vpid.size() <= 0) {\r |
323 | Log\r |
324 | .wrn("Init Guid",\r |
325 | "This module hasn't defined any package dependency, so there is no guid value can be added for event");\r |
326 | }\r |
327 | //\r |
328 | // Init guids drop down list\r |
329 | //\r |
330 | Tools\r |
55683eab |
331 | .generateComboBoxByVector(iComboBoxGuidC_Name,\r |
d48c170d |
332 | wt.getAllGuidDeclarationsFromPackages(vpid, EnumerationData.GUID_TYPE_EFI_EVENT));\r |
333 | \r |
a929458e |
334 | if (this.id != null) {\r |
55683eab |
335 | this.iComboBoxGuidC_Name.setSelectedItem(id.getName());\r |
a929458e |
336 | this.jComboBoxEventsType.setSelectedItem(id.getType());\r |
337 | this.jComboBoxUsage.setSelectedItem(id.getUsage());\r |
338 | this.jTextAreaHelpText.setText(id.getHelp());\r |
339 | \r |
340 | jTextFieldFeatureFlag.setText(id.getFeatureFlag());\r |
341 | this.jArchCheckBox.setSelectedItems(id.getSupArchList());\r |
342 | this.jComboBoxEventGroup.setSelectedItem(id.getGroup());\r |
343 | }\r |
7ab6baa9 |
344 | }\r |
a929458e |
345 | \r |
346 | /**\r |
347 | * This is the override edit constructor\r |
348 | * \r |
349 | * @param inEventsIdentification\r |
350 | * @param iFrame\r |
351 | * \r |
352 | */\r |
e08433ef |
353 | public EventsDlg(EventsIdentification inEventsIdentification, IFrame iFrame, ModuleIdentification mid) {\r |
a929458e |
354 | super(iFrame, true);\r |
e08433ef |
355 | init(inEventsIdentification, mid);\r |
7ab6baa9 |
356 | }\r |
a929458e |
357 | \r |
358 | /**\r |
359 | * Disable all components when the mode is view\r |
360 | * \r |
361 | * @param isView\r |
362 | * true - The view mode; false - The non-view mode\r |
363 | * \r |
364 | */\r |
365 | public void setViewMode(boolean isView) {\r |
366 | if (isView) {\r |
55683eab |
367 | this.iComboBoxGuidC_Name.setEnabled(!isView);\r |
a929458e |
368 | this.jComboBoxUsage.setEnabled(!isView);\r |
369 | }\r |
06a19cee |
370 | }\r |
371 | \r |
a929458e |
372 | /**\r |
373 | * This method initializes jContentPane\r |
374 | * \r |
375 | * @return javax.swing.JPanel jContentPane\r |
376 | * \r |
377 | */\r |
378 | private JPanel getJContentPane() {\r |
379 | if (jContentPane == null) {\r |
380 | jStarLabel1 = new StarLabel();\r |
3f62225f |
381 | jStarLabel1.setLocation(new java.awt.Point(2, 12));\r |
a929458e |
382 | jLabelEventType = new JLabel();\r |
383 | jLabelEventType.setText("Select Event Type");\r |
3f62225f |
384 | jLabelEventType.setBounds(new java.awt.Rectangle(12, 12, 168, 20));\r |
a929458e |
385 | \r |
386 | jStarLabel2 = new StarLabel();\r |
3f62225f |
387 | jStarLabel2.setLocation(new java.awt.Point(2, 37));\r |
a929458e |
388 | jLabelC_Name = new JLabel();\r |
389 | jLabelC_Name.setText("Guid C Name");\r |
3f62225f |
390 | jLabelC_Name.setBounds(new java.awt.Rectangle(12, 37, 168, 20));\r |
a929458e |
391 | \r |
392 | jStarLabel3 = new StarLabel();\r |
3f62225f |
393 | jStarLabel3.setLocation(new java.awt.Point(2, 62));\r |
a929458e |
394 | jLabelGroup = new JLabel();\r |
395 | jLabelGroup.setText("Event Group Type");\r |
3f62225f |
396 | jLabelGroup.setBounds(new java.awt.Rectangle(12, 62, 168, 20));\r |
a929458e |
397 | \r |
398 | jStarLabel4 = new StarLabel();\r |
3f62225f |
399 | jStarLabel4.setLocation(new java.awt.Point(2, 87));\r |
a929458e |
400 | jLabelUsage = new JLabel();\r |
401 | jLabelUsage.setText("Usage");\r |
3f62225f |
402 | jLabelUsage.setBounds(new java.awt.Rectangle(12, 87, 168, 20));\r |
a929458e |
403 | \r |
404 | jLabelHelpText = new JLabel();\r |
3f62225f |
405 | jLabelHelpText.setBounds(new java.awt.Rectangle(12, 112, 168, 20));\r |
a929458e |
406 | jLabelHelpText.setText("Help Text");\r |
407 | \r |
408 | jLabelFeatureFlag = new JLabel();\r |
21b42c66 |
409 | jLabelFeatureFlag.setBounds(new java.awt.Rectangle(12, 182, 168, 20));\r |
a929458e |
410 | jLabelFeatureFlag.setText("Feature Flag Expression");\r |
21b42c66 |
411 | jLabelFeatureFlag.setEnabled(false);\r |
a929458e |
412 | \r |
413 | jLabelArch = new JLabel();\r |
21b42c66 |
414 | jLabelArch.setBounds(new java.awt.Rectangle(12, 157, 168, 20));\r |
a929458e |
415 | jLabelArch.setText("Supported Architectures");\r |
416 | jArchCheckBox = new ArchCheckBox();\r |
21b42c66 |
417 | jArchCheckBox.setBounds(new java.awt.Rectangle(168, 157, 320, 20));\r |
a929458e |
418 | jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));\r |
419 | \r |
420 | jContentPane = new JPanel();\r |
421 | jContentPane.setLayout(null);\r |
3f62225f |
422 | jContentPane.setPreferredSize(new java.awt.Dimension(485, 235));\r |
a929458e |
423 | \r |
424 | jContentPane.add(jStarLabel1, null);\r |
425 | jContentPane.add(jLabelEventType, null);\r |
426 | jContentPane.add(getJComboBoxEventsType(), null);\r |
427 | jContentPane.add(jStarLabel2, null);\r |
428 | jContentPane.add(jLabelC_Name, null);\r |
55683eab |
429 | jContentPane.add(getIComboBoxGuidC_Name(), null);\r |
a929458e |
430 | jContentPane.add(jStarLabel3, null);\r |
431 | jContentPane.add(jLabelGroup, null);\r |
432 | jContentPane.add(getJComboBoxEventGroup(), null);\r |
433 | jContentPane.add(jStarLabel4, null);\r |
434 | jContentPane.add(jLabelUsage, null);\r |
435 | jContentPane.add(getJComboBoxUsage(), null);\r |
436 | jContentPane.add(jLabelHelpText, null);\r |
437 | jContentPane.add(getJScrollPaneHelpText(), null);\r |
438 | jContentPane.add(jLabelFeatureFlag, null);\r |
439 | jContentPane.add(getJTextFieldFeatureFlag(), null);\r |
440 | jContentPane.add(jLabelArch, null);\r |
441 | jContentPane.add(jArchCheckBox, null);\r |
442 | jContentPane.add(getJButtonOk(), null);\r |
443 | jContentPane.add(getJButtonCancel(), null);\r |
444 | \r |
445 | }\r |
446 | return jContentPane;\r |
7ab6baa9 |
447 | }\r |
a929458e |
448 | \r |
449 | /**\r |
450 | * This method initializes events groups and usage type\r |
451 | * \r |
452 | */\r |
453 | private void initFrame() {\r |
454 | Tools.generateComboBoxByVector(jComboBoxEventsType, ed.getVEventType());\r |
455 | Tools.generateComboBoxByVector(jComboBoxEventGroup, ed.getVEventGroup());\r |
456 | Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVEventUsage());\r |
06a19cee |
457 | }\r |
458 | \r |
a929458e |
459 | /*\r |
460 | * (non-Javadoc)\r |
461 | * \r |
462 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r |
463 | * \r |
464 | * Override actionPerformed to listen all actions\r |
465 | * \r |
466 | */\r |
467 | public void actionPerformed(ActionEvent arg0) {\r |
468 | if (arg0.getSource() == jButtonOk) {\r |
469 | if (checkAdd()) {\r |
470 | getCurrentEvents();\r |
471 | this.returnType = DataType.RETURN_TYPE_OK;\r |
472 | this.setVisible(false);\r |
473 | }\r |
474 | }\r |
475 | \r |
476 | if (arg0.getSource() == jButtonCancel) {\r |
477 | this.returnType = DataType.RETURN_TYPE_CANCEL;\r |
478 | this.setVisible(false);\r |
479 | }\r |
06a19cee |
480 | }\r |
481 | \r |
a929458e |
482 | /**\r |
483 | * Data validation for all fields\r |
484 | * \r |
485 | * @retval true - All datas are valid\r |
486 | * @retval false - At least one data is invalid\r |
487 | * \r |
488 | */\r |
489 | public boolean checkAdd() {\r |
490 | //\r |
491 | // Check if all fields have correct data types\r |
492 | //\r |
d48c170d |
493 | \r |
494 | //\r |
495 | // Check Name\r |
496 | //\r |
55683eab |
497 | if (this.iComboBoxGuidC_Name.getSelectedItem() == null) {\r |
d48c170d |
498 | Log.wrn("Update Guids", "Please select one Event Name");\r |
499 | return false;\r |
500 | }\r |
a929458e |
501 | \r |
502 | //\r |
503 | // Check Name\r |
504 | //\r |
55683eab |
505 | if (isEmpty(this.iComboBoxGuidC_Name.getSelectedItem().toString())) {\r |
a929458e |
506 | Log.wrn("Update Events", "Event Name couldn't be empty");\r |
507 | return false;\r |
508 | }\r |
509 | \r |
55683eab |
510 | if (!isEmpty(this.iComboBoxGuidC_Name.getSelectedItem().toString())) {\r |
511 | if (!DataValidation.isC_NameType(this.iComboBoxGuidC_Name.getSelectedItem().toString())) {\r |
a929458e |
512 | Log.wrn("Update Events", "Incorrect data type for Event Name");\r |
513 | return false;\r |
514 | }\r |
515 | }\r |
516 | \r |
517 | //\r |
518 | // Check FeatureFlag\r |
519 | //\r |
520 | if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {\r |
521 | if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {\r |
522 | Log.wrn("Update Events", "Incorrect data type for Feature Flag");\r |
523 | return false;\r |
524 | }\r |
525 | }\r |
526 | \r |
527 | return true;\r |
06a19cee |
528 | }\r |
529 | \r |
a929458e |
530 | private EventsIdentification getCurrentEvents() {\r |
55683eab |
531 | String arg0 = this.iComboBoxGuidC_Name.getSelectedItem().toString();\r |
a929458e |
532 | String arg1 = this.jComboBoxEventsType.getSelectedItem().toString();\r |
533 | String arg2 = this.jComboBoxUsage.getSelectedItem().toString();\r |
534 | \r |
535 | String arg3 = this.jTextFieldFeatureFlag.getText();\r |
536 | Vector<String> arg4 = this.jArchCheckBox.getSelectedItemsVector();\r |
537 | String arg5 = this.jTextAreaHelpText.getText();\r |
538 | String arg6 = this.jComboBoxEventGroup.getSelectedItem().toString();\r |
539 | id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5, arg6);\r |
540 | return id;\r |
06a19cee |
541 | }\r |
542 | \r |
a929458e |
543 | public EventsIdentification getId() {\r |
544 | return id;\r |
06a19cee |
545 | }\r |
7ab6baa9 |
546 | \r |
a929458e |
547 | public void setId(EventsIdentification id) {\r |
548 | this.id = id;\r |
549 | }\r |
06a19cee |
550 | }\r |