2 Java class SpdLibClassDecls is GUI for create library definition elements of spd file.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 package org
.tianocore
.frameworkwizard
.packaging
.ui
;
15 import java
.awt
.Dimension
;
16 import java
.awt
.event
.ActionEvent
;
17 import java
.awt
.event
.ComponentEvent
;
19 import java
.util
.HashMap
;
20 import java
.util
.Iterator
;
23 import java
.util
.Vector
;
25 import javax
.swing
.AbstractAction
;
26 import javax
.swing
.JFileChooser
;
27 import javax
.swing
.JOptionPane
;
28 import javax
.swing
.JPanel
;
29 import javax
.swing
.JTable
;
30 import javax
.swing
.JTextField
;
31 import javax
.swing
.JComboBox
;
32 import javax
.swing
.JLabel
;
33 import javax
.swing
.JScrollPane
;
34 import javax
.swing
.JButton
;
35 import javax
.swing
.JFrame
;
36 import javax
.swing
.ListSelectionModel
;
37 import javax
.swing
.event
.InternalFrameAdapter
;
38 import javax
.swing
.event
.InternalFrameEvent
;
39 import javax
.swing
.event
.ListSelectionEvent
;
40 import javax
.swing
.event
.ListSelectionListener
;
41 import javax
.swing
.event
.TableModelEvent
;
42 import javax
.swing
.event
.TableModelListener
;
43 import javax
.swing
.table
.DefaultTableModel
;
44 import javax
.swing
.table
.TableModel
;
46 import org
.apache
.xmlbeans
.XmlObject
;
47 import org
.tianocore
.PackageSurfaceAreaDocument
;
48 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
49 import org
.tianocore
.frameworkwizard
.common
.Tools
;
50 import org
.tianocore
.frameworkwizard
.common
.Identifications
.OpeningPackageType
;
51 import org
.tianocore
.frameworkwizard
.common
.ui
.IInternalFrame
;
52 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
53 import org
.tianocore
.frameworkwizard
.common
.ui
.iCheckBoxList
.ICheckBoxList
;
54 import org
.tianocore
.frameworkwizard
.platform
.ui
.ListEditor
;
55 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.GlobalData
;
56 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
57 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.ModuleIdentification
;
58 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.PackageIdentification
;
62 GUI for create library definition elements of spd file.
64 @since PackageEditor 1.0
66 public class SpdLibClassDecls
extends IInternalFrame
implements TableModelListener
{
70 private static final long serialVersionUID
= 1L;
74 private JTable jTable
= null;
76 private DefaultTableModel model
= null;
78 private JPanel jContentPane
= null;
80 private JTextField jTextFieldAdd
= null;
82 private JComboBox jComboBoxSelect
= null;
84 private JScrollPane jScrollPane
= null;
86 private JButton jButtonAdd
= null;
88 private JButton jButtonRemove
= null;
90 private JButton jButtonClearAll
= null;
92 private JLabel jLabel
= null;
94 private JTextField jTextField
= null;
96 private JButton jButtonBrowse
= null;
98 private StarLabel jStarLabel1
= null;
100 private StarLabel jStarLabel2
= null;
102 private SpdFileContents sfc
= null;
104 private OpeningPackageType docConsole
= null;
106 private JLabel jLabel1
= null;
108 private JScrollPane topScrollPane
= null; // @jve:decl-index=0:visual-constraint="10,53"
110 private int selectedRow
= -1;
112 private StarLabel starLabel
= null;
114 private JLabel jLabel2
= null;
116 private JTextField jTextFieldHelp
= null;
118 private JLabel jLabel3
= null;
120 private JTextField jTextField1
= null;
122 private JLabel jLabel4
= null;
124 private JTextField jTextField2
= null;
126 private JLabel jLabel5
= null;
128 private JLabel jLabel6
= null;
130 private JScrollPane jScrollPaneArch
= null;
132 private JScrollPane jScrollPane1
= null;
134 private ICheckBoxList iCheckBoxListArch
= null;
136 private ICheckBoxList iCheckBoxList
= null;
138 private JComboBox jComboBox
= null;
140 HashMap
<String
, String
> libNameGuidMap
= new HashMap
<String
, String
>();
144 This method initializes this
147 private void initialize() {
149 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
154 This method initializes jTextFieldAdd
156 @return javax.swing.JTextField
158 private JTextField
getJTextFieldAdd() {
159 if (jTextFieldAdd
== null) {
160 jTextFieldAdd
= new JTextField();
161 jTextFieldAdd
.setBounds(new java
.awt
.Rectangle(122,6,390,20));
162 jTextFieldAdd
.setPreferredSize(new java
.awt
.Dimension(260,20));
163 jTextFieldAdd
.setEnabled(true);
165 return jTextFieldAdd
;
169 This method initializes jComboBoxSelect
171 @return javax.swing.JComboBox
173 private JComboBox
getJComboBoxSelect() {
174 if (jComboBoxSelect
== null) {
175 jComboBoxSelect
= new JComboBox();
176 jComboBoxSelect
.setBounds(new java
.awt
.Rectangle(220, 10, 260, 20));
177 jComboBoxSelect
.setPreferredSize(new java
.awt
.Dimension(260,22));
178 jComboBoxSelect
.setEnabled(true);
179 jComboBoxSelect
.setVisible(false);
181 return jComboBoxSelect
;
185 This method initializes jScrollPane
187 @return javax.swing.JScrollPane
189 private JScrollPane
getJScrollPane() {
190 if (jScrollPane
== null) {
191 jScrollPane
= new JScrollPane();
192 jScrollPane
.setBounds(new java
.awt
.Rectangle(12,351,608,253));
193 jScrollPane
.setPreferredSize(new java
.awt
.Dimension(330,150));
194 jScrollPane
.setViewportView(getJTable());
200 This method initializes jTable
202 @return javax.swing.JTable
204 private JTable
getJTable() {
205 if (jTable
== null) {
206 model
= new DefaultTableModel();
207 jTable
= new JTable(model
);
208 jTable
.setRowHeight(20);
209 jTable
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
210 model
.addColumn("LibraryClass");
211 model
.addColumn("IncludeHeader");
212 model
.addColumn("HelpText");
213 model
.addColumn("RecommendedInstance");
214 model
.addColumn("InstanceVersion");
215 model
.addColumn("SupportedArch");
216 model
.addColumn("SupportedModule");
218 Vector
<String
> vArch
= new Vector
<String
>();
225 jTable
.getColumnModel().getColumn(5).setCellEditor(new ListEditor(vArch
));
227 Vector
<String
> vModule
= new Vector
<String
>();
230 vModule
.add("PEI_CORE");
232 vModule
.add("DXE_CORE");
233 vModule
.add("DXE_DRIVER");
234 vModule
.add("DXE_RUNTIME_DRIVER");
235 vModule
.add("DXE_SAL_DRIVER");
236 vModule
.add("DXE_SMM_DRIVER");
237 vModule
.add("UEFI_DRIVER");
238 vModule
.add("UEFI_APPLICATION");
239 vModule
.add("USER_DEFINED");
240 jTable
.getColumnModel().getColumn(6).setCellEditor(new ListEditor(vModule
));
242 jTable
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
243 jTable
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
244 public void valueChanged(ListSelectionEvent e
) {
245 if (e
.getValueIsAdjusting()){
248 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
249 if (lsm
.isSelectionEmpty()) {
253 selectedRow
= lsm
.getMinSelectionIndex();
258 jTable
.getModel().addTableModelListener(this);
265 public void tableChanged(TableModelEvent arg0
) {
266 // TODO Auto-generated method stub
267 int row
= arg0
.getFirstRow();
268 TableModel m
= (TableModel
)arg0
.getSource();
269 if (arg0
.getType() == TableModelEvent
.UPDATE
){
270 String lib
= m
.getValueAt(row
, 0) + "";
271 String hdr
= m
.getValueAt(row
, 1) + "";
272 String hlp
= m
.getValueAt(row
, 2) + "";
273 String name
= m
.getValueAt(row
, 3) + "";
274 String ver
= m
.getValueAt(row
, 4) + "";
276 if (m
.getValueAt(row
, 5) != null) {
277 arch
= m
.getValueAt(row
, 5).toString();
279 String module
= null;
280 if (m
.getValueAt(row
, 6) != null) {
281 module
= m
.getValueAt(row
, 6).toString();
283 String
[] rowData
= {lib
, hdr
, hlp
};
284 if (!dataValidation(rowData
)) {
287 docConsole
.setSaved(false);
289 getLibInstances(lib
);
290 String guid
= nameToGuid(name
);
292 sfc
.updateSpdLibClass(row
, lib
, hdr
, hlp
, guid
, ver
, arch
, module
);
297 This method initializes jButtonAdd
299 @return javax.swing.JButton
301 private JButton
getJButtonAdd() {
302 if (jButtonAdd
== null) {
303 jButtonAdd
= new JButton();
304 jButtonAdd
.setText("Add");
305 jButtonAdd
.setSize(new java
.awt
.Dimension(80,20));
306 jButtonAdd
.setLocation(new java
.awt
.Point(359,326));
307 jButtonAdd
.addActionListener(this);
313 This method initializes jButtonRemove
315 @return javax.swing.JButton
317 private JButton
getJButtonRemove() {
318 if (jButtonRemove
== null) {
319 jButtonRemove
= new JButton();
320 jButtonRemove
.setText("Remove");
321 jButtonRemove
.setSize(new java
.awt
.Dimension(80,20));
322 jButtonRemove
.setLocation(new java
.awt
.Point(443,326));
323 jButtonRemove
.addActionListener(this);
325 return jButtonRemove
;
329 This method initializes jButtonRemoveAll
331 @return javax.swing.JButton
333 private JButton
getJButtonClearAll() {
334 if (jButtonClearAll
== null) {
335 jButtonClearAll
= new JButton();
336 jButtonClearAll
.setText("Clear All");
337 jButtonClearAll
.setSize(new java
.awt
.Dimension(86,20));
338 jButtonClearAll
.setLocation(new java
.awt
.Point(530,326));
339 jButtonClearAll
.addActionListener(this);
341 return jButtonClearAll
;
345 This is the default constructor
347 public SpdLibClassDecls() {
354 public SpdLibClassDecls(PackageSurfaceAreaDocument
.PackageSurfaceArea inPsa
){
356 sfc
= new SpdFileContents(inPsa
);
360 public SpdLibClassDecls(OpeningPackageType opt
) {
361 this(opt
.getXmlSpd());
365 This method initializes this
369 private void init() {
371 this.setContentPane(getJContentPane());
372 this.setTitle("Library Class Declarations");
373 this.setBounds(new java
.awt
.Rectangle(0, 0, 500, 370));
374 this.setVisible(true);
375 this.addInternalFrameListener(new InternalFrameAdapter(){
376 public void internalFrameDeactivated(InternalFrameEvent e
){
377 if (jTable
.isEditing()) {
378 jTable
.getCellEditor().stopCellEditing();
385 private void init(SpdFileContents sfc
) {
386 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
390 // initialize table using SpdFileContents object
392 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][7];
393 sfc
.getSpdLibClassDeclarations(saa
);
395 while (i
< saa
.length
) {
396 if (saa
[i
][3] != null && saa
[i
][3].length() > 0) {
397 getLibInstances(saa
[i
][0]);
398 saa
[i
][3] = guidToName(saa
[i
][3]);
401 model
.addRow(saa
[i
]);
405 private JScrollPane
getJContentPane(){
406 if (topScrollPane
== null){
407 topScrollPane
= new JScrollPane();
408 topScrollPane
.setSize(new java
.awt
.Dimension(634,500));
409 topScrollPane
.setViewportView(getJContentPane1());
411 return topScrollPane
;
414 This method initializes jContentPane
416 @return javax.swing.JPanel
418 private JPanel
getJContentPane1() {
419 if (jContentPane
== null) {
420 jLabel6
= new JLabel();
421 jLabel6
.setBounds(new java
.awt
.Rectangle(16,252,108,16));
422 jLabel6
.setText("Supported Module");
423 jLabel6
.setEnabled(true);
424 jLabel5
= new JLabel();
425 jLabel5
.setBounds(new java
.awt
.Rectangle(15,169,93,16));
426 jLabel5
.setText("Supported Arch");
427 jLabel5
.setEnabled(true);
428 jLabel4
= new JLabel();
429 jLabel4
.setBounds(new java
.awt
.Rectangle(16,138,196,16));
430 jLabel4
.setEnabled(true);
431 jLabel4
.setText("Recommended Instance Version");
432 jLabel3
= new JLabel();
433 jLabel3
.setBounds(new java
.awt
.Rectangle(17,112,195,16));
434 jLabel3
.setEnabled(true);
435 jLabel3
.setText("Recommended Instance Name");
436 jLabel2
= new JLabel();
437 jLabel2
.setBounds(new java
.awt
.Rectangle(16,33,82,20));
438 jLabel2
.setText("Help Text");
439 starLabel
= new StarLabel();
440 starLabel
.setBounds(new java
.awt
.Rectangle(1,33,10,20));
441 jLabel1
= new JLabel();
442 jLabel1
.setBounds(new java
.awt
.Rectangle(16,6,82,20));
443 jLabel1
.setText("Library Class");
444 jStarLabel1
= new StarLabel();
445 jStarLabel1
.setLocation(new java
.awt
.Point(1,7));
446 jStarLabel2
= new StarLabel();
447 jStarLabel2
.setLocation(new java
.awt
.Point(-1,74));
448 jLabel
= new JLabel();
449 jLabel
.setBounds(new java
.awt
.Rectangle(14,74,199,22));
450 jLabel
.setText("Include Header for Specified Class");
452 jContentPane
= new JPanel();
453 jContentPane
.setPreferredSize(new Dimension(480, 400));
454 jContentPane
.setLayout(null);
455 jContentPane
.add(jLabel
, null);
456 jContentPane
.add(jStarLabel1
, null);
457 jContentPane
.add(jStarLabel2
, null);
458 jContentPane
.add(getJTextFieldAdd(), null);
459 jContentPane
.add(getJComboBoxSelect(), null);
460 jContentPane
.add(getJScrollPane(), null);
461 jContentPane
.add(getJButtonAdd(), null);
462 jContentPane
.add(getJButtonRemove(), null);
463 jContentPane
.add(getJButtonClearAll(), null);
465 jContentPane
.add(getJTextField(), null);
466 jContentPane
.add(getJButtonBrowse(), null);
467 jContentPane
.add(jLabel1
, null);
468 jContentPane
.add(starLabel
, null);
469 jContentPane
.add(jLabel2
, null);
470 jContentPane
.add(getJTextFieldHelp(), null);
471 jContentPane
.add(jLabel3
, null);
472 jContentPane
.add(getJTextField1(), null);
473 jContentPane
.add(jLabel4
, null);
474 jContentPane
.add(getJTextField2(), null);
475 jContentPane
.add(jLabel5
, null);
476 jContentPane
.add(jLabel6
, null);
478 jContentPane
.add(getJScrollPaneArch(), null);
479 jContentPane
.add(getJScrollPane1(), null);
480 jContentPane
.add(getJComboBox(), null);
488 fill ComboBoxes with pre-defined contents
490 private void initFrame() {
491 jComboBoxSelect
.addItem("BaseCpuICacheFlush");
492 jComboBoxSelect
.addItem("BaseDebugLibNull");
493 jComboBoxSelect
.addItem("BaseDebugLibReportStatusCode");
494 jComboBoxSelect
.addItem("BaseIoLibIntrinsic");
495 jComboBoxSelect
.addItem("BaseLib");
496 jComboBoxSelect
.addItem("BaseMemoryLib");
497 jComboBoxSelect
.addItem("BaseMemoryLibMmx");
498 jComboBoxSelect
.addItem("BaseMemoryLibSse2");
499 jComboBoxSelect
.addItem("BasePeCoffGetEntryPointLib");
500 jComboBoxSelect
.addItem("BasePeCoffLib");
501 jComboBoxSelect
.addItem("BasePrintLib");
502 jComboBoxSelect
.addItem("BaseReportStatusCodeLibNull");
503 jComboBoxSelect
.addItem("CommonPciCf8Lib");
504 jComboBoxSelect
.addItem("CommonPciExpressLib");
505 jComboBoxSelect
.addItem("CommonPciLibCf8");
506 jComboBoxSelect
.addItem("CommonPciLibPciExpress");
507 jComboBoxSelect
.addItem("DxeCoreEntryPoint");
508 jComboBoxSelect
.addItem("DxeHobLib");
509 jComboBoxSelect
.addItem("DxeIoLibCpuIo");
510 jComboBoxSelect
.addItem("DxeLib");
511 jComboBoxSelect
.addItem("DxePcdLib");
512 jComboBoxSelect
.addItem("DxeReportStatusCodeLib");
513 jComboBoxSelect
.addItem("DxeServicesTableLib");
514 jComboBoxSelect
.addItem("PeiCoreEntryPoint");
515 jComboBoxSelect
.addItem("PeiMemoryLib");
516 jComboBoxSelect
.addItem("PeimEntryPoint");
517 jComboBoxSelect
.addItem("PeiReportStatusCodeLib");
518 jComboBoxSelect
.addItem("PeiServicesTablePointerLib");
519 jComboBoxSelect
.addItem("PeiServicesTablePointerLibMm7");
520 jComboBoxSelect
.addItem("UefiDebugLibConOut");
521 jComboBoxSelect
.addItem("UefiDebugLibStdErr");
522 jComboBoxSelect
.addItem("UefiDriverEntryPointMultiple");
523 jComboBoxSelect
.addItem("UefiDriverEntryPointSingle");
524 jComboBoxSelect
.addItem("UefiDriverEntryPointSingleUnload");
525 jComboBoxSelect
.addItem("UefiDriverModelLib");
526 jComboBoxSelect
.addItem("UefiDriverModelLibNoConfigNoDiag");
527 jComboBoxSelect
.addItem("UefiLib");
528 jComboBoxSelect
.addItem("UefiMemoryLib");
533 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
535 public void actionPerformed(ActionEvent arg0
) {
537 if (arg0
.getSource() == jButtonAdd
) {
539 //ToDo: check before add
540 String
[] row
= {null, null, null, jComboBox
.getSelectedItem()+"", jTextField2
.getText(), null, null};
541 row
[0] = jTextFieldAdd
.getText();
542 row
[1] = jTextField
.getText().replace('\\', '/');
543 row
[2] = jTextFieldHelp
.getText();
544 row
[5] = vectorToString(iCheckBoxList
.getAllCheckedItemsString());
545 if (row
[5].length() == 0){
548 row
[6] = vectorToString(iCheckBoxListArch
.getAllCheckedItemsString());
549 if (row
[6].length() == 0){
552 if (!dataValidation(row
)) {
556 jTable
.changeSelection(model
.getRowCount()-1, 0, false, false);
557 docConsole
.setSaved(false);
559 //convert to GUID before storing recommended lib instance.
561 getLibInstances(row
[0]);
562 String recommendGuid
= nameToGuid(row
[3]);
563 sfc
.genSpdLibClassDeclarations(row
[0], recommendGuid
, row
[1], row
[2], row
[5], null, null, row
[4], null, row
[6]);
567 // remove selected line
569 if (arg0
.getSource() == jButtonRemove
) {
570 if (jTable
.isEditing()){
571 jTable
.getCellEditor().stopCellEditing();
573 int rowSelected
= selectedRow
;
574 if (rowSelected
>= 0) {
575 model
.removeRow(rowSelected
);
576 sfc
.removeSpdLibClass(rowSelected
);
580 if (arg0
.getSource() == jButtonClearAll
) {
581 if (model
.getRowCount() == 0) {
585 model
.setRowCount(0);
586 sfc
.removeSpdLibClass();
590 private boolean dataValidation(String
[] row
) {
591 if (!DataValidation
.isKeywordType(row
[0])) {
592 JOptionPane
.showMessageDialog(frame
, "Library Class is NOT KeyWord Type.");
595 if (!DataValidation
.isPathAndFilename(row
[1])) {
596 JOptionPane
.showMessageDialog(frame
, "Include Header is NOT PathAndFilename Type.");
598 if (row
[2].length() == 0) {
599 JOptionPane
.showMessageDialog(frame
, "HelpText could NOT be empty.");
604 Add contents in list to sfc
606 protected void save() {
611 This method initializes jTextField
613 @return javax.swing.JTextField
615 private JTextField
getJTextField() {
616 if (jTextField
== null) {
617 jTextField
= new JTextField();
618 jTextField
.setBounds(new java
.awt
.Rectangle(218,75,290,21));
619 jTextField
.setPreferredSize(new java
.awt
.Dimension(260,20));
625 This method initializes jButtonBrowse
627 @return javax.swing.JButton
629 private JButton
getJButtonBrowse() {
630 if (jButtonBrowse
== null) {
631 jButtonBrowse
= new JButton();
632 jButtonBrowse
.setBounds(new java
.awt
.Rectangle(528,75,90,20));
633 jButtonBrowse
.setText("Browse");
634 jButtonBrowse
.setPreferredSize(new java
.awt
.Dimension(80,20));
635 jButtonBrowse
.addActionListener(new AbstractAction() {
640 private static final long serialVersionUID
= 1L;
642 public void actionPerformed(ActionEvent arg0
) {
644 // Select files from current pkg
646 String dirPrefix
= Tools
.dirForNewSpd
.substring(0, Tools
.dirForNewSpd
.lastIndexOf(File
.separator
));
647 JFileChooser chooser
= new JFileChooser(dirPrefix
);
649 String headerDest
= null;
651 chooser
.setMultiSelectionEnabled(false);
652 chooser
.setFileSelectionMode(JFileChooser
.FILES_AND_DIRECTORIES
);
653 int retval
= chooser
.showOpenDialog(frame
);
654 if (retval
== JFileChooser
.APPROVE_OPTION
) {
656 theFile
= chooser
.getSelectedFile();
657 String file
= theFile
.getPath();
658 if (!file
.startsWith(dirPrefix
)) {
659 JOptionPane
.showMessageDialog(frame
, "You can only select files in current package!");
669 headerDest
= theFile
.getPath();
670 int fileIndex
= headerDest
.indexOf(System
.getProperty("file.separator"), dirPrefix
.length());
671 jTextField
.setText(headerDest
.substring(fileIndex
+ 1).replace('\\', '/'));
677 return jButtonBrowse
;
680 public void componentResized(ComponentEvent arg0
) {
681 int intPreferredWidth
= 500;
683 resizeComponentWidth(this.jTextFieldAdd
, this.getWidth(), intPreferredWidth
);
684 resizeComponentWidth(this.jTextFieldHelp
, this.getWidth(), intPreferredWidth
);
685 resizeComponentWidth(this.jScrollPane
, this.getWidth(), intPreferredWidth
);
689 * This method initializes jTextFieldHelp
691 * @return javax.swing.JTextField
693 private JTextField
getJTextFieldHelp() {
694 if (jTextFieldHelp
== null) {
695 jTextFieldHelp
= new JTextField();
696 jTextFieldHelp
.setBounds(new java
.awt
.Rectangle(122,33,390,20));
697 jTextFieldHelp
.setPreferredSize(new java
.awt
.Dimension(260,20));
699 return jTextFieldHelp
;
703 * This method initializes jTextField1
705 * @return javax.swing.JTextField
707 private JTextField
getJTextField1() {
708 if (jTextField1
== null) {
709 jTextField1
= new JTextField();
710 jTextField1
.setBounds(new java
.awt
.Rectangle(218,110,291,20));
711 jTextField1
.setEnabled(true);
712 jTextField1
.setVisible(false);
718 * This method initializes jTextField2
720 * @return javax.swing.JTextField
722 private JTextField
getJTextField2() {
723 if (jTextField2
== null) {
724 jTextField2
= new JTextField();
725 jTextField2
.setBounds(new java
.awt
.Rectangle(218,135,292,20));
726 jTextField2
.setEnabled(true);
731 private JScrollPane
getJScrollPaneArch() {
732 if (jScrollPaneArch
== null) {
733 jScrollPaneArch
= new JScrollPane();
734 jScrollPaneArch
.setBounds(new java
.awt
.Rectangle(218,245,293,73));
735 jScrollPaneArch
.setPreferredSize(new java
.awt
.Dimension(320, 80));
736 jScrollPaneArch
.setViewportView(getICheckBoxListSupportedArchitectures());
738 return jScrollPaneArch
;
741 private ICheckBoxList
getICheckBoxListSupportedArchitectures() {
742 if (iCheckBoxListArch
== null) {
743 iCheckBoxListArch
= new ICheckBoxList();
744 iCheckBoxListArch
.setBounds(new java
.awt
.Rectangle(218,246,292,73));
745 Vector
<String
> v
= new Vector
<String
>();
752 v
.add("DXE_RUNTIME_DRIVER");
753 v
.add("DXE_SAL_DRIVER");
754 v
.add("DXE_SMM_DRIVER");
755 v
.add("UEFI_DRIVER");
756 v
.add("UEFI_APPLICATION");
757 v
.add("USER_DEFINED");
758 iCheckBoxListArch
.setAllItems(v
);
760 return iCheckBoxListArch
;
763 private String
vectorToString(Vector
<String
> v
) {
765 for (int i
= 0; i
< v
.size(); ++i
) {
772 private JScrollPane
getJScrollPane1() {
773 if (jScrollPane1
== null) {
774 jScrollPane1
= new JScrollPane();
775 jScrollPane1
.setBounds(new java
.awt
.Rectangle(218,170,293,73));
776 jScrollPane1
.setPreferredSize(new java
.awt
.Dimension(320, 80));
777 jScrollPane1
.setViewportView(getICheckBoxList());
782 * This method initializes iCheckBoxList
784 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
786 private ICheckBoxList
getICheckBoxList() {
787 if (iCheckBoxList
== null) {
788 iCheckBoxList
= new ICheckBoxList();
789 iCheckBoxList
.setBounds(new java
.awt
.Rectangle(218,171,292,66));
790 Vector
<String
> v
= new Vector
<String
>();
797 iCheckBoxList
.setAllItems(v
);
799 return iCheckBoxList
;
803 * This method initializes jComboBox
805 * @return javax.swing.JComboBox
807 private JComboBox
getJComboBox() {
808 if (jComboBox
== null) {
809 jComboBox
= new JComboBox();
810 jComboBox
.setPreferredSize(new java
.awt
.Dimension(31,20));
811 jComboBox
.setSize(new java
.awt
.Dimension(290,20));
812 jComboBox
.setLocation(new java
.awt
.Point(218,111));
813 jComboBox
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
814 public void focusGained(java
.awt
.event
.FocusEvent e
) {
815 if (jTextFieldAdd
.getText().length() == 0) {
818 jComboBox
.removeAllItems();
819 getLibInstances(jTextFieldAdd
.getText());
820 Set
<String
> libNames
= libNameGuidMap
.keySet();
821 Iterator
<String
> si
= libNames
.iterator();
822 while(si
.hasNext()) {
823 jComboBox
.addItem(si
.next());
832 private void getLibInstances(String libClass
){
833 libNameGuidMap
.clear();
835 GlobalData
.initInfo("Tools" + File
.separator
+ "Conf" + File
.separator
+ "FrameworkDatabase.db", System
.getenv("WORKSPACE"));
837 Set
<PackageIdentification
> spi
= GlobalData
.getPackageList();
838 Iterator ispi
= spi
.iterator();
840 while (ispi
.hasNext()) {
841 PackageIdentification pi
= (PackageIdentification
) ispi
.next();
843 Set
<ModuleIdentification
> smi
= GlobalData
.getModules(pi
);
844 Iterator ismi
= smi
.iterator();
845 while (ismi
.hasNext()) {
846 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
847 Map
<String
, XmlObject
> m
= GlobalData
.getNativeMsa(mi
);
848 SurfaceAreaQuery
.setDoc(m
);
849 String
[] classProduced
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED");
850 for (int i
= 0; i
< classProduced
.length
; ++i
) {
851 if (classProduced
[i
].equals(libClass
)) {
852 libNameGuidMap
.put(mi
.getName(), mi
.getGuid());
859 JOptionPane
.showMessageDialog(frame
, "Search Instances Fail.");
864 private String
nameToGuid(String name
) {
866 if (!libNameGuidMap
.containsKey(name
)) {
870 s
= libNameGuidMap
.get(name
);
874 private String
guidToName(String guid
){
876 if (!libNameGuidMap
.containsValue(guid
)) {
879 Set
<String
> key
= libNameGuidMap
.keySet();
880 Iterator
<String
> is
= key
.iterator();
881 while(is
.hasNext()) {
883 if (libNameGuidMap
.get(s
).equals(guid
)) {