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