]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleProtocols.java
Adpate to schema merge.
[mirror_edk2.git] / Tools / Source / ModuleEditor / src / org / tianocore / packaging / module / ui / ModuleProtocols.java
CommitLineData
878ddf1f 1/** @file\r
2 \r
3 The file is used to create, update Protocol 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\r
16package org.tianocore.packaging.module.ui;\r
17\r
18import java.awt.Dimension;\r
19import java.awt.event.ActionEvent;\r
20\r
21import javax.swing.JButton;\r
22import javax.swing.JComboBox;\r
23import javax.swing.JLabel;\r
24import javax.swing.JPanel;\r
25import javax.swing.JRadioButton;\r
26import javax.swing.JTextField;\r
27\r
28import org.tianocore.ProtocolNotifyUsage;\r
29import org.tianocore.ProtocolUsage;\r
30import org.tianocore.ProtocolsDocument;\r
31import org.tianocore.common.DataValidation;\r
32import org.tianocore.common.Log;\r
33import org.tianocore.common.Tools;\r
34import org.tianocore.packaging.common.ui.IDefaultMutableTreeNode;\r
35import org.tianocore.packaging.common.ui.IInternalFrame;\r
36import org.tianocore.packaging.common.ui.StarLabel;\r
37\r
38/**\r
39 The class is used to create, update Protocol of MSA/MBD file\r
40 It extends IInternalFrame\r
41 \r
42 @since ModuleEditor 1.0\r
43\r
44 **/\r
45public class ModuleProtocols extends IInternalFrame {\r
46\r
47 ///\r
48 /// Define class Serial Version UID\r
49 ///\r
50 private static final long serialVersionUID = -9084913640747858848L;\r
51\r
52 //\r
53 //Define class members\r
54 //\r
55 private ProtocolsDocument.Protocols protocols = null;\r
56\r
57 private int location = -1;\r
58\r
59 private JPanel jContentPane = null;\r
60\r
61 private JLabel jLabelC_Name = null;\r
62\r
63 private JTextField jTextFieldC_Name = null;\r
64\r
65 private JLabel jLabelGuid = null;\r
66\r
67 private JTextField jTextFieldGuid = null;\r
68\r
69 private JLabel jLabelFeatureFlag = null;\r
70\r
71 private JTextField jTextFieldFeatureFlag = null;\r
72\r
73 private JButton jButtonOk = null;\r
74\r
75 private JButton jButtonCancel = null;\r
76\r
77 private JLabel jLabelUsage = null;\r
78\r
79 private JComboBox jComboBoxUsage = null;\r
80\r
81 private JLabel jLabelEnableFeature = null;\r
82\r
83 private JRadioButton jRadioButtonEnableFeature = null;\r
84\r
85 private JRadioButton jRadioButtonDisableFeature = null;\r
86\r
87 private JRadioButton jRadioButtonProtocol = null;\r
88\r
89 private JRadioButton jRadioButtonProtocolNotify = null;\r
90\r
91 private JButton jButtonGenerateGuid = null;\r
92\r
93 private JLabel jLabelOverrideID = null;\r
94\r
95 private JTextField jTextFieldOverrideID = null;\r
96\r
97 private StarLabel jStarLabel1 = null;\r
98\r
99 private StarLabel jStarLabel2 = null;\r
100\r
101 private JLabel jLabelProtocolType = null;\r
102\r
103 /**\r
104 This method initializes jTextFieldC_Name \r
105 \r
106 @return javax.swing.JTextField jTextFieldC_Name\r
107 \r
108 **/\r
109 private JTextField getJTextFieldProtocolName() {\r
110 if (jTextFieldC_Name == null) {\r
111 jTextFieldC_Name = new JTextField();\r
112 jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));\r
113 }\r
114 return jTextFieldC_Name;\r
115 }\r
116\r
117 /**\r
118 This method initializes jTextFieldGuid \r
119 \r
120 @return javax.swing.JTextField jTextFieldGuid\r
121 \r
122 **/\r
123 private JTextField getJTextFieldGuid() {\r
124 if (jTextFieldGuid == null) {\r
125 jTextFieldGuid = new JTextField();\r
2a8b1c0a 126 jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 60, 250, 20));\r
878ddf1f 127 }\r
128 return jTextFieldGuid;\r
129 }\r
130\r
131 /**\r
132 This method initializes jTextFieldFeatureFlag \r
133 \r
134 @return javax.swing.JTextField jTextFieldFeatureFlag\r
135 \r
136 **/\r
137 private JTextField getJTextFieldFeatureFlag() {\r
138 if (jTextFieldFeatureFlag == null) {\r
139 jTextFieldFeatureFlag = new JTextField();\r
140 jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 135, 320, 20));\r
141 }\r
142 return jTextFieldFeatureFlag;\r
143 }\r
144\r
145 /**\r
146 This method initializes jButtonOk \r
147 \r
148 @return javax.swing.JButton jButtonOk\r
149 \r
150 **/\r
151 private JButton getJButtonOk() {\r
152 if (jButtonOk == null) {\r
153 jButtonOk = new JButton();\r
154 jButtonOk.setText("OK");\r
155 jButtonOk.setBounds(new java.awt.Rectangle(290, 190, 90, 20));\r
156 jButtonOk.addActionListener(this);\r
157 }\r
158 return jButtonOk;\r
159 }\r
160\r
161 /**\r
162 This method initializes jButtonCancel \r
163 \r
164 @return javax.swing.JButton jButtonCancel\r
165 \r
166 **/\r
167 private JButton getJButtonCancel() {\r
168 if (jButtonCancel == null) {\r
169 jButtonCancel = new JButton();\r
170 jButtonCancel.setText("Cancel");\r
171 jButtonCancel.setBounds(new java.awt.Rectangle(390, 190, 90, 20));\r
172 jButtonCancel.setPreferredSize(new Dimension(90, 20));\r
173 jButtonCancel.addActionListener(this);\r
174 }\r
175 return jButtonCancel;\r
176 }\r
177\r
178 /**\r
179 This method initializes jComboBoxUsage \r
180 \r
181 @return javax.swing.JComboBox jComboBoxUsage\r
182 \r
183 **/\r
184 private JComboBox getJComboBoxProtocolUsage() {\r
185 if (jComboBoxUsage == null) {\r
186 jComboBoxUsage = new JComboBox();\r
187 jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 85, 320, 20));\r
188 }\r
189 return jComboBoxUsage;\r
190 }\r
191\r
192 /**\r
193 This method initializes jRadioButtonEnableFeature \r
194 \r
195 @return javax.swing.JRadioButton jRadioButtonEnableFeature\r
196 \r
197 **/\r
198 private JRadioButton getJRadioButtonEnableFeature() {\r
199 if (jRadioButtonEnableFeature == null) {\r
200 jRadioButtonEnableFeature = new JRadioButton();\r
201 jRadioButtonEnableFeature.setText("Enable");\r
202 jRadioButtonEnableFeature.setBounds(new java.awt.Rectangle(160, 110, 90, 20));\r
203 jRadioButtonEnableFeature.addActionListener(this);\r
204 jRadioButtonEnableFeature.setSelected(true);\r
205 }\r
206 return jRadioButtonEnableFeature;\r
207 }\r
208\r
209 /**\r
210 This method initializes jRadioButtonDisableFeature \r
211 \r
212 @return javax.swing.JRadioButton jRadioButtonDisableFeature\r
213 \r
214 **/\r
215 private JRadioButton getJRadioButtonDisableFeature() {\r
216 if (jRadioButtonDisableFeature == null) {\r
217 jRadioButtonDisableFeature = new JRadioButton();\r
218 jRadioButtonDisableFeature.setText("Disable");\r
219 jRadioButtonDisableFeature.setBounds(new java.awt.Rectangle(320, 110, 90, 20));\r
220 jRadioButtonDisableFeature.addActionListener(this);\r
221 }\r
222 return jRadioButtonDisableFeature;\r
223 }\r
224\r
225 /**\r
226 This method initializes jRadioButtonProtocol \r
227 \r
228 @return javax.swing.JRadioButton jRadioButtonProtocol\r
229 \r
230 **/\r
231 private JRadioButton getJRadioButtonProtocol() {\r
232 if (jRadioButtonProtocol == null) {\r
233 jRadioButtonProtocol = new JRadioButton();\r
234 jRadioButtonProtocol.setText("Protocol");\r
235 jRadioButtonProtocol.setBounds(new java.awt.Rectangle(160, 10, 90, 20));\r
236 jRadioButtonProtocol.setSelected(true);\r
237 jRadioButtonProtocol.addActionListener(this);\r
238 }\r
239 return jRadioButtonProtocol;\r
240 }\r
241\r
242 /**\r
243 This method initializes jRadioButtonProtocolNotify \r
244 \r
245 @return javax.swing.JRadioButton jRadioButtonProtocolNotify\r
246 \r
247 **/\r
248 private JRadioButton getJRadioButtonProtocolNotify() {\r
249 if (jRadioButtonProtocolNotify == null) {\r
250 jRadioButtonProtocolNotify = new JRadioButton();\r
251 jRadioButtonProtocolNotify.setText("Protocol Notify");\r
252 jRadioButtonProtocolNotify.setBounds(new java.awt.Rectangle(320, 10, 120, 20));\r
253 jRadioButtonProtocolNotify.addActionListener(this);\r
254 }\r
255 return jRadioButtonProtocolNotify;\r
256 }\r
257\r
258 /**\r
259 This method initializes jButtonGenerateGuid \r
260 \r
261 @return javax.swing.JButton jButtonGenerateGuid\r
262 \r
263 **/\r
264 private JButton getJButtonGenerateGuid() {\r
265 if (jButtonGenerateGuid == null) {\r
266 jButtonGenerateGuid = new JButton();\r
2a8b1c0a 267 jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 60, 65, 20));\r
878ddf1f 268 jButtonGenerateGuid.setText("GEN");\r
269 jButtonGenerateGuid.addActionListener(this);\r
270 }\r
271 return jButtonGenerateGuid;\r
272 }\r
273\r
274 /**\r
275 This method initializes jTextFieldOverrideID \r
276 \r
277 @return javax.swing.JTextField jTextFieldOverrideID\r
278 \r
279 **/\r
280 private JTextField getJTextFieldOverrideID() {\r
281 if (jTextFieldOverrideID == null) {\r
282 jTextFieldOverrideID = new JTextField();\r
2a8b1c0a 283 jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 160, 50, 20));\r
878ddf1f 284 }\r
285 return jTextFieldOverrideID;\r
286 }\r
287\r
288 public static void main(String[] args) {\r
289\r
290 }\r
291\r
292 /**\r
293 This is the default constructor\r
294 \r
295 **/\r
296 public ModuleProtocols() {\r
297 super();\r
298 init();\r
299 this.setVisible(true);\r
300 }\r
301\r
302 /**\r
303 This is the override edit constructor\r
304 \r
305 @param inProtocol The input data of ProtocolsDocument.Protocols\r
306 \r
307 **/\r
308 public ModuleProtocols(ProtocolsDocument.Protocols inProtocol) {\r
309 super();\r
310 init(inProtocol);\r
311 this.setVisible(true);\r
312 }\r
313\r
314 /**\r
315 This is the override edit constructor\r
316 \r
317 @param inProtocol The input data of ProtocolsDocument.Protocols\r
318 @param type The input data of node type\r
319 @param index The input data of node index\r
320 \r
321 **/\r
322 public ModuleProtocols(ProtocolsDocument.Protocols inProtocol, int type, int index) {\r
323 super();\r
324 init(inProtocol, type, index);\r
325 this.setVisible(true);\r
326 }\r
327\r
328 /**\r
329 This method initializes this\r
330 \r
331 @param inProtocol The input data of ProtocolsDocument.Protocols\r
332 \r
333 **/\r
334 private void init(ProtocolsDocument.Protocols inProtocol) {\r
335 init();\r
336 this.setProtocols(inProtocol);\r
337 }\r
338\r
339 /**\r
340 This method initializes this\r
341 Fill values to all fields if these values are not empty\r
342 \r
343 @param inProtocol The input data of ProtocolsDocument.Protocols\r
344 @param type The input data of node type\r
345 @param index The input data of node index\r
346 \r
347 **/\r
348 private void init(ProtocolsDocument.Protocols inProtocol, int type, int index) {\r
349 init(inProtocol);\r
350 this.location = index;\r
351 if (type == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOL_ITEM) {\r
352 this.jRadioButtonProtocol.setSelected(true);\r
353 this.jRadioButtonProtocolNotify.setSelected(false);\r
354 if (this.protocols.getProtocolArray(index).getStringValue() != null) {\r
355 this.jTextFieldC_Name.setText(this.protocols.getProtocolArray(index).getStringValue());\r
356 }\r
357 if (this.protocols.getProtocolArray(index).getGuid() != null) {\r
358 this.jTextFieldGuid.setText(this.protocols.getProtocolArray(index).getGuid());\r
359 }\r
360 if (this.protocols.getProtocolArray(index).getUsage() != null) {\r
361 this.jComboBoxUsage.setSelectedItem(this.protocols.getProtocolArray(index).getUsage().toString());\r
362 }\r
363 this.jRadioButtonEnableFeature.setSelected(this.protocols.getProtocolArray(index).getEnableFeature());\r
364 this.jRadioButtonDisableFeature.setSelected(!this.protocols.getProtocolArray(index).getEnableFeature());\r
365 if (this.protocols.getProtocolArray(index).getFeatureFlag() != null) {\r
366 this.jTextFieldFeatureFlag.setText(this.protocols.getProtocolArray(index).getFeatureFlag());\r
367 }\r
368 this.jTextFieldOverrideID.setText(String.valueOf(this.protocols.getProtocolArray(index).getOverrideID()));\r
369 } else if (type == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOLNOTIFY_ITEM) {\r
370 this.jRadioButtonProtocol.setSelected(false);\r
371 this.jRadioButtonProtocolNotify.setSelected(true);\r
372 this.jTextFieldFeatureFlag.setEditable(false);\r
373 this.jRadioButtonDisableFeature.setEnabled(false);\r
374 this.jRadioButtonEnableFeature.setEnabled(false);\r
375 this.jComboBoxUsage.setEnabled(false);\r
376 if (this.protocols.getProtocolNotifyArray(index).getStringValue() != null) {\r
377 this.jTextFieldC_Name.setText(this.protocols.getProtocolNotifyArray(index).getStringValue());\r
378 }\r
379 if (this.protocols.getProtocolNotifyArray(index).getGuid() != null) {\r
380 this.jTextFieldGuid.setText(this.protocols.getProtocolNotifyArray(index).getGuid());\r
381 }\r
382 if (this.protocols.getProtocolNotifyArray(index).getUsage() != null) {\r
383 this.jComboBoxUsage.setSelectedItem(this.protocols.getProtocolNotifyArray(index).getUsage().toString());\r
384 }\r
385 this.jTextFieldOverrideID.setText(String.valueOf(this.protocols.getProtocolNotifyArray(index)\r
386 .getOverrideID()));\r
387 }\r
388 this.jRadioButtonProtocol.setEnabled(false);\r
389 this.jRadioButtonProtocolNotify.setEnabled(false);\r
390 }\r
391\r
392 /**\r
393 This method initializes this\r
394 \r
395 **/\r
396 private void init() {\r
397 this.setSize(500, 515);\r
398 this.setName("JFrame");\r
399 this.setContentPane(getJContentPane());\r
400 this.setTitle("Protocols");\r
401 initFrame();\r
402 this.setViewMode(false);\r
403 }\r
404\r
405 /**\r
406 Disable all components when the mode is view\r
407 \r
408 @param isView true - The view mode; false - The non-view mode\r
409 \r
410 **/\r
411 public void setViewMode(boolean isView) {\r
412 this.jButtonOk.setVisible(false);\r
413 this.jButtonCancel.setVisible(false);\r
414 if (isView) {\r
415 this.jRadioButtonProtocol.setEnabled(!isView);\r
416 this.jRadioButtonProtocolNotify.setEnabled(!isView);\r
417 this.jTextFieldC_Name.setEnabled(!isView);\r
418 this.jTextFieldGuid.setEnabled(!isView);\r
419 this.jComboBoxUsage.setEnabled(!isView);\r
420 this.jRadioButtonEnableFeature.setEnabled(!isView);\r
421 this.jRadioButtonDisableFeature.setEnabled(!isView);\r
422 this.jTextFieldFeatureFlag.setEnabled(!isView);\r
423 this.jTextFieldOverrideID.setEnabled(!isView);\r
424 this.jButtonGenerateGuid.setEnabled(!isView);\r
425 }\r
426 }\r
427\r
428 /**\r
429 This method initializes jContentPane\r
430 \r
431 @return javax.swing.JPanel jContentPane\r
432 \r
433 **/\r
434 private JPanel getJContentPane() {\r
435 if (jContentPane == null) {\r
436 jLabelProtocolType = new JLabel();\r
437 jLabelProtocolType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));\r
438 jLabelProtocolType.setText("Protocol Type");\r
439 jLabelOverrideID = new JLabel();\r
440 jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 160, 140, 20));\r
441 jLabelOverrideID.setText("Override ID");\r
442 jLabelEnableFeature = new JLabel();\r
443 jLabelEnableFeature.setText("Enable Feature");\r
444 jLabelEnableFeature.setBounds(new java.awt.Rectangle(15, 110, 140, 20));\r
445 jLabelUsage = new JLabel();\r
446 jLabelUsage.setText("Usage");\r
447 jLabelUsage.setBounds(new java.awt.Rectangle(15, 85, 140, 20));\r
448 jLabelFeatureFlag = new JLabel();\r
449 jLabelFeatureFlag.setText("Feature Flag");\r
450 jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 135, 140, 20));\r
451 jLabelGuid = new JLabel();\r
452 jLabelGuid.setText("Guid");\r
453 jLabelGuid.setBounds(new java.awt.Rectangle(15, 60, 140, 20));\r
454 jLabelC_Name = new JLabel();\r
455 jLabelC_Name.setText("C_Name");\r
456 jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));\r
457 jContentPane = new JPanel();\r
458 jContentPane.setLayout(null);\r
459 jContentPane.add(jLabelC_Name, null);\r
460 jContentPane.add(getJTextFieldProtocolName(), null);\r
461 jContentPane.add(jLabelGuid, null);\r
462 jContentPane.add(getJTextFieldGuid(), null);\r
463 jContentPane.add(jLabelFeatureFlag, null);\r
464 jContentPane.add(getJTextFieldFeatureFlag(), null);\r
465 jContentPane.add(getJButtonOk(), null);\r
466 jContentPane.add(getJButtonCancel(), null);\r
467 jContentPane.add(jLabelUsage, null);\r
468 jContentPane.add(getJComboBoxProtocolUsage(), null);\r
469 jContentPane.add(jLabelEnableFeature, null);\r
470 jContentPane.add(getJRadioButtonEnableFeature(), null);\r
471 jContentPane.add(getJRadioButtonDisableFeature(), null);\r
472 jContentPane.add(getJRadioButtonProtocol(), null);\r
473 jContentPane.add(getJRadioButtonProtocolNotify(), null);\r
474 jContentPane.add(getJButtonGenerateGuid(), null);\r
475 jContentPane.add(jLabelOverrideID, null);\r
476 jContentPane.add(getJTextFieldOverrideID(), null);\r
477 jContentPane.add(jLabelProtocolType, null);\r
478\r
479 jStarLabel1 = new StarLabel();\r
480 jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));\r
481 jStarLabel2 = new StarLabel();\r
482 jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));\r
483\r
484 jContentPane.add(jStarLabel1, null);\r
485 jContentPane.add(jStarLabel2, null);\r
486 }\r
487 return jContentPane;\r
488 }\r
489\r
490 /**\r
491 This method initializes Usage type\r
492 \r
493 **/\r
494 private void initFrame() {\r
495 jComboBoxUsage.addItem("ALWAYS_CONSUMED");\r
496 jComboBoxUsage.addItem("SOMETIMES_CONSUMED");\r
497 jComboBoxUsage.addItem("ALWAYS_PRODUCED");\r
498 jComboBoxUsage.addItem("SOMETIMES_PRODUCED");\r
499 jComboBoxUsage.addItem("TO_START");\r
500 jComboBoxUsage.addItem("BY_START");\r
501 jComboBoxUsage.addItem("PRIVATE");\r
502 }\r
503\r
504 /* (non-Javadoc)\r
505 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r
506 *\r
507 * Override actionPerformed to listen all actions\r
508 * \r
509 */\r
510 public void actionPerformed(ActionEvent arg0) {\r
511 if (arg0.getSource() == jButtonOk) {\r
512 this.setEdited(true);\r
513 this.save();\r
514 this.dispose();\r
515 }\r
516 if (arg0.getSource() == jButtonCancel) {\r
517 this.dispose();\r
518 }\r
519\r
520 //\r
521 // Contorl the selected status when click RadionButton\r
522 // Do not use Radio Button Group\r
523 //\r
524 if (arg0.getSource() == jRadioButtonProtocol) {\r
525 if (jRadioButtonProtocol.isSelected()) {\r
526 jRadioButtonProtocolNotify.setSelected(false);\r
527 jRadioButtonEnableFeature.setEnabled(true);\r
528 jRadioButtonDisableFeature.setEnabled(true);\r
529 jTextFieldFeatureFlag.setEnabled(true);\r
530 jComboBoxUsage.setEnabled(true);\r
531 }\r
532 if (!jRadioButtonProtocolNotify.isSelected() && !jRadioButtonProtocol.isSelected()) {\r
533 jRadioButtonProtocol.setSelected(true);\r
534 jRadioButtonEnableFeature.setEnabled(true);\r
535 jRadioButtonDisableFeature.setEnabled(true);\r
536 jTextFieldFeatureFlag.setEnabled(true);\r
537 jComboBoxUsage.setEnabled(true);\r
538 }\r
539 }\r
540\r
541 if (arg0.getSource() == jRadioButtonProtocolNotify) {\r
542 if (jRadioButtonProtocolNotify.isSelected()) {\r
543 jRadioButtonProtocol.setSelected(false);\r
544 jRadioButtonEnableFeature.setEnabled(false);\r
545 jRadioButtonDisableFeature.setEnabled(false);\r
546 jTextFieldFeatureFlag.setEnabled(false);\r
547 jComboBoxUsage.setSelectedIndex(1);\r
548 jComboBoxUsage.setEnabled(false);\r
549 }\r
550 if (!jRadioButtonProtocolNotify.isSelected() && !jRadioButtonProtocol.isSelected()) {\r
551 jRadioButtonProtocolNotify.setSelected(true);\r
552 jRadioButtonEnableFeature.setEnabled(false);\r
553 jRadioButtonDisableFeature.setEnabled(false);\r
554 jTextFieldFeatureFlag.setEnabled(false);\r
555 jComboBoxUsage.setSelectedIndex(1);\r
556 jComboBoxUsage.setEnabled(false);\r
557 }\r
558 }\r
559\r
560 //\r
561 // Contorl the selected status when click RadionButton\r
562 // Do not use Radio Button Group\r
563 //\r
564 if (arg0.getSource() == jRadioButtonEnableFeature) {\r
565 if (jRadioButtonEnableFeature.isSelected()) {\r
566 jRadioButtonDisableFeature.setSelected(false);\r
567 }\r
568 if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {\r
569 jRadioButtonEnableFeature.setSelected(true);\r
570 }\r
571 }\r
572\r
573 if (arg0.getSource() == jRadioButtonDisableFeature) {\r
574 if (jRadioButtonDisableFeature.isSelected()) {\r
575 jRadioButtonEnableFeature.setSelected(false);\r
576 }\r
577 if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {\r
578 jRadioButtonDisableFeature.setSelected(true);\r
579 }\r
580 }\r
581\r
582 if (arg0.getSource() == jButtonGenerateGuid) {\r
583 jTextFieldGuid.setText(Tools.generateUuidString());\r
584 }\r
585 }\r
586\r
587 /**\r
588 Get ProtocolsDocument.Protocols\r
589 \r
590 @return ProtocolsDocument.Protocols\r
591 \r
592 **/\r
593 public ProtocolsDocument.Protocols getProtocols() {\r
594 return protocols;\r
595 }\r
596\r
597 /**\r
598 Set ProtocolsDocument.Protocols\r
599 \r
600 @param protocols The input data of ProtocolsDocument.Protocols\r
601 \r
602 **/\r
603 public void setProtocols(ProtocolsDocument.Protocols protocols) {\r
604 this.protocols = protocols;\r
605 }\r
606\r
607 /**\r
608 Data validation for all fields\r
609 \r
610 @retval true - All datas are valid\r
611 @retval false - At least one data is invalid\r
612 \r
613 **/\r
614 public boolean check() {\r
615 //\r
616 // Check if all required fields are not empty\r
617 //\r
618 if (isEmpty(this.jTextFieldC_Name.getText())) {\r
619 Log.err("C_Name couldn't be empty");\r
620 return false;\r
621 }\r
622\r
623 //\r
624 // Check if all fields have correct data types \r
625 //\r
626 if (!DataValidation.isCName(this.jTextFieldC_Name.getText())) {\r
627 Log.err("Incorrect data type for C_Name");\r
628 return false;\r
629 }\r
630 if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {\r
631 Log.err("Incorrect data type for Guid");\r
632 return false;\r
633 }\r
634 if (!isEmpty(this.jTextFieldFeatureFlag.getText())\r
635 && !DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {\r
636 Log.err("Incorrect data type for Feature Flag");\r
637 return false;\r
638 }\r
639 if (!isEmpty(this.jTextFieldOverrideID.getText())\r
640 && !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {\r
641 Log.err("Incorrect data type for Override ID");\r
642 return false;\r
643 }\r
644\r
645 return true;\r
646 }\r
647\r
648 /**\r
649 Save all components of Protocols\r
650 if exists protocols, set the value directly\r
651 if not exists protocols, new an instance first\r
652 \r
653 **/\r
654 public void save() {\r
655 try {\r
656 if (this.protocols == null) {\r
657 protocols = ProtocolsDocument.Protocols.Factory.newInstance();\r
658 }\r
659 if (this.jRadioButtonProtocol.isSelected()) {\r
660 ProtocolsDocument.Protocols.Protocol protocol = ProtocolsDocument.Protocols.Protocol.Factory\r
661 .newInstance();\r
662 protocol.setStringValue(this.jTextFieldC_Name.getText());\r
663 if (!isEmpty(this.jTextFieldGuid.getText())) {\r
664 protocol.setGuid(this.jTextFieldGuid.getText());\r
665 }\r
666 protocol.setUsage(ProtocolUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));\r
667 protocol.setEnableFeature(this.jRadioButtonEnableFeature.isSelected());\r
668 if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {\r
669 protocol.setFeatureFlag(this.jTextFieldFeatureFlag.getText());\r
670 }\r
671 if (!isEmpty(this.jTextFieldOverrideID.getText())) {\r
672 protocol.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));\r
673 }\r
674 if (location > -1) {\r
675 protocols.setProtocolArray(location, protocol);\r
676 } else {\r
677 protocols.addNewProtocol();\r
678 protocols.setProtocolArray(protocols.getProtocolList().size() - 1, protocol);\r
679 }\r
680 }\r
681 if (this.jRadioButtonProtocolNotify.isSelected()) {\r
682 ProtocolsDocument.Protocols.ProtocolNotify protocolNofity = ProtocolsDocument.Protocols.ProtocolNotify.Factory\r
683 .newInstance();\r
684 protocolNofity.setStringValue(this.jTextFieldC_Name.getText());\r
685 if (!isEmpty(this.jTextFieldGuid.getText())) {\r
686 protocolNofity.setGuid(this.jTextFieldGuid.getText());\r
687 }\r
688 protocolNofity\r
689 .setUsage(ProtocolNotifyUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));\r
690\r
691 if (!isEmpty(this.jTextFieldOverrideID.getText())) {\r
692 protocolNofity.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));\r
693 }\r
694 if (location > -1) {\r
695 protocols.setProtocolNotifyArray(location, protocolNofity);\r
696 } else {\r
697 protocols.addNewProtocolNotify();\r
698 protocols.setProtocolNotifyArray(protocols.getProtocolNotifyList().size() - 1, protocolNofity);\r
699 }\r
700 }\r
701 } catch (Exception e) {\r
702 Log.err("Update Protocols", e.getMessage());\r
703 }\r
704 }\r
705}\r