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 jButtonRemoveAll
= null;
92 private JLabel jLabelHdr
= null;
94 private JTextField jTextFieldHdr
= 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 jLabel1ClassName
= 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 jLabel2HelpText
= null;
116 private JTextField jTextFieldHelp
= null;
118 private JLabel jLabel3RecInstName
= null;
120 private JTextField jTextField1RecInstName
= null;
122 private JLabel jLabel4RecInstVer
= null;
124 private JTextField jTextField2RecInstVer
= null;
126 private JLabel jLabel5SupArchList
= null;
128 private JLabel jLabel6SupModList
= null;
130 private JScrollPane jScrollPaneModules
= null;
132 private JScrollPane jScrollPane1Arch
= null;
134 private ICheckBoxList iCheckBoxListModules
= null;
136 private ICheckBoxList iCheckBoxList
= null;
138 private JComboBox jComboBox
= null;
140 private int cnClassName
= 0;
141 private int cnHdrFile
= 1;
142 private int cnHelpText
= 2;
143 private int cnRecInstName
= 3;
144 private int cnRecInstVer
= 4;
145 private int cnSupArch
= 5;
146 private int cnSupMod
= 6;
148 HashMap
<String
, String
> libNameGuidMap
= new HashMap
<String
, String
>();
152 This method initializes this
155 private void initialize() {
157 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
162 This method initializes jTextFieldAdd
164 @return javax.swing.JTextField
166 private JTextField
getJTextFieldAdd() {
167 if (jTextFieldAdd
== null) {
168 jTextFieldAdd
= new JTextField();
169 jTextFieldAdd
.setBounds(new java
.awt
.Rectangle(122,6,390,20));
170 jTextFieldAdd
.setPreferredSize(new java
.awt
.Dimension(260,20));
171 jTextFieldAdd
.setEnabled(true);
173 return jTextFieldAdd
;
177 This method initializes jComboBoxSelect
179 @return javax.swing.JComboBox
181 private JComboBox
getJComboBoxSelect() {
182 if (jComboBoxSelect
== null) {
183 jComboBoxSelect
= new JComboBox();
184 jComboBoxSelect
.setBounds(new java
.awt
.Rectangle(220, 10, 260, 20));
185 jComboBoxSelect
.setPreferredSize(new java
.awt
.Dimension(260,22));
186 jComboBoxSelect
.setEnabled(true);
187 jComboBoxSelect
.setVisible(false);
189 return jComboBoxSelect
;
193 This method initializes jScrollPane
195 @return javax.swing.JScrollPane
197 Used for the Table of Library Classes that are provided by this package
200 private JScrollPane
getJScrollPane() {
201 if (jScrollPane
== null) {
202 jScrollPane
= new JScrollPane();
203 jScrollPane
.setBounds(new java
.awt
.Rectangle(12,351,608,253));
204 jScrollPane
.setPreferredSize(new java
.awt
.Dimension(390,150));
205 jScrollPane
.setViewportView(getJTable());
211 This method initializes jTable
213 @return javax.swing.JTable
215 private JTable
getJTable() {
216 if (jTable
== null) {
217 model
= new DefaultTableModel();
218 jTable
= new JTable(model
);
219 jTable
.setRowHeight(20);
220 // jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
221 jTable
.setColumnSelectionAllowed(false);
222 model
.addColumn("Class Name");
223 model
.addColumn("Header");
224 model
.addColumn("Help Text");
225 model
.addColumn("Reserved");
226 model
.addColumn("Reserved");
227 // model.addColumn("Recommended Instance");
228 // model.addColumn("Version");
229 model
.addColumn("Sup. Arch");
230 model
.addColumn("Mod. Types");
232 Vector
<String
> vArch
= new Vector
<String
>();
239 // jTable.getColumnModel().getColumn(cnSupArch).setCellEditor(new ListEditor(vArch));
241 Vector
<String
> vModule
= new Vector
<String
>();
244 vModule
.add("PEI_CORE");
246 vModule
.add("DXE_CORE");
247 vModule
.add("DXE_DRIVER");
248 vModule
.add("DXE_RUNTIME_DRIVER");
249 vModule
.add("DXE_SAL_DRIVER");
250 vModule
.add("DXE_SMM_DRIVER");
251 vModule
.add("UEFI_DRIVER");
252 vModule
.add("UEFI_APPLICATION");
253 vModule
.add("USER_DEFINED");
256 jTable
.getColumnModel().getColumn(cnSupMod
).setCellEditor(new ListEditor(vModule
));
258 jTable
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
259 jTable
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
260 public void valueChanged(ListSelectionEvent e
) {
261 if (e
.getValueIsAdjusting()){
264 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
265 if (lsm
.isSelectionEmpty()) {
269 selectedRow
= lsm
.getMinSelectionIndex();
274 jTable
.getModel().addTableModelListener(this);
281 public void tableChanged(TableModelEvent arg0
) {
282 // TODO Auto-generated method stub
283 int row
= arg0
.getFirstRow();
284 TableModel m
= (TableModel
)arg0
.getSource();
285 if (arg0
.getType() == TableModelEvent
.UPDATE
){
286 String lib
= m
.getValueAt(row
, cnClassName
) + "";
287 String hdr
= m
.getValueAt(row
, cnHdrFile
) + "";
288 String hlp
= m
.getValueAt(row
, cnHelpText
) + "";
289 String name
= m
.getValueAt(row
, cnRecInstName
) + "";
290 String ver
= m
.getValueAt(row
, cnRecInstVer
) + "";
292 if (m
.getValueAt(row
, cnSupArch
) != null) {
293 arch
= m
.getValueAt(row
, cnSupArch
).toString();
295 String module
= null;
296 // if (lsm.isSelectionEmpty()) {
297 if (m
.getValueAt(row
, cnSupMod
) != null) {
298 module
= m
.getValueAt(row
, cnSupMod
).toString();
299 if (module
== "NONE") {
303 String
[] rowData
= {lib
, hdr
, hlp
};
304 if (!dataValidation(rowData
)) {
307 docConsole
.setSaved(false);
309 // LAH getLibInstances(lib);
311 // LAH String guid = nameToGuid(name);
313 // LAH WAS sfc.updateSpdLibClass(row, lib, hdr, hlp, guid, ver, arch, module);
314 sfc
.updateSpdLibClass(row
, lib
, hdr
, hlp
, null, null, arch
, module
);
319 This method initializes jButtonAdd
321 @return javax.swing.JButton
323 private JButton
getJButtonAdd() {
324 if (jButtonAdd
== null) {
325 jButtonAdd
= new JButton();
326 jButtonAdd
.setText("Add");
327 jButtonAdd
.setSize(new java
.awt
.Dimension(99,20));
328 jButtonAdd
.setLocation(new java
.awt
.Point(321,326));
329 jButtonAdd
.addActionListener(this);
335 This method initializes jButtonRemove
337 @return javax.swing.JButton
339 private JButton
getJButtonRemove() {
340 if (jButtonRemove
== null) {
341 jButtonRemove
= new JButton();
342 jButtonRemove
.setText("Remove");
343 jButtonRemove
.setSize(new java
.awt
.Dimension(99,20));
344 jButtonRemove
.setLocation(new java
.awt
.Point(424,326));
345 jButtonRemove
.addActionListener(this);
347 return jButtonRemove
;
351 This method initializes jButtonRemoveAll
353 @return javax.swing.JButton
355 private JButton
getJButtonRemoveAll() {
356 if (jButtonRemoveAll
== null) {
357 jButtonRemoveAll
= new JButton();
358 jButtonRemoveAll
.setText("Remove All");
359 jButtonRemoveAll
.setSize(new java
.awt
.Dimension(99,20));
360 jButtonRemoveAll
.setLocation(new java
.awt
.Point(527,326));
361 jButtonRemoveAll
.addActionListener(this);
363 return jButtonRemoveAll
;
367 This is the default constructor
369 public SpdLibClassDecls() {
376 public SpdLibClassDecls(PackageSurfaceAreaDocument
.PackageSurfaceArea inPsa
){
378 sfc
= new SpdFileContents(inPsa
);
382 public SpdLibClassDecls(OpeningPackageType opt
) {
383 this(opt
.getXmlSpd());
387 This method initializes this
391 private void init() {
393 this.setContentPane(getJContentPane());
394 this.setTitle("Library Class Declarations");
395 this.setBounds(new java
.awt
.Rectangle(0, 0, 500, 370));
396 this.setVisible(true);
397 this.addInternalFrameListener(new InternalFrameAdapter(){
398 public void internalFrameDeactivated(InternalFrameEvent e
){
399 if (jTable
.isEditing()) {
400 jTable
.getCellEditor().stopCellEditing();
407 private void init(SpdFileContents sfc
) {
408 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
412 // initialize table using SpdFileContents object
414 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][7];
415 sfc
.getSpdLibClassDeclarations(saa
);
417 while (i
< saa
.length
) {
418 if (saa
[i
][3] != null && saa
[i
][3].length() > 0) {
419 getLibInstances(saa
[i
][0]);
420 saa
[i
][3] = guidToName(saa
[i
][3]);
423 model
.addRow(saa
[i
]);
427 private JScrollPane
getJContentPane(){
428 if (topScrollPane
== null){
429 topScrollPane
= new JScrollPane();
430 topScrollPane
.setSize(new java
.awt
.Dimension(634,590));
431 topScrollPane
.setViewportView(getJContentPane1());
433 return topScrollPane
;
436 This method initializes jContentPane
438 @return javax.swing.JPanel
440 private JPanel
getJContentPane1() {
441 if (jContentPane
== null) {
443 jStarLabel1
= new StarLabel();
444 jStarLabel1
.setLocation(new java
.awt
.Point(1,7));
445 jLabel1ClassName
= new JLabel();
446 jLabel1ClassName
.setBounds(new java
.awt
.Rectangle(16,6,82,20));
447 jLabel1ClassName
.setText("Library Class");
450 starLabel
= new StarLabel();
451 starLabel
.setBounds(new java
.awt
.Rectangle(1,33,10,20));
452 jLabel2HelpText
= new JLabel();
453 jLabel2HelpText
.setBounds(new java
.awt
.Rectangle(16,33,82,20));
454 jLabel2HelpText
.setText("Help Text");
457 jStarLabel2
= new StarLabel();
458 jStarLabel2
.setLocation(new java
.awt
.Point(1,74));
459 jLabelHdr
= new JLabel();
460 jLabelHdr
.setBounds(new java
.awt
.Rectangle(14,74,199,22));
461 jLabelHdr
.setText("Include Header for Specified Class");
463 jLabel6SupModList
= new JLabel();
464 jLabel6SupModList
.setBounds(new java
.awt
.Rectangle(16,252,108,16));
465 jLabel6SupModList
.setText("Supported Module");
466 jLabel6SupModList
.setEnabled(true);
468 jLabel5SupArchList
= new JLabel();
469 jLabel5SupArchList
.setBounds(new java
.awt
.Rectangle(15,169,93,16));
470 jLabel5SupArchList
.setText("Supported Arch");
471 jLabel5SupArchList
.setEnabled(true);
472 jLabel4RecInstVer
= new JLabel();
473 jLabel4RecInstVer
.setBounds(new java
.awt
.Rectangle(16,138,196,16));
474 jLabel4RecInstVer
.setEnabled(true);
475 jLabel4RecInstVer
.setText("Recommended Instance Version");
476 jLabel3RecInstName
= new JLabel();
477 jLabel3RecInstName
.setBounds(new java
.awt
.Rectangle(17,112,195,16));
478 jLabel3RecInstName
.setEnabled(true);
479 jLabel3RecInstName
.setText("Recommended Instance Name");
481 jContentPane
= new JPanel();
482 jContentPane
.setPreferredSize(new Dimension(480, 400));
483 jContentPane
.setLayout(null);
484 jContentPane
.add(jLabelHdr
, null);
485 jContentPane
.add(jStarLabel1
, null);
486 jContentPane
.add(jStarLabel2
, null);
487 jContentPane
.add(getJTextFieldAdd(), null);
488 jContentPane
.add(getJComboBoxSelect(), null);
489 jContentPane
.add(getJScrollPane(), null);
490 jContentPane
.add(getJButtonAdd(), null);
491 jContentPane
.add(getJButtonRemove(), null);
492 jContentPane
.add(getJButtonRemoveAll(), null);
494 jContentPane
.add(getJTextFieldHdr(), null);
495 jContentPane
.add(getJButtonBrowse(), null);
496 jContentPane
.add(jLabel1ClassName
, null);
497 jContentPane
.add(starLabel
, null);
498 jContentPane
.add(jLabel2HelpText
, null);
499 jContentPane
.add(getJTextFieldHelp(), null);
500 // LAH Removed until we can fix permanently
501 // jContentPane.add(jLabel3RecInstName, null);
502 // jContentPane.add(getJTextField1RecInstName(), null);
503 // jContentPane.add(jLabel4RecInstVer, null);
504 // jContentPane.add(getJTextField2RecInstVer(), null);
505 jContentPane
.add(jLabel5SupArchList
, null);
506 jContentPane
.add(jLabel6SupModList
, null);
508 jContentPane
.add(getJScrollPaneModules(), null);
509 jContentPane
.add(getJScrollPane1Arch(), null);
510 // LAH jContentPane.add(getJComboBox(), null);
518 fill ComboBoxes with pre-defined contents
520 private void initFrame() {
521 jComboBoxSelect
.addItem("BaseCpuICacheFlush");
522 jComboBoxSelect
.addItem("BaseDebugLibNull");
523 jComboBoxSelect
.addItem("BaseDebugLibReportStatusCode");
524 jComboBoxSelect
.addItem("BaseIoLibIntrinsic");
525 jComboBoxSelect
.addItem("BaseLib");
526 jComboBoxSelect
.addItem("BaseMemoryLib");
527 jComboBoxSelect
.addItem("BaseMemoryLibMmx");
528 jComboBoxSelect
.addItem("BaseMemoryLibSse2");
529 jComboBoxSelect
.addItem("BasePeCoffGetEntryPointLib");
530 jComboBoxSelect
.addItem("BasePeCoffLib");
531 jComboBoxSelect
.addItem("BasePrintLib");
532 jComboBoxSelect
.addItem("BaseReportStatusCodeLibNull");
533 jComboBoxSelect
.addItem("CommonPciCf8Lib");
534 jComboBoxSelect
.addItem("CommonPciExpressLib");
535 jComboBoxSelect
.addItem("CommonPciLibCf8");
536 jComboBoxSelect
.addItem("CommonPciLibPciExpress");
537 jComboBoxSelect
.addItem("DxeCoreEntryPoint");
538 jComboBoxSelect
.addItem("DxeHobLib");
539 jComboBoxSelect
.addItem("DxeIoLibCpuIo");
540 jComboBoxSelect
.addItem("DxeLib");
541 jComboBoxSelect
.addItem("DxePcdLib");
542 jComboBoxSelect
.addItem("DxeReportStatusCodeLib");
543 jComboBoxSelect
.addItem("DxeServicesTableLib");
544 jComboBoxSelect
.addItem("PeiCoreEntryPoint");
545 jComboBoxSelect
.addItem("PeiMemoryLib");
546 jComboBoxSelect
.addItem("PeimEntryPoint");
547 jComboBoxSelect
.addItem("PeiReportStatusCodeLib");
548 jComboBoxSelect
.addItem("PeiServicesTablePointerLib");
549 jComboBoxSelect
.addItem("PeiServicesTablePointerLibMm7");
550 jComboBoxSelect
.addItem("UefiDebugLibConOut");
551 jComboBoxSelect
.addItem("UefiDebugLibStdErr");
552 jComboBoxSelect
.addItem("UefiDriverEntryPointMultiple");
553 jComboBoxSelect
.addItem("UefiDriverEntryPointSingle");
554 jComboBoxSelect
.addItem("UefiDriverEntryPointSingleUnload");
555 jComboBoxSelect
.addItem("UefiDriverModelLib");
556 jComboBoxSelect
.addItem("UefiDriverModelLibNoConfigNoDiag");
557 jComboBoxSelect
.addItem("UefiLib");
558 jComboBoxSelect
.addItem("UefiMemoryLib");
563 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
565 public void actionPerformed(ActionEvent arg0
) {
567 if (arg0
.getSource() == jButtonAdd
) {
569 //ToDo: check before add
570 // LAH WAS String[] row = {null, null, null, jComboBox.getSelectedItem()+"", jTextField2RecInstVer.getText(), null, null};
571 String
[] row
= {null, null, null, null, null, null, null};
572 row
[cnClassName
] = jTextFieldAdd
.getText();
573 row
[cnHdrFile
] = jTextFieldHdr
.getText().replace('\\', '/');
574 row
[cnHelpText
] = jTextFieldHelp
.getText();
575 row
[cnSupArch
] = vectorToString(iCheckBoxList
.getAllCheckedItemsString());
576 if (row
[cnSupArch
].length() == 0) {
577 row
[cnSupArch
] = null;
579 row
[cnSupMod
] = vectorToString(iCheckBoxListModules
.getAllCheckedItemsString());
580 if (row
[cnSupMod
].length() == 0){
581 row
[cnSupMod
] = null;
583 if (!dataValidation(row
)) {
587 jTable
.changeSelection(model
.getRowCount()-1, 0, false, false);
588 docConsole
.setSaved(false);
590 //convert to GUID before storing recommended lib instance.
592 getLibInstances(row
[0]);
594 // LAH recommendGuid = nameToGuid(row[3]);
596 // LAH WAS sfc.genSpdLibClassDeclarations(row[0], recommendGuid, row[1], row[2], row[5], null, null, row[4], null, row[6]);
597 sfc
.genSpdLibClassDeclarations(row
[cnClassName
], null, row
[cnHdrFile
], row
[cnHelpText
], row
[cnSupArch
], null, null, row
[cnRecInstVer
], null, row
[cnSupMod
]);
601 // remove selected line
603 if (arg0
.getSource() == jButtonRemove
) {
604 if (jTable
.isEditing()){
605 jTable
.getCellEditor().stopCellEditing();
607 int rowSelected
= selectedRow
;
608 if (rowSelected
>= 0) {
609 model
.removeRow(rowSelected
);
610 sfc
.removeSpdLibClass(rowSelected
);
614 if (arg0
.getSource() == jButtonRemoveAll
) {
615 if (model
.getRowCount() == 0) {
619 model
.setRowCount(0);
620 sfc
.removeSpdLibClass();
624 private boolean dataValidation(String
[] row
) {
625 if (!DataValidation
.isKeywordType(row
[cnClassName
])) {
626 JOptionPane
.showMessageDialog(frame
, "Library Class is NOT KeyWord Type.");
629 if (!DataValidation
.isPathAndFilename(row
[cnHdrFile
])) {
630 JOptionPane
.showMessageDialog(frame
, "Include Header is NOT PathAndFilename Type.");
632 if (row
[cnHelpText
].length() == 0) {
633 JOptionPane
.showMessageDialog(frame
, "Help Text Must NOT be empty.");
638 Add contents in list to sfc
640 protected void save() {
645 This method initializes jTextField
647 @return javax.swing.JTextField
649 private JTextField
getJTextFieldHdr() {
650 if (jTextFieldHdr
== null) {
651 jTextFieldHdr
= new JTextField();
652 jTextFieldHdr
.setBounds(new java
.awt
.Rectangle(218,75,305,21));
653 jTextFieldHdr
.setPreferredSize(new java
.awt
.Dimension(260,20));
655 return jTextFieldHdr
;
659 This method initializes jButtonBrowse
661 @return javax.swing.JButton
663 private JButton
getJButtonBrowse() {
664 if (jButtonBrowse
== null) {
665 jButtonBrowse
= new JButton();
666 jButtonBrowse
.setBounds(new java
.awt
.Rectangle(527,75,90,20));
667 jButtonBrowse
.setText("Browse");
668 jButtonBrowse
.setPreferredSize(new java
.awt
.Dimension(99,20));
669 jButtonBrowse
.addActionListener(new AbstractAction() {
674 private static final long serialVersionUID
= 1L;
676 public void actionPerformed(ActionEvent arg0
) {
678 // Select files from current pkg
680 String dirPrefix
= Tools
.dirForNewSpd
.substring(0, Tools
.dirForNewSpd
.lastIndexOf(File
.separator
));
681 JFileChooser chooser
= new JFileChooser(dirPrefix
);
683 String headerDest
= null;
685 chooser
.setMultiSelectionEnabled(false);
686 chooser
.setFileSelectionMode(JFileChooser
.FILES_AND_DIRECTORIES
);
687 int retval
= chooser
.showOpenDialog(frame
);
688 if (retval
== JFileChooser
.APPROVE_OPTION
) {
690 theFile
= chooser
.getSelectedFile();
691 String file
= theFile
.getPath();
692 if (!file
.startsWith(dirPrefix
)) {
693 JOptionPane
.showMessageDialog(frame
, "You can only select files in current package!");
703 headerDest
= theFile
.getPath();
704 int fileIndex
= headerDest
.indexOf(System
.getProperty("file.separator"), dirPrefix
.length());
705 jTextFieldHdr
.setText(headerDest
.substring(fileIndex
+ 1).replace('\\', '/'));
711 return jButtonBrowse
;
714 public void componentResized(ComponentEvent arg0
) {
715 int intPreferredWidth
= 500;
717 resizeComponentWidth(this.jTextFieldAdd
, this.getWidth(), intPreferredWidth
);
718 resizeComponentWidth(this.jTextFieldHelp
, this.getWidth(), intPreferredWidth
);
719 resizeComponentWidth(this.jScrollPane
, this.getWidth(), intPreferredWidth
-10);
723 * This method initializes jTextFieldHelp
725 * @return javax.swing.JTextField
727 private JTextField
getJTextFieldHelp() {
728 if (jTextFieldHelp
== null) {
729 jTextFieldHelp
= new JTextField();
730 jTextFieldHelp
.setBounds(new java
.awt
.Rectangle(122,33,390,20));
731 jTextFieldHelp
.setPreferredSize(new java
.awt
.Dimension(260,20));
733 return jTextFieldHelp
;
737 * This method initializes jTextField1RecInstName
739 * @return javax.swing.JTextField
741 private JTextField
getJTextField1RecInstName() {
742 if (jTextField1RecInstName
== null) {
743 jTextField1RecInstName
= new JTextField();
744 jTextField1RecInstName
.setBounds(new java
.awt
.Rectangle(218,110,291,20));
745 jTextField1RecInstName
.setEnabled(true);
746 jTextField1RecInstName
.setVisible(false);
748 return jTextField1RecInstName
;
752 * This method initializes jTextField2RecInstVer
754 * @return javax.swing.JTextField
756 private JTextField
getJTextField2RecInstVer() {
757 if (jTextField2RecInstVer
== null) {
758 jTextField2RecInstVer
= new JTextField();
759 jTextField2RecInstVer
.setBounds(new java
.awt
.Rectangle(218,135,292,20));
760 jTextField2RecInstVer
.setEnabled(true);
762 return jTextField2RecInstVer
;
765 private JScrollPane
getJScrollPaneModules() {
766 if (jScrollPaneModules
== null) {
767 jScrollPaneModules
= new JScrollPane();
768 jScrollPaneModules
.setBounds(new java
.awt
.Rectangle(218,245,293,73));
769 jScrollPaneModules
.setPreferredSize(new java
.awt
.Dimension(320, 80));
770 jScrollPaneModules
.setViewportView(getICheckBoxListSupportedModules());
772 return jScrollPaneModules
;
775 private ICheckBoxList
getICheckBoxListSupportedModules() {
776 if (iCheckBoxListModules
== null) {
777 iCheckBoxListModules
= new ICheckBoxList();
778 iCheckBoxListModules
.setBounds(new java
.awt
.Rectangle(218,246,292,73));
779 Vector
<String
> v
= new Vector
<String
>();
786 v
.add("DXE_RUNTIME_DRIVER");
787 v
.add("DXE_SAL_DRIVER");
788 v
.add("DXE_SMM_DRIVER");
789 v
.add("UEFI_DRIVER");
790 v
.add("UEFI_APPLICATION");
791 v
.add("USER_DEFINED");
792 iCheckBoxListModules
.setAllItems(v
);
794 return iCheckBoxListModules
;
797 private String
vectorToString(Vector
<String
> v
) {
799 for (int i
= 0; i
< v
.size(); ++i
) {
806 private JScrollPane
getJScrollPane1Arch() {
807 if (jScrollPane1Arch
== null) {
808 jScrollPane1Arch
= new JScrollPane();
809 jScrollPane1Arch
.setBounds(new java
.awt
.Rectangle(218,170,293,73));
810 jScrollPane1Arch
.setPreferredSize(new java
.awt
.Dimension(320, 80));
811 jScrollPane1Arch
.setViewportView(getICheckBoxList());
813 return jScrollPane1Arch
;
816 * This method initializes iCheckBoxList
818 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
820 private ICheckBoxList
getICheckBoxList() {
821 if (iCheckBoxList
== null) {
822 iCheckBoxList
= new ICheckBoxList();
823 iCheckBoxList
.setBounds(new java
.awt
.Rectangle(218,171,292,66));
824 Vector
<String
> v
= new Vector
<String
>();
831 iCheckBoxList
.setAllItems(v
);
833 return iCheckBoxList
;
837 * This method initializes jComboBox
839 * @return javax.swing.JComboBox
841 private JComboBox
getJComboBox() {
842 if (jComboBox
== null) {
843 jComboBox
= new JComboBox();
844 jComboBox
.setPreferredSize(new java
.awt
.Dimension(31,20));
845 jComboBox
.setSize(new java
.awt
.Dimension(290,20));
846 jComboBox
.setLocation(new java
.awt
.Point(218,111));
847 jComboBox
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
848 public void focusGained(java
.awt
.event
.FocusEvent e
) {
849 if (jTextFieldAdd
.getText().length() == 0) {
852 jComboBox
.removeAllItems();
853 getLibInstances(jTextFieldAdd
.getText());
854 Set
<String
> libNames
= libNameGuidMap
.keySet();
855 Iterator
<String
> si
= libNames
.iterator();
856 while(si
.hasNext()) {
857 jComboBox
.addItem(si
.next());
866 private void getLibInstances(String libClass
){
867 libNameGuidMap
.clear();
869 GlobalData
.initInfo("Tools" + File
.separator
+ "Conf" + File
.separator
+ "FrameworkDatabase.db", System
.getenv("WORKSPACE"));
871 Set
<PackageIdentification
> spi
= GlobalData
.getPackageList();
872 Iterator ispi
= spi
.iterator();
874 while (ispi
.hasNext()) {
875 PackageIdentification pi
= (PackageIdentification
) ispi
.next();
877 Set
<ModuleIdentification
> smi
= GlobalData
.getModules(pi
);
878 Iterator ismi
= smi
.iterator();
879 while (ismi
.hasNext()) {
880 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
881 Map
<String
, XmlObject
> m
= GlobalData
.getNativeMsa(mi
);
882 SurfaceAreaQuery
.setDoc(m
);
883 String
[] classProduced
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED");
884 for (int i
= 0; i
< classProduced
.length
; ++i
) {
885 if (classProduced
[i
].equals(libClass
)) {
886 libNameGuidMap
.put(mi
.getName(), mi
.getGuid());
893 JOptionPane
.showMessageDialog(frame
, "Search Instances Fail.");
898 private String
nameToGuid(String name
) {
900 if (!libNameGuidMap
.containsKey(name
)) {
904 s
= libNameGuidMap
.get(name
);
908 private String
guidToName(String guid
){
910 if (!libNameGuidMap
.containsValue(guid
)) {
913 Set
<String
> key
= libNameGuidMap
.keySet();
914 Iterator
<String
> is
= key
.iterator();
915 while(is
.hasNext()) {
917 if (libNameGuidMap
.get(s
).equals(guid
)) {