3 The file is used to create, update MbdLibraries of a MBD file
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
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.
15 package org
.tianocore
.packaging
.module
.ui
;
17 import java
.awt
.event
.ActionEvent
;
18 import java
.awt
.event
.ItemEvent
;
19 import java
.awt
.event
.ItemListener
;
20 import java
.util
.Vector
;
22 import javax
.swing
.JButton
;
23 import javax
.swing
.JCheckBox
;
24 import javax
.swing
.JComboBox
;
25 import javax
.swing
.JLabel
;
26 import javax
.swing
.JPanel
;
27 import javax
.swing
.JTextField
;
29 import org
.tianocore
.LibrariesDocument
;
30 import org
.tianocore
.LibraryUsage
;
31 import org
.tianocore
.SupportedArchitectures
;
32 import org
.tianocore
.common
.DataValidation
;
33 import org
.tianocore
.common
.Log
;
34 import org
.tianocore
.common
.Tools
;
35 import org
.tianocore
.packaging
.common
.ui
.IDefaultMutableTreeNode
;
36 import org
.tianocore
.packaging
.common
.ui
.IInternalFrame
;
37 import org
.tianocore
.packaging
.common
.ui
.StarLabel
;
40 The class is used to create, update MbdLibraries of a MBD file
41 It extends IInternalFrame
43 @since ModuleEditor 1.0
46 public class MbdLibraries
extends IInternalFrame
implements ItemListener
{
49 /// Define class Serial Version UID
51 private static final long serialVersionUID
= 8042998899875417568L;
54 //Define class members
56 private LibrariesDocument
.Libraries libraries
= null;
58 private int location
= -1;
60 private int intSelectedItemId
= 0;
65 private int operation
= -1;
67 private Vector
<String
> vName
= new Vector
<String
>();
69 private Vector
<String
> vGuid
= new Vector
<String
>();
71 private Vector
<String
> vLibraryClass
= new Vector
<String
>();
73 private Vector
<String
> vClassGuid
= new Vector
<String
>();
75 private Vector
<String
> vVersion
= new Vector
<String
>();
77 private Vector
<String
> vUsage
= new Vector
<String
>();
79 private Vector
<String
> vOverrideID
= new Vector
<String
>();
81 private JPanel jContentPane
= null;
83 private JButton jButtonOk
= null;
85 private JButton jButtonCancel
= null;
87 private JLabel jLabelName
= null;
89 private JTextField jTextFieldFileName
= null;
91 private JLabel jLabelGuid
= null;
93 private JTextField jTextFieldGuid
= null;
95 private JButton jButtonGenerateGuid
= null;
97 private JComboBox jComboBoxArch
= null;
99 private JLabel jLabelLibraryClass
= null;
101 private JTextField jTextFieldLibraryClass
= null;
103 private JLabel jLabelUsage
= null;
105 private JLabel jLabelClassGuid
= null;
107 private JTextField jTextFieldClassGuid
= null;
109 private JLabel jLabelOverrideID
= null;
111 private JTextField jTextFieldOverrideID
= null;
113 private JComboBox jComboBoxUsage
= null;
115 private StarLabel jStarLabel1
= null;
117 private JComboBox jComboBoxFileList
= null;
119 private JButton jButtonAdd
= null;
121 private JButton jButtonRemove
= null;
123 private JButton jButtonUpdate
= null;
125 private JCheckBox jCheckBoxArch
= null;
127 private JButton jButtonGenerateGuid2
= null;
129 private JLabel jLabelVersion
= null;
131 private JTextField jTextFieldVersion
= null;
134 This method initializes jButtonOk
136 @return javax.swing.JButton jButtonOk
139 private JButton
getJButton() {
140 if (jButtonOk
== null) {
141 jButtonOk
= new JButton();
142 jButtonOk
.setText("OK");
143 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 240, 90, 20));
144 jButtonOk
.addActionListener(this);
150 *This method initializes jButtonCancel
152 @return javax.swing.JButton jButtonCancel
155 private JButton
getJButtonCancel() {
156 if (jButtonCancel
== null) {
157 jButtonCancel
= new JButton();
158 jButtonCancel
.setText("Cancel");
159 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 240, 90, 20));
160 jButtonCancel
.setPreferredSize(new java
.awt
.Dimension(90, 20));
161 jButtonCancel
.addActionListener(this);
163 return jButtonCancel
;
167 This method initializes jTextFieldFileName
169 @return javax.swing.JTextField jTextFieldFileName
172 private JTextField
getJTextFieldSourceFilesDirectory() {
173 if (jTextFieldFileName
== null) {
174 jTextFieldFileName
= new JTextField();
175 jTextFieldFileName
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
177 return jTextFieldFileName
;
181 This method initializes jTextFieldGuid
183 @return javax.swing.JTextField jTextFieldGuid
186 private JTextField
getJTextFieldGuid() {
187 if (jTextFieldGuid
== null) {
188 jTextFieldGuid
= new JTextField();
189 jTextFieldGuid
.setBounds(new java
.awt
.Rectangle(160, 35, 250, 20));
191 return jTextFieldGuid
;
195 This method initializes jButtonGenerateGuid
197 @return javax.swing.JButton jButtonGenerateGuid
200 private JButton
getJButtonGenerateGuid() {
201 if (jButtonGenerateGuid
== null) {
202 jButtonGenerateGuid
= new JButton();
203 jButtonGenerateGuid
.setBounds(new java
.awt
.Rectangle(415, 35, 65, 20));
204 jButtonGenerateGuid
.setText("GEN");
205 jButtonGenerateGuid
.addActionListener(this);
207 return jButtonGenerateGuid
;
211 This method initializes jComboBoxArch
213 @return javax.swing.JComboBox jComboBoxArch
216 private JComboBox
getJComboBoxArch() {
217 if (jComboBoxArch
== null) {
218 jComboBoxArch
= new JComboBox();
219 jComboBoxArch
.setBounds(new java
.awt
.Rectangle(140, 210, 340, 20));
220 jComboBoxArch
.setEnabled(false);
222 return jComboBoxArch
;
226 This method initializes jTextFieldLibraryClass
228 @return javax.swing.JTextField jTextFieldLibraryClass
231 private JTextField
getJTextFieldLibraryClass() {
232 if (jTextFieldLibraryClass
== null) {
233 jTextFieldLibraryClass
= new JTextField();
234 jTextFieldLibraryClass
.setBounds(new java
.awt
.Rectangle(160, 60, 320, 20));
236 return jTextFieldLibraryClass
;
240 This method initializes jTextFieldClassGuid
242 @return javax.swing.JTextField jTextFieldClassGuid
245 private JTextField
getJTextFieldClassGuid() {
246 if (jTextFieldClassGuid
== null) {
247 jTextFieldClassGuid
= new JTextField();
248 jTextFieldClassGuid
.setBounds(new java
.awt
.Rectangle(160, 85, 250, 20));
250 return jTextFieldClassGuid
;
254 This method initializes jTextFieldOverrideID
256 @return javax.swing.JTextField jTextFieldOverrideID
259 private JTextField
getJTextFieldOverrideID() {
260 if (jTextFieldOverrideID
== null) {
261 jTextFieldOverrideID
= new JTextField();
262 jTextFieldOverrideID
.setBounds(new java
.awt
.Rectangle(160, 160, 50, 20));
264 return jTextFieldOverrideID
;
268 This method initializes jComboBoxUsage
270 @return javax.swing.JComboBox jComboBoxUsage
273 private JComboBox
getJComboBoxUsage() {
274 if (jComboBoxUsage
== null) {
275 jComboBoxUsage
= new JComboBox();
276 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(160, 135, 320, 20));
278 return jComboBoxUsage
;
282 This method initializes jComboBoxFileList
284 @return javax.swing.JComboBox jComboBoxFileList
287 private JComboBox
getJComboBoxFileList() {
288 if (jComboBoxFileList
== null) {
289 jComboBoxFileList
= new JComboBox();
290 jComboBoxFileList
.setBounds(new java
.awt
.Rectangle(15, 185, 210, 20));
291 jComboBoxFileList
.addItemListener(this);
292 jComboBoxFileList
.addActionListener(this);
294 return jComboBoxFileList
;
298 This method initializes jButtonAdd
300 @return javax.swing.JButton jButtonAdd
303 private JButton
getJButtonAdd() {
304 if (jButtonAdd
== null) {
305 jButtonAdd
= new JButton();
306 jButtonAdd
.setBounds(new java
.awt
.Rectangle(230, 185, 80, 20));
307 jButtonAdd
.setText("Add");
308 jButtonAdd
.addActionListener(this);
314 This method initializes jButtonRemove
316 @return javax.swing.JButton jButtonRemove
319 private JButton
getJButtonRemove() {
320 if (jButtonRemove
== null) {
321 jButtonRemove
= new JButton();
322 jButtonRemove
.setBounds(new java
.awt
.Rectangle(400, 185, 80, 20));
323 jButtonRemove
.setText("Remove");
324 jButtonRemove
.addActionListener(this);
326 return jButtonRemove
;
330 This method initializes jButtonUpdate
332 @return javax.swing.JButton jButtonUpdate
335 private JButton
getJButtonUpdate() {
336 if (jButtonUpdate
== null) {
337 jButtonUpdate
= new JButton();
338 jButtonUpdate
.setBounds(new java
.awt
.Rectangle(315, 185, 80, 20));
339 jButtonUpdate
.setText("Update");
340 jButtonUpdate
.addActionListener(this);
342 return jButtonUpdate
;
346 This method initializes jCheckBoxArch
348 @return javax.swing.JCheckBox jCheckBoxArch
351 private JCheckBox
getJCheckBoxArch() {
352 if (jCheckBoxArch
== null) {
353 jCheckBoxArch
= new JCheckBox();
354 jCheckBoxArch
.setBounds(new java
.awt
.Rectangle(10, 210, 119, 20));
355 jCheckBoxArch
.setText("Specific Arch");
356 jCheckBoxArch
.addActionListener(this);
358 return jCheckBoxArch
;
362 This method initializes jButtonGenerateGuid2
364 @return javax.swing.JButton jButtonGenerateGuid2
367 private JButton
getJButtonGenerateGuid2() {
368 if (jButtonGenerateGuid2
== null) {
369 jButtonGenerateGuid2
= new JButton();
370 jButtonGenerateGuid2
.setBounds(new java
.awt
.Rectangle(415, 85, 65, 20));
371 jButtonGenerateGuid2
.setText("GEN");
372 jButtonGenerateGuid2
.addActionListener(this);
374 return jButtonGenerateGuid2
;
378 This method initializes jTextFieldVersion
380 @return javax.swing.JTextField jTextFieldVersion
383 private JTextField
getJTextFieldVersion() {
384 if (jTextFieldVersion
== null) {
385 jTextFieldVersion
= new JTextField();
386 jTextFieldVersion
.setBounds(new java
.awt
.Rectangle(160, 110, 320, 20));
388 return jTextFieldVersion
;
391 public static void main(String
[] args
) {
396 This is the default constructor
399 public MbdLibraries() {
402 this.setVisible(true);
406 This is the override edit constructor
408 @param inLibraries The input LibrariesDocument.Libraries
411 public MbdLibraries(LibrariesDocument
.Libraries inLibraries
) {
414 this.setVisible(true);
418 This is the override edit constructor
420 @param inLibraries The input LibrariesDocument.Libraries
421 @param type The input data of node type
422 @param index The input data of node index
425 public MbdLibraries(LibrariesDocument
.Libraries inLibraries
, int type
, int index
) {
428 this.setVisible(true);
432 This is the override edit constructor
434 @param inLibraries The input LibrariesDocument.Libraries
435 @param type The input data of node type
436 @param index The input data of node index
437 @param inOperation The input data of operation type
440 public MbdLibraries(LibrariesDocument
.Libraries inLibraries
, int type
, int index
, int inOperation
) {
442 init(inLibraries
, type
, index
, inOperation
);
443 this.operation
= inOperation
;
444 this.setVisible(true);
448 This method initializes this
450 @param inLibraries LibrariesDocument.Libraries
453 private void init(LibrariesDocument
.Libraries inLibraries
) {
455 this.setLibraries(inLibraries
);
459 This method initializes this
460 Fill values to all fields if these values are not empty
462 @param inLibraries LibrariesDocument.Libraries
463 @param type The input data of node type
464 @param index The input data of node index
465 @param inOperation The input data of operation type
468 private void init(LibrariesDocument
.Libraries inLibraries
, int type
, int index
, int inOperation
) {
470 this.location
= index
;
471 this.operation
= inOperation
;
473 if (operation
== 2) {
474 this.jCheckBoxArch
.setEnabled(false);
475 this.jComboBoxArch
.setEnabled(false);
477 if (type
== IDefaultMutableTreeNode
.LIBRARIES_LIBRARY
) {
478 if (this.libraries
.getLibraryList().size() > 0) {
479 for (int indexI
= 0; indexI
< this.libraries
.getLibraryList().size(); indexI
++) {
480 if (this.libraries
.getLibraryArray(indexI
).getStringValue() != null) {
481 vName
.addElement(this.libraries
.getLibraryArray(indexI
).getStringValue());
483 vName
.addElement("");
485 if (this.libraries
.getLibraryArray(indexI
).getGuid() != null) {
486 vGuid
.addElement(this.libraries
.getLibraryArray(indexI
).getGuid());
488 vGuid
.addElement("");
490 if (this.libraries
.getLibraryArray(indexI
).getLibraryClass() != null) {
491 vLibraryClass
.addElement(this.libraries
.getLibraryArray(indexI
).getLibraryClass());
493 vLibraryClass
.addElement("");
495 if (this.libraries
.getLibraryArray(indexI
).getClassGuid() != null) {
496 vClassGuid
.addElement(this.libraries
.getLibraryArray(indexI
).getClassGuid());
498 vClassGuid
.addElement("");
500 if (this.libraries
.getLibraryArray(indexI
).getVersion() != null) {
501 vVersion
.addElement(this.libraries
.getLibraryArray(indexI
).getVersion());
503 vVersion
.addElement("");
505 if (this.libraries
.getLibraryArray(indexI
).getUsage() != null) {
506 vUsage
.addElement(this.libraries
.getLibraryArray(indexI
).getUsage().toString());
508 vUsage
.addElement("ALWAYS_CONSUMED");
510 vOverrideID
.addElement(String
.valueOf(this.libraries
.getLibraryArray(indexI
).getOverrideID()));
511 jComboBoxFileList
.addItem(this.libraries
.getLibraryArray(indexI
).getStringValue());
515 if (type
== IDefaultMutableTreeNode
.LIBRARIES_ARCH_ITEM
) {
516 this.jCheckBoxArch
.setSelected(true);
517 this.jComboBoxArch
.setSelectedItem(this.libraries
.getArchArray(index
).getArchType().toString());
518 for (int indexI
= 0; indexI
< this.libraries
.getArchArray(index
).getLibraryList().size(); indexI
++) {
519 if (this.libraries
.getArchArray(index
).getLibraryArray(indexI
).getStringValue() != null) {
520 vName
.addElement(this.libraries
.getArchArray(index
).getLibraryArray(indexI
).getStringValue());
522 vName
.addElement("");
524 if (this.libraries
.getArchArray(index
).getLibraryArray(indexI
).getGuid() != null) {
525 vGuid
.addElement(this.libraries
.getArchArray(index
).getLibraryArray(indexI
).getGuid());
527 vGuid
.addElement("");
529 if (this.libraries
.getArchArray(index
).getLibraryArray(indexI
).getLibraryClass() != null) {
530 vLibraryClass
.addElement(this.libraries
.getArchArray(index
).getLibraryArray(indexI
)
533 vLibraryClass
.addElement("");
535 if (this.libraries
.getArchArray(index
).getLibraryArray(indexI
).getClassGuid() != null) {
537 .addElement(this.libraries
.getArchArray(index
).getLibraryArray(indexI
).getClassGuid());
539 vClassGuid
.addElement("");
541 if (this.libraries
.getArchArray(index
).getLibraryArray(indexI
).getVersion() != null) {
542 vVersion
.addElement(this.libraries
.getArchArray(index
).getLibraryArray(indexI
).getVersion());
544 vVersion
.addElement("");
546 if (this.libraries
.getArchArray(index
).getLibraryArray(indexI
).getUsage() != null) {
547 vUsage
.addElement(this.libraries
.getArchArray(index
).getLibraryArray(indexI
).getUsage()
550 vUsage
.addElement("");
552 vOverrideID
.addElement(String
.valueOf(this.libraries
.getArchArray(index
).getLibraryArray(indexI
).getOverrideID()));
553 jComboBoxFileList
.addItem(this.libraries
.getArchArray(index
).getLibraryArray(indexI
)
561 This method initializes this
564 private void init() {
565 this.setSize(500, 515);
566 this.setName("JFrame");
567 this.setContentPane(getJContentPane());
568 this.setTitle("Source Files");
570 this.setViewMode(false);
574 Disable all components when the mode is view
576 @param isView true - The view mode; false - The non-view mode
579 public void setViewMode(boolean isView
) {
580 this.jButtonOk
.setVisible(false);
581 this.jButtonCancel
.setVisible(false);
583 this.jTextFieldFileName
.setEnabled(!isView
);
584 this.jTextFieldGuid
.setEnabled(!isView
);
585 this.jButtonGenerateGuid
.setEnabled(!isView
);
586 this.jComboBoxArch
.setEnabled(!isView
);
587 this.jTextFieldLibraryClass
.setEnabled(!isView
);
588 this.jTextFieldClassGuid
.setEnabled(!isView
);
589 this.jTextFieldOverrideID
.setEnabled(!isView
);
590 this.jComboBoxUsage
.setEnabled(!isView
);
591 this.jButtonAdd
.setEnabled(!isView
);
592 this.jButtonRemove
.setEnabled(!isView
);
593 this.jButtonUpdate
.setEnabled(!isView
);
594 this.jCheckBoxArch
.setEnabled(!isView
);
595 this.jTextFieldVersion
.setEnabled(!isView
);
597 this.jButtonOk
.setEnabled(!isView
);
598 this.jButtonCancel
.setEnabled(!isView
);
599 this.jButtonGenerateGuid
.setEnabled(!isView
);
600 this.jButtonGenerateGuid2
.setEnabled(!isView
);
605 This method initializes jContentPane
607 @return javax.swing.JPanel jContentPane
610 private JPanel
getJContentPane() {
611 if (jContentPane
== null) {
612 jLabelVersion
= new JLabel();
613 jLabelVersion
.setBounds(new java
.awt
.Rectangle(15, 110, 140, 20));
614 jLabelVersion
.setText("Version");
615 jLabelOverrideID
= new JLabel();
616 jLabelOverrideID
.setBounds(new java
.awt
.Rectangle(15, 160, 140, 20));
617 jLabelOverrideID
.setText("Override ID");
618 jLabelClassGuid
= new JLabel();
619 jLabelClassGuid
.setBounds(new java
.awt
.Rectangle(15, 85, 140, 20));
620 jLabelClassGuid
.setText("Class Guid");
621 jLabelUsage
= new JLabel();
622 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 135, 140, 20));
623 jLabelUsage
.setText("Usage");
624 jLabelLibraryClass
= new JLabel();
625 jLabelLibraryClass
.setBounds(new java
.awt
.Rectangle(15, 60, 140, 20));
626 jLabelLibraryClass
.setText("Library Class");
627 jLabelGuid
= new JLabel();
628 jLabelGuid
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
629 jLabelGuid
.setText("Guid");
630 jLabelName
= new JLabel();
631 jLabelName
.setText("Name");
632 jLabelName
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
633 jContentPane
= new JPanel();
634 jContentPane
.setLayout(null);
635 jContentPane
.add(getJButton(), null);
636 jContentPane
.add(getJButtonCancel(), null);
637 jContentPane
.add(jLabelName
, null);
638 jContentPane
.add(getJTextFieldSourceFilesDirectory(), null);
639 jContentPane
.add(jLabelGuid
, null);
640 jContentPane
.add(getJTextFieldGuid(), null);
641 jContentPane
.add(getJButtonGenerateGuid(), null);
642 jContentPane
.add(getJComboBoxArch(), null);
643 jContentPane
.add(jLabelLibraryClass
, null);
644 jContentPane
.add(getJTextFieldLibraryClass(), null);
645 jContentPane
.add(jLabelUsage
, null);
646 jContentPane
.add(jLabelClassGuid
, null);
647 jContentPane
.add(getJTextFieldClassGuid(), null);
648 jContentPane
.add(getJButtonGenerateGuid2(), null);
649 jContentPane
.add(jLabelVersion
, null);
650 jContentPane
.add(getJTextFieldVersion(), null);
651 jContentPane
.add(jLabelOverrideID
, null);
652 jContentPane
.add(getJTextFieldOverrideID(), null);
653 jContentPane
.add(getJComboBoxUsage(), null);
655 jStarLabel1
= new StarLabel();
656 jStarLabel1
.setLocation(new java
.awt
.Point(0, 10));
658 jContentPane
.add(jStarLabel1
, null);
659 jContentPane
.add(getJComboBoxFileList(), null);
660 jContentPane
.add(getJButtonAdd(), null);
661 jContentPane
.add(getJButtonRemove(), null);
662 jContentPane
.add(getJButtonUpdate(), null);
663 jContentPane
.add(getJCheckBoxArch(), null);
670 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
672 * Override actionPerformed to listen all actions
675 public void actionPerformed(ActionEvent arg0
) {
676 if (arg0
.getSource() == jButtonOk
) {
677 this.setEdited(true);
681 if (arg0
.getSource() == jButtonCancel
) {
684 if (arg0
.getSource() == jButtonGenerateGuid
) {
685 jTextFieldGuid
.setText(Tools
.generateUuidString());
687 if (arg0
.getSource() == jButtonGenerateGuid2
) {
688 jTextFieldClassGuid
.setText(Tools
.generateUuidString());
690 if (arg0
.getSource() == jButtonAdd
) {
696 if (arg0
.getSource() == jButtonRemove
) {
699 if (arg0
.getSource() == jButtonUpdate
) {
705 if (arg0
.getSource() == jCheckBoxArch
) {
706 if (this.jCheckBoxArch
.isSelected()) {
707 this.jComboBoxArch
.setEnabled(true);
709 this.jComboBoxArch
.setEnabled(false);
715 Init the items of Usage and Arch
718 private void initFrame() {
719 jComboBoxUsage
.addItem("ALWAYS_CONSUMED");
720 jComboBoxUsage
.addItem("SOMETIMES_CONSUMED");
721 jComboBoxUsage
.addItem("ALWAYS_PRODUCED");
722 jComboBoxUsage
.addItem("SOMETIMES_PRODUCED");
723 jComboBoxUsage
.addItem("DEFAULT");
724 jComboBoxUsage
.addItem("PRIVATE");
726 jComboBoxArch
.addItem("ALL");
727 jComboBoxArch
.addItem("EBC");
728 jComboBoxArch
.addItem("ARM");
729 jComboBoxArch
.addItem("IA32");
730 jComboBoxArch
.addItem("X64");
731 jComboBoxArch
.addItem("IPF");
732 jComboBoxArch
.addItem("PPC");
736 Add current item to Vector
739 private void addToList() {
740 intSelectedItemId
= vName
.size();
741 vName
.addElement(this.jTextFieldFileName
.getText());
742 vGuid
.addElement(this.jTextFieldGuid
.getText());
743 vLibraryClass
.addElement(this.jTextFieldLibraryClass
.getText());
744 vClassGuid
.addElement(this.jTextFieldClassGuid
.getText());
745 vVersion
.addElement(this.jTextFieldVersion
.getText());
746 vUsage
.addElement(this.jComboBoxUsage
.getSelectedItem().toString());
747 vOverrideID
.addElement(this.jTextFieldOverrideID
.getText());
748 jComboBoxFileList
.addItem(this.jTextFieldFileName
.getText());
749 jComboBoxFileList
.setSelectedItem(this.jTextFieldFileName
.getText());
752 // Reset select item index
754 intSelectedItemId
= vName
.size();
757 // Reload all fields of selected item
763 Remove current item from Vector
766 private void removeFromList() {
767 int intTempIndex
= intSelectedItemId
;
768 if (vName
.size() < 1) {
772 jComboBoxFileList
.removeItemAt(intSelectedItemId
);
774 vName
.removeElementAt(intTempIndex
);
775 vGuid
.removeElementAt(intTempIndex
);
776 vLibraryClass
.removeElementAt(intTempIndex
);
777 vClassGuid
.removeElementAt(intTempIndex
);
778 vVersion
.removeElementAt(intTempIndex
);
779 vUsage
.removeElementAt(intTempIndex
);
780 vOverrideID
.removeElementAt(intTempIndex
);
783 // Reload all fields of selected item
789 Update current item of Vector
792 private void updateForList() {
794 // Backup selected item index
796 int intTempIndex
= intSelectedItemId
;
797 vName
.setElementAt(this.jTextFieldFileName
.getText(), intSelectedItemId
);
798 vGuid
.setElementAt(this.jTextFieldGuid
.getText(), intSelectedItemId
);
799 vLibraryClass
.setElementAt(this.jTextFieldLibraryClass
.getText(), intSelectedItemId
);
800 vClassGuid
.setElementAt(this.jTextFieldClassGuid
.getText(), intSelectedItemId
);
801 vVersion
.setElementAt(this.jTextFieldVersion
.getText(), intSelectedItemId
);
802 vUsage
.setElementAt(this.jComboBoxUsage
.getSelectedItem().toString(), intSelectedItemId
);
803 vOverrideID
.setElementAt(this.jTextFieldOverrideID
.getText(), intSelectedItemId
);
805 jComboBoxFileList
.removeAllItems();
806 for (int index
= 0; index
< vName
.size(); index
++) {
807 jComboBoxFileList
.addItem(vName
.elementAt(index
));
811 // Restore selected item index
813 intSelectedItemId
= intTempIndex
;
816 // Reset select item index
818 jComboBoxFileList
.setSelectedIndex(intSelectedItemId
);
821 // Reload all fields of selected item
827 Refresh all fields' values of selected item of Vector
830 private void reloadFromList() {
831 if (vName
.size() > 0) {
833 // Get selected item index
835 intSelectedItemId
= jComboBoxFileList
.getSelectedIndex();
837 this.jTextFieldFileName
.setText(vName
.elementAt(intSelectedItemId
).toString());
838 this.jComboBoxUsage
.setSelectedItem(vUsage
.elementAt(intSelectedItemId
).toString());
839 this.jTextFieldGuid
.setText(vGuid
.elementAt(intSelectedItemId
).toString());
840 this.jTextFieldLibraryClass
.setText(vLibraryClass
.elementAt(intSelectedItemId
).toString());
841 this.jTextFieldClassGuid
.setText(vClassGuid
.elementAt(intSelectedItemId
).toString());
842 this.jTextFieldVersion
.setText(vVersion
.elementAt(intSelectedItemId
).toString());
843 this.jTextFieldOverrideID
.setText(vOverrideID
.elementAt(intSelectedItemId
).toString());
845 this.jTextFieldFileName
.setText("");
846 this.jComboBoxUsage
.setSelectedIndex(0);
847 this.jTextFieldGuid
.setText("");
848 this.jTextFieldLibraryClass
.setText("");
849 this.jTextFieldClassGuid
.setText("");
850 this.jTextFieldVersion
.setText("");
851 this.jTextFieldOverrideID
.setText("");
856 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
858 * Reflesh the frame when selected item changed
860 public void itemStateChanged(ItemEvent arg0
) {
861 if (arg0
.getStateChange() == ItemEvent
.SELECTED
) {
867 Data validation for all fields before save
869 @retval true - All datas are valid
870 @retval false - At least one data is invalid
873 public boolean check() {
874 if (this.jComboBoxFileList
.getItemCount() < 1) {
875 Log
.err("Must have one Library at least!");
882 Data validation for all fields before add current item to Vector
884 @retval true - All datas are valid
885 @retval false - At least one data is invalid
888 public boolean checkAdd() {
890 // Check if all required fields are not empty
892 if (isEmpty(this.jTextFieldFileName
.getText())) {
893 Log
.err("File Name couldn't be empty");
898 // Check if all fields have correct data types
900 if (!DataValidation
.isBaseName(this.jTextFieldFileName
.getText())) {
901 Log
.err("Incorrect data type for Name");
904 if (!isEmpty(this.jTextFieldGuid
.getText()) && !DataValidation
.isGuid(this.jTextFieldGuid
.getText())) {
905 Log
.err("Incorrect data type for Guid");
908 if (!isEmpty(this.jTextFieldLibraryClass
.getText())
909 && !DataValidation
.isPath(this.jTextFieldLibraryClass
.getText())) {
910 Log
.err("Incorrect data type for Path");
913 if (!isEmpty(this.jTextFieldClassGuid
.getText()) && !DataValidation
.isGuid(this.jTextFieldClassGuid
.getText())) {
914 Log
.err("Incorrect data type for Guid");
917 if (!isEmpty(this.jTextFieldOverrideID
.getText())
918 && !DataValidation
.isOverrideID(this.jTextFieldOverrideID
.getText())) {
919 Log
.err("Incorrect data type for Override ID");
927 Save all components of Mbd Libraries
928 if exists libraries, set the value directly
929 if not exists libraries, new an instance first
934 if (this.libraries
== null) {
935 libraries
= LibrariesDocument
.Libraries
.Factory
.newInstance();
940 if (!this.jCheckBoxArch
.isSelected()) {
941 if (this.operation
== 2) { //Add new filename
943 //First remove all existed filename
945 if (libraries
.getLibraryList().size() > 0) {
946 for (int index
= libraries
.getLibraryList().size() - 1; index
>= 0; index
--) {
947 libraries
.removeLibrary(index
);
951 LibrariesDocument
.Libraries
.Library library
= LibrariesDocument
.Libraries
.Library
.Factory
.newInstance();
952 for (int index
= 0; index
< vName
.size(); index
++) {
953 if (!isEmpty(vName
.elementAt(index
).toString())) {
954 library
.setStringValue(vName
.elementAt(index
).toString());
956 if (!isEmpty(vGuid
.elementAt(index
).toString())) {
957 library
.setGuid(vGuid
.elementAt(index
).toString());
959 if (!isEmpty(vLibraryClass
.elementAt(index
).toString())) {
960 library
.setLibraryClass(vLibraryClass
.elementAt(index
).toString());
962 if (!isEmpty(vClassGuid
.elementAt(index
).toString())) {
963 library
.setClassGuid(vClassGuid
.elementAt(index
).toString());
965 if (!isEmpty(vVersion
.elementAt(index
).toString())) {
966 library
.setVersion(vVersion
.elementAt(index
).toString());
968 if (!isEmpty(vUsage
.elementAt(index
).toString())) {
969 library
.setUsage(LibraryUsage
.Enum
.forString(vUsage
.elementAt(index
).toString()));
971 if (!isEmpty(vOverrideID
.elementAt(index
).toString())) {
972 library
.setOverrideID(Integer
.parseInt(vOverrideID
.elementAt(index
).toString()));
974 libraries
.addNewLibrary();
975 libraries
.setLibraryArray(libraries
.getLibraryList().size() - 1, library
);
981 if (this.jCheckBoxArch
.isSelected()) {
982 LibrariesDocument
.Libraries
.Arch arch
= LibrariesDocument
.Libraries
.Arch
.Factory
.newInstance();
983 if (this.operation
== 2) {
984 //First remove all existed filename
985 for (int index
= libraries
.getArchArray(location
).getLibraryList().size() - 1; index
>= 0; index
--) {
986 libraries
.getArchArray(location
).removeLibrary(index
);
989 for (int index
= 0; index
< vName
.size(); index
++) {
990 LibrariesDocument
.Libraries
.Arch
.Library library
= LibrariesDocument
.Libraries
.Arch
.Library
.Factory
.newInstance();
991 if (!isEmpty(vName
.elementAt(index
).toString())) {
992 library
.setStringValue(vName
.elementAt(index
).toString());
994 if (!isEmpty(vGuid
.elementAt(index
).toString())) {
995 library
.setGuid(vGuid
.elementAt(index
).toString());
997 if (!isEmpty(vLibraryClass
.elementAt(index
).toString())) {
998 library
.setLibraryClass(vLibraryClass
.elementAt(index
).toString());
1000 if (!isEmpty(vClassGuid
.elementAt(index
).toString())) {
1001 library
.setClassGuid(vClassGuid
.elementAt(index
).toString());
1003 if (!isEmpty(vVersion
.elementAt(index
).toString())) {
1004 library
.setVersion(vVersion
.elementAt(index
).toString());
1006 if (!isEmpty(vUsage
.elementAt(index
).toString())) {
1007 library
.setUsage(LibraryUsage
.Enum
.forString(vUsage
.elementAt(index
).toString()));
1009 if (!isEmpty(vOverrideID
.elementAt(index
).toString())) {
1010 library
.setOverrideID(Integer
.parseInt(vOverrideID
.elementAt(index
).toString()));
1012 arch
.addNewLibrary();
1013 arch
.setLibraryArray(arch
.getLibraryList().size() - 1, library
);
1016 .setArchType(SupportedArchitectures
.Enum
.forString(this.jComboBoxArch
.getSelectedItem().toString()));
1017 if (location
> -1) {
1018 libraries
.setArchArray(location
, arch
);
1020 libraries
.addNewArch();
1021 libraries
.setArchArray(libraries
.getArchList().size() - 1, arch
);
1024 } catch (Exception e
) {
1025 Log
.err("Update Source Files", e
.getMessage());
1030 Get LibrariesDocument.Libraries
1032 @return LibrariesDocument.Libraries
1035 public LibrariesDocument
.Libraries
getLibraries() {
1040 Set LibrariesDocument.Libraries
1042 @param libraries The input LibrariesDocument.Libraries
1045 public void setLibraries(LibrariesDocument
.Libraries libraries
) {
1046 this.libraries
= libraries
;