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