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