]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePpis.java
1. Restructure some folders and files
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / 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.frameworkwizard.module.ui;
16
17 import java.awt.event.ActionEvent;
18 import java.awt.event.ComponentEvent;
19 import java.awt.event.ItemEvent;
20 import java.util.Vector;
21
22 import javax.swing.JButton;
23 import javax.swing.JComboBox;
24 import javax.swing.JLabel;
25 import javax.swing.JPanel;
26 import javax.swing.JScrollPane;
27 import javax.swing.JTextArea;
28 import javax.swing.JTextField;
29
30 import org.tianocore.PPIsDocument;
31 import org.tianocore.PpiNotifyUsage;
32 import org.tianocore.PpiUsage;
33 import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
34 import org.tianocore.PPIsDocument.PPIs;
35 import org.tianocore.PPIsDocument.PPIs.Ppi;
36 import org.tianocore.PPIsDocument.PPIs.PpiNotify;
37 import org.tianocore.frameworkwizard.common.DataType;
38 import org.tianocore.frameworkwizard.common.DataValidation;
39 import org.tianocore.frameworkwizard.common.EnumerationData;
40 import org.tianocore.frameworkwizard.common.Log;
41 import org.tianocore.frameworkwizard.common.Tools;
42 import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
43 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
44 import org.tianocore.frameworkwizard.common.ui.StarLabel;
45 import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
46 import org.tianocore.frameworkwizard.module.Identifications.Ppis.PpisIdentification;
47 import org.tianocore.frameworkwizard.module.Identifications.Ppis.PpisVector;
48 import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
49
50 /**
51 The class is used to create, update Ppi of MSA/MBD file
52 It extends IInternalFrame
53
54 **/
55 public class ModulePpis extends IInternalFrame {
56
57 ///
58 /// Define class Serial Version UID
59 ///
60 private static final long serialVersionUID = -4284901202357037724L;
61
62 //
63 //Define class members
64 //
65 private JPanel jContentPane = null;
66
67 private JLabel jLabelC_Name = null;
68
69 private JComboBox jComboBoxCName = null;
70
71 private JTextField jTextFieldFeatureFlag = null;
72
73 private JLabel jLabelFeatureFlag = null;
74
75 private JLabel jLabelUsage = null;
76
77 private JComboBox jComboBoxUsage = null;
78
79 private JLabel jLabelPpiType = null;
80
81 private StarLabel jStarLabel1 = null;
82
83 private StarLabel jStarLabel2 = null;
84
85 private JComboBox jComboBoxPpiType = null;
86
87 private JLabel jLabelArch = null;
88
89 private JTextArea jTextAreaList = null;
90
91 private JComboBox jComboBoxList = null;
92
93 private JButton jButtonAdd = null;
94
95 private JButton jButtonRemove = null;
96
97 private JButton jButtonUpdate = null;
98
99 private JScrollPane jScrollPane = null;
100
101 private JScrollPane jScrollPaneList = null;
102
103 private ICheckBoxList iCheckBoxListArch = null;
104
105 private JScrollPane jScrollPaneArch = null;
106
107 private JLabel jLabelHelpText = null;
108
109 private JTextField jTextFieldHelpText = null;
110
111 //
112 // Not used by UI
113 //
114 private int intSelectedItemId = 0;
115
116 private OpeningModuleType omt = null;
117
118 private ModuleSurfaceArea msa = null;
119
120 private PPIsDocument.PPIs ppis = null;
121
122 private PpisIdentification id = null;
123
124 private PpisVector vid = new PpisVector();
125
126 private WorkspaceTools wt = new WorkspaceTools();
127
128 private EnumerationData ed = new EnumerationData();
129
130 /**
131 This method initializes jTextFieldC_Name
132
133 @return javax.swing.JTextField jTextFieldC_Name
134
135 **/
136 private JComboBox getJComboBoxCName() {
137 if (jComboBoxCName == null) {
138 jComboBoxCName = new JComboBox();
139 jComboBoxCName.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
140 jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
141 }
142 return jComboBoxCName;
143 }
144
145 /**
146 This method initializes jTextFieldFeatureFlag
147
148 @return javax.swing.JTextField jTextFieldFeatureFlag
149
150 **/
151 private JTextField getJTextFieldFeatureFlag() {
152 if (jTextFieldFeatureFlag == null) {
153 jTextFieldFeatureFlag = new JTextField();
154 jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
155 jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
156 }
157 return jTextFieldFeatureFlag;
158 }
159
160 /**
161 This method initializes jComboBox
162
163 @return javax.swing.JComboBox jComboBoxUsage
164
165 **/
166 private JComboBox getJComboBox() {
167 if (jComboBoxUsage == null) {
168 jComboBoxUsage = new JComboBox();
169 jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
170 jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
171 }
172 return jComboBoxUsage;
173 }
174
175 /**
176 * This method initializes jComboBoxPpiType
177 *
178 * @return javax.swing.JComboBox
179 */
180 private JComboBox getJComboBoxPpiType() {
181 if (jComboBoxPpiType == null) {
182 jComboBoxPpiType = new JComboBox();
183 jComboBoxPpiType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
184 jComboBoxPpiType.setPreferredSize(new java.awt.Dimension(320, 20));
185 jComboBoxPpiType.addItemListener(this);
186 }
187 return jComboBoxPpiType;
188 }
189
190 /**
191 This method initializes jComboBoxFileList
192
193 @return javax.swing.JComboBox jComboBoxFileList
194
195 **/
196 private JComboBox getJComboBoxList() {
197 if (jComboBoxList == null) {
198 jComboBoxList = new JComboBox();
199 jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
200 jComboBoxList.addItemListener(this);
201 jComboBoxList.addActionListener(this);
202 jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
203 }
204 return jComboBoxList;
205 }
206
207 /**
208 This method initializes jButtonAdd
209
210 @return javax.swing.JButton jButtonAdd
211
212 **/
213 private JButton getJButtonAdd() {
214 if (jButtonAdd == null) {
215 jButtonAdd = new JButton();
216 jButtonAdd.setBounds(new java.awt.Rectangle(230, 220, 80, 20));
217 jButtonAdd.setText("Add");
218 jButtonAdd.addActionListener(this);
219 jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
220 }
221 return jButtonAdd;
222 }
223
224 /**
225 This method initializes jButtonRemove
226
227 @return javax.swing.JButton jButtonRemove
228
229 **/
230 private JButton getJButtonRemove() {
231 if (jButtonRemove == null) {
232 jButtonRemove = new JButton();
233 jButtonRemove.setBounds(new java.awt.Rectangle(400, 220, 80, 20));
234 jButtonRemove.setText("Remove");
235 jButtonRemove.addActionListener(this);
236 jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
237 }
238 return jButtonRemove;
239 }
240
241 /**
242 This method initializes jButtonUpdate
243
244 @return javax.swing.JButton jButtonUpdate
245
246 **/
247 private JButton getJButtonUpdate() {
248 if (jButtonUpdate == null) {
249 jButtonUpdate = new JButton();
250 jButtonUpdate.setBounds(new java.awt.Rectangle(315, 220, 80, 20));
251 jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
252 jButtonUpdate.setText("Update");
253 jButtonUpdate.addActionListener(this);
254 }
255 return jButtonUpdate;
256 }
257
258 /**
259 * This method initializes jScrollPaneFileList
260 *
261 * @return javax.swing.JScrollPane
262 */
263 private JScrollPane getJScrollPaneList() {
264 if (jScrollPaneList == null) {
265 jScrollPaneList = new JScrollPane();
266 jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
267 jScrollPaneList.setViewportView(getJTextAreaList());
268 jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
269 }
270 return jScrollPaneList;
271 }
272
273 /**
274 This method initializes jScrollPane
275
276 @return javax.swing.JScrollPane
277 */
278 private JScrollPane getJScrollPane() {
279 if (jScrollPane == null) {
280 jScrollPane = new JScrollPane();
281 jScrollPane.setViewportView(getJContentPane());
282 }
283 return jScrollPane;
284 }
285
286 /**
287 * This method initializes jTextAreaFileList
288 *
289 * @return javax.swing.JTextArea
290 */
291 private JTextArea getJTextAreaList() {
292 if (jTextAreaList == null) {
293 jTextAreaList = new JTextArea();
294 jTextAreaList.setEditable(false);
295
296 }
297 return jTextAreaList;
298 }
299
300 /**
301 This method initializes iCheckBoxListArch
302
303 @return ICheckBoxList
304 **/
305 private ICheckBoxList getICheckBoxListSupportedArchitectures() {
306 if (iCheckBoxListArch == null) {
307 iCheckBoxListArch = new ICheckBoxList();
308 iCheckBoxListArch.addFocusListener(this);
309 iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
310 }
311 return iCheckBoxListArch;
312 }
313
314 /**
315 This method initializes jScrollPaneArch
316
317 @return javax.swing.JScrollPane
318
319 **/
320 private JScrollPane getJScrollPaneArch() {
321 if (jScrollPaneArch == null) {
322 jScrollPaneArch = new JScrollPane();
323 jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 135, 320, 80));
324 jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
325 jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
326 }
327 return jScrollPaneArch;
328 }
329
330 /**
331 This method initializes jTextFieldHelpText
332
333 @return javax.swing.JTextField
334
335 **/
336 private JTextField getJTextFieldHelpText() {
337 if (jTextFieldHelpText == null) {
338 jTextFieldHelpText = new JTextField();
339 jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
340 jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
341 }
342 return jTextFieldHelpText;
343 }
344
345 public static void main(String[] args) {
346
347 }
348
349 /**
350 This method initializes this
351
352 **/
353 private void init() {
354 this.setSize(500, 515);
355 this.setContentPane(getJScrollPane());
356 this.setTitle("Ppis");
357 initFrame();
358 this.setViewMode(false);
359 }
360
361 /**
362 This method initializes this
363 Fill values to all fields if these values are not empty
364
365 @param inPackageDependencies
366
367 **/
368 private void init(PPIs inPpis) {
369 init();
370 this.ppis = inPpis;
371
372 if (this.ppis != null) {
373 if (this.ppis.getPpiList().size() > 0) {
374 for (int index = 0; index < this.ppis.getPpiList().size(); index++) {
375 String arg0 = ppis.getPpiList().get(index).getPpiCName();
376 String arg1 = ed.getVPpiType().get(0);
377 String arg2 = null;
378 if (ppis.getPpiList().get(index).getUsage() != null) {
379 arg2 = ppis.getPpiList().get(index).getUsage().toString();
380 }
381
382 String arg3 = ppis.getPpiList().get(index).getFeatureFlag();
383 Vector<String> arg4 = Tools.convertListToVector(ppis.getPpiList().get(index)
384 .getSupArchList());
385 String arg5 = ppis.getPpiList().get(index).getHelpText();
386
387 id = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
388 vid.addPpis(id);
389 }
390 }
391 if (this.ppis.getPpiNotifyList().size() > 0) {
392 for (int index = 0; index < this.ppis.getPpiNotifyList().size(); index++) {
393 String arg0 = ppis.getPpiNotifyList().get(index).getPpiNotifyCName();
394 String arg1 = ed.getVPpiType().get(1);
395 String arg2 = null;
396 if (ppis.getPpiNotifyList().get(index).getUsage() != null) {
397 arg2 = ppis.getPpiNotifyList().get(index).getUsage().toString();
398 }
399
400 String arg3 = ppis.getPpiNotifyList().get(index).getFeatureFlag();
401 Vector<String> arg4 = Tools.convertListToVector(ppis.getPpiNotifyList().get(index)
402 .getSupArchList());
403 String arg5 = ppis.getPpiNotifyList().get(index).getHelpText();
404
405 id = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
406 vid.addPpis(id);
407 }
408 }
409 }
410 //
411 // Update the list
412 //
413 Tools.generateComboBoxByVector(jComboBoxList, vid.getPpisName());
414 reloadListArea();
415 }
416
417 /**
418 This is the default constructor
419
420 **/
421 public ModulePpis() {
422 super();
423 init();
424 this.setVisible(true);
425 }
426
427 /**
428 This is the override edit constructor
429
430 @param inPpis The input data of PPIsDocument.PPIs
431
432 **/
433 public ModulePpis(OpeningModuleType inOmt) {
434 super();
435 this.omt = inOmt;
436 this.msa = omt.getXmlMsa();
437 init(msa.getPPIs());
438 this.setVisible(true);
439 }
440
441 /**
442 Disable all components when the mode is view
443
444 @param isView true - The view mode; false - The non-view mode
445
446 **/
447 public void setViewMode(boolean isView) {
448 if (isView) {
449 this.jComboBoxCName.setEnabled(!isView);
450 this.jComboBoxUsage.setEnabled(!isView);
451 this.jTextFieldFeatureFlag.setEnabled(!isView);
452 }
453 }
454
455 /**
456 This method initializes jContentPane
457
458 @return javax.swing.JPanel jContentPane
459
460 **/
461 private JPanel getJContentPane() {
462 if (jContentPane == null) {
463 jLabelArch = new JLabel();
464 jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
465 jLabelArch.setText("Arch");
466 jLabelPpiType = new JLabel();
467 jLabelPpiType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
468 jLabelPpiType.setText("Ppi Type");
469 jLabelUsage = new JLabel();
470 jLabelUsage.setText("Usage");
471 jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
472 jLabelFeatureFlag = new JLabel();
473 jLabelFeatureFlag.setText("Feature Flag");
474 jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
475 jLabelC_Name = new JLabel();
476 jLabelC_Name.setText("C_Name Type");
477 jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
478 jLabelHelpText = new JLabel();
479 jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
480 jLabelHelpText.setText("Help Text");
481
482 jContentPane = new JPanel();
483 jContentPane.setLayout(null);
484 jContentPane.setPreferredSize(new java.awt.Dimension(490, 495));
485
486 jContentPane.add(jLabelC_Name, null);
487 jContentPane.add(getJComboBoxCName(), null);
488 jContentPane.add(getJTextFieldFeatureFlag(), null);
489 jContentPane.add(jLabelFeatureFlag, null);
490 jContentPane.add(jLabelUsage, null);
491 jContentPane.add(getJComboBox(), null);
492 jContentPane.add(getJComboBoxPpiType(), null);
493 jContentPane.add(jLabelArch, null);
494 jContentPane.add(jLabelPpiType, null);
495 jStarLabel1 = new StarLabel();
496 jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
497 jStarLabel2 = new StarLabel();
498 jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
499
500 jContentPane.add(jStarLabel1, null);
501 jContentPane.add(jStarLabel2, null);
502
503 jContentPane.add(getJComboBoxList(), null);
504 jContentPane.add(getJButtonAdd(), null);
505 jContentPane.add(getJButtonRemove(), null);
506 jContentPane.add(getJButtonUpdate(), null);
507 jContentPane.add(getJScrollPaneList(), null);
508 jContentPane.add(getJScrollPaneArch(), null);
509 jContentPane.add(jLabelHelpText, null);
510 jContentPane.add(getJTextFieldHelpText(), null);
511 }
512 return jContentPane;
513 }
514
515 /**
516 This method initializes Usage type
517
518 **/
519 private void initFrame() {
520 EnumerationData ed = new EnumerationData();
521
522 Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllPpiDeclarationsFromWorkspace());
523 Tools.generateComboBoxByVector(jComboBoxPpiType, ed.getVPpiType());
524 Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVPpiUsage());
525
526 this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
527 }
528
529 /* (non-Javadoc)
530 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
531 *
532 * Override actionPerformed to listen all actions
533 *
534 */
535 public void actionPerformed(ActionEvent arg0) {
536 if (arg0.getSource() == jButtonAdd) {
537 if (!checkAdd()) {
538 return;
539 }
540 addToList();
541 }
542 if (arg0.getSource() == jButtonRemove) {
543 removeFromList();
544 }
545 if (arg0.getSource() == jButtonUpdate) {
546 if (!checkAdd()) {
547 return;
548 }
549 updateForList();
550 }
551 }
552
553 /**
554 Data validation for all fields
555
556 @retval true - All datas are valid
557 @retval false - At least one data is invalid
558
559 **/
560 public boolean checkAdd() {
561 //
562 // Check if all fields have correct data types
563 //
564
565 //
566 // Check Name
567 //
568 if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
569 if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
570 Log.err("Incorrect data type for Ppi/PpiNotify Name");
571 return false;
572 }
573 }
574
575 //
576 // Check FeatureFlag
577 //
578 if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
579 if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
580 Log.err("Incorrect data type for Feature Flag");
581 return false;
582 }
583 }
584
585 return true;
586 }
587
588 /**
589 Save all components of PPIs
590 if exists ppis, set the value directly
591 if not exists ppis, new an instance first
592
593 **/
594 public void save() {
595 try {
596 int count = this.vid.size();
597
598 this.ppis = PPIs.Factory.newInstance();
599 if (count > 0) {
600 for (int index = 0; index < count; index++) {
601 if (vid.getPpis(index).getType().equals(ed.getVPpiType().get(0))) {
602 Ppi p = Ppi.Factory.newInstance();
603 if (!isEmpty(vid.getPpis(index).getName())) {
604 p.setPpiCName(vid.getPpis(index).getName());
605 }
606 if (!isEmpty(vid.getPpis(index).getUsage())) {
607 p.setUsage(PpiUsage.Enum.forString(vid.getPpis(index).getUsage()));
608 }
609 if (!isEmpty(vid.getPpis(index).getFeatureFlag())) {
610 p.setFeatureFlag(vid.getPpis(index).getFeatureFlag());
611 }
612 if (vid.getPpis(index).getSupArchList() != null
613 && vid.getPpis(index).getSupArchList().size() > 0) {
614 p.setSupArchList(vid.getPpis(index).getSupArchList());
615 }
616 if (!isEmpty(vid.getPpis(index).getHelp())) {
617 p.setHelpText(vid.getPpis(index).getHelp());
618 }
619 this.ppis.addNewPpi();
620 this.ppis.setPpiArray(ppis.getPpiList().size() - 1, p);
621 }
622 if (vid.getPpis(index).getType().equals(ed.getVPpiType().get(1))) {
623 PpiNotify p = PpiNotify.Factory.newInstance();
624 if (!isEmpty(vid.getPpis(index).getName())) {
625 p.setPpiNotifyCName(vid.getPpis(index).getName());
626 }
627 if (!isEmpty(vid.getPpis(index).getUsage())) {
628 p.setUsage(PpiNotifyUsage.Enum.forString(vid.getPpis(index).getUsage()));
629 }
630 if (!isEmpty(vid.getPpis(index).getFeatureFlag())) {
631 p.setFeatureFlag(vid.getPpis(index).getFeatureFlag());
632 }
633 if (vid.getPpis(index).getSupArchList() != null
634 && vid.getPpis(index).getSupArchList().size() > 0) {
635 p.setSupArchList(vid.getPpis(index).getSupArchList());
636 }
637 if (!isEmpty(vid.getPpis(index).getHelp())) {
638 p.setHelpText(vid.getPpis(index).getHelp());
639 }
640 this.ppis.addNewPpiNotify();
641 this.ppis.setPpiNotifyArray(ppis.getPpiNotifyList().size() - 1, p);
642 }
643 }
644 }
645
646 this.msa.setPPIs(ppis);
647 this.omt.setSaved(false);
648 } catch (Exception e) {
649 e.printStackTrace();
650 Log.err("Update Ppis", e.getMessage());
651 }
652 }
653
654 /* (non-Javadoc)
655 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
656 *
657 * Override componentResized to resize all components when frame's size is changed
658 */
659 public void componentResized(ComponentEvent arg0) {
660 int intCurrentWidth = this.getJContentPane().getWidth();
661 int intCurrentHeight = this.getJContentPane().getHeight();
662 int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
663 int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
664
665 resizeComponentWidth(jComboBoxPpiType, intCurrentWidth, intPreferredWidth);
666 resizeComponentWidth(jComboBoxCName, intCurrentWidth, intPreferredWidth);
667 resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
668 resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
669 resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
670 resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
671
672 resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
673 resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
674 relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
675 relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
676 relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
677 }
678
679 private PpisIdentification getCurrentPpis() {
680 String arg0 = this.jComboBoxCName.getSelectedItem().toString();
681 String arg1 = this.jComboBoxPpiType.getSelectedItem().toString();
682 String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
683
684 String arg3 = this.jTextFieldFeatureFlag.getText();
685 Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
686 String arg5 = this.jTextFieldHelpText.getText();
687
688 id = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
689 return id;
690 }
691
692 /**
693 Add current item to Vector
694
695 **/
696 private void addToList() {
697 intSelectedItemId = vid.size();
698
699 vid.addPpis(getCurrentPpis());
700
701 jComboBoxList.addItem(id.getName());
702 jComboBoxList.setSelectedItem(id.getName());
703
704 //
705 // Reset select item index
706 //
707 intSelectedItemId = vid.size();
708
709 //
710 // Reload all fields of selected item
711 //
712 reloadFromList();
713
714 //
715 // Save to memory
716 //
717 save();
718 }
719
720 /**
721 Remove current item from Vector
722
723 **/
724 private void removeFromList() {
725 //
726 // Check if exist items
727 //
728 if (this.vid.size() < 1) {
729 return;
730 }
731
732 int intTempIndex = intSelectedItemId;
733
734 jComboBoxList.removeItemAt(intSelectedItemId);
735
736 vid.removePpis(intTempIndex);
737
738 //
739 // Reload all fields of selected item
740 //
741 reloadFromList();
742
743 //
744 // Save to memory
745 //
746 save();
747 }
748
749 /**
750 Update current item of Vector
751
752 **/
753 private void updateForList() {
754 //
755 // Check if exist items
756 //
757 if (this.vid.size() < 1) {
758 return;
759 }
760
761 //
762 // Backup selected item index
763 //
764 int intTempIndex = intSelectedItemId;
765
766 vid.updatePpis(getCurrentPpis(), intTempIndex);
767
768 jComboBoxList.removeAllItems();
769 for (int index = 0; index < vid.size(); index++) {
770 jComboBoxList.addItem(vid.getPpis(index).getName());
771 }
772
773 //
774 // Restore selected item index
775 //
776 intSelectedItemId = intTempIndex;
777
778 //
779 // Reset select item index
780 //
781 jComboBoxList.setSelectedIndex(intSelectedItemId);
782
783 //
784 // Reload all fields of selected item
785 //
786 reloadFromList();
787
788 //
789 // Save to memory
790 //
791 save();
792 }
793
794 /**
795 Refresh all fields' values of selected item of Vector
796
797 **/
798 private void reloadFromList() {
799 if (vid.size() > 0) {
800 //
801 // Get selected item index
802 //
803 intSelectedItemId = jComboBoxList.getSelectedIndex();
804
805 this.jComboBoxCName.setSelectedItem(vid.getPpis(intSelectedItemId).getName());
806 this.jComboBoxPpiType.setSelectedItem(vid.getPpis(intSelectedItemId).getType());
807 this.jComboBoxUsage.setSelectedItem(vid.getPpis(intSelectedItemId).getUsage());
808 this.jTextFieldHelpText.setText(vid.getPpis(intSelectedItemId).getHelp());
809
810 jTextFieldFeatureFlag.setText(vid.getPpis(intSelectedItemId).getFeatureFlag());
811 iCheckBoxListArch.setAllItemsUnchecked();
812 iCheckBoxListArch.initCheckedItem(true, vid.getPpis(intSelectedItemId).getSupArchList());
813
814 } else {
815 }
816
817 reloadListArea();
818 }
819
820 /**
821 Update list area pane via the elements of Vector
822
823 **/
824 private void reloadListArea() {
825 String strListItem = "";
826 for (int index = 0; index < vid.size(); index++) {
827 strListItem = strListItem + vid.getPpis(index).getName() + DataType.UNIX_LINE_SEPARATOR;
828 }
829 this.jTextAreaList.setText(strListItem);
830 }
831
832 /* (non-Javadoc)
833 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
834 *
835 * Reflesh the frame when selected item changed
836 *
837 */
838 public void itemStateChanged(ItemEvent arg0) {
839 if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
840 reloadFromList();
841 }
842 if (arg0.getSource() == this.jComboBoxPpiType && arg0.getStateChange() == ItemEvent.SELECTED) {
843 if (this.jComboBoxPpiType.getSelectedItem().toString().equals(ed.getVPpiType().get(0))) {
844 Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVPpiUsage());
845 } else {
846 Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVPpiNotifyUsage());
847 }
848 }
849 }
850 }