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