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");
255 jTable
.getColumnModel().getColumn(cnSupMod
).setCellEditor(new ListEditor(vModule
));
257 jTable
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
258 jTable
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
259 public void valueChanged(ListSelectionEvent e
) {
260 if (e
.getValueIsAdjusting()){
263 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
264 if (lsm
.isSelectionEmpty()) {
268 selectedRow
= lsm
.getMinSelectionIndex();
273 jTable
.getModel().addTableModelListener(this);
280 public void tableChanged(TableModelEvent arg0
) {
281 // TODO Auto-generated method stub
282 int row
= arg0
.getFirstRow();
283 TableModel m
= (TableModel
)arg0
.getSource();
284 if (arg0
.getType() == TableModelEvent
.UPDATE
){
285 String lib
= m
.getValueAt(row
, cnClassName
) + "";
286 String hdr
= m
.getValueAt(row
, cnHdrFile
) + "";
287 String hlp
= m
.getValueAt(row
, cnHelpText
) + "";
288 String name
= m
.getValueAt(row
, cnRecInstName
) + "";
289 String ver
= m
.getValueAt(row
, cnRecInstVer
) + "";
291 if (m
.getValueAt(row
, cnSupArch
) != null) {
292 arch
= m
.getValueAt(row
, cnSupArch
).toString();
294 String module
= null;
295 if (m
.getValueAt(row
, cnSupMod
) != null) {
296 module
= m
.getValueAt(row
, cnSupMod
).toString();
298 String
[] rowData
= {lib
, hdr
, hlp
};
299 if (!dataValidation(rowData
)) {
302 docConsole
.setSaved(false);
304 // LAH getLibInstances(lib);
307 String guid
= nameToGuid(name
);
310 // LAH WAS sfc.updateSpdLibClass(row, lib, hdr, hlp, guid, ver, arch, module);
311 sfc
.updateSpdLibClass(row
, lib
, hdr
, hlp
, null, null, arch
, module
);
316 This method initializes jButtonAdd
318 @return javax.swing.JButton
320 private JButton
getJButtonAdd() {
321 if (jButtonAdd
== null) {
322 jButtonAdd
= new JButton();
323 jButtonAdd
.setText("Add");
324 jButtonAdd
.setSize(new java
.awt
.Dimension(99,20));
325 jButtonAdd
.setLocation(new java
.awt
.Point(321,326));
326 jButtonAdd
.addActionListener(this);
332 This method initializes jButtonRemove
334 @return javax.swing.JButton
336 private JButton
getJButtonRemove() {
337 if (jButtonRemove
== null) {
338 jButtonRemove
= new JButton();
339 jButtonRemove
.setText("Remove");
340 jButtonRemove
.setSize(new java
.awt
.Dimension(99,20));
341 jButtonRemove
.setLocation(new java
.awt
.Point(424,326));
342 jButtonRemove
.addActionListener(this);
344 return jButtonRemove
;
348 This method initializes jButtonRemoveAll
350 @return javax.swing.JButton
352 private JButton
getJButtonRemoveAll() {
353 if (jButtonRemoveAll
== null) {
354 jButtonRemoveAll
= new JButton();
355 jButtonRemoveAll
.setText("Remove All");
356 jButtonRemoveAll
.setSize(new java
.awt
.Dimension(99,20));
357 jButtonRemoveAll
.setLocation(new java
.awt
.Point(527,326));
358 jButtonRemoveAll
.addActionListener(this);
360 return jButtonRemoveAll
;
364 This is the default constructor
366 public SpdLibClassDecls() {
373 public SpdLibClassDecls(PackageSurfaceAreaDocument
.PackageSurfaceArea inPsa
){
375 sfc
= new SpdFileContents(inPsa
);
379 public SpdLibClassDecls(OpeningPackageType opt
) {
380 this(opt
.getXmlSpd());
384 This method initializes this
388 private void init() {
390 this.setContentPane(getJContentPane());
391 this.setTitle("Library Class Declarations");
392 this.setBounds(new java
.awt
.Rectangle(0, 0, 500, 370));
393 this.setVisible(true);
394 this.addInternalFrameListener(new InternalFrameAdapter(){
395 public void internalFrameDeactivated(InternalFrameEvent e
){
396 if (jTable
.isEditing()) {
397 jTable
.getCellEditor().stopCellEditing();
404 private void init(SpdFileContents sfc
) {
405 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
409 // initialize table using SpdFileContents object
411 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][7];
412 sfc
.getSpdLibClassDeclarations(saa
);
414 while (i
< saa
.length
) {
415 if (saa
[i
][3] != null && saa
[i
][3].length() > 0) {
416 getLibInstances(saa
[i
][0]);
417 saa
[i
][3] = guidToName(saa
[i
][3]);
420 model
.addRow(saa
[i
]);
424 private JScrollPane
getJContentPane(){
425 if (topScrollPane
== null){
426 topScrollPane
= new JScrollPane();
427 topScrollPane
.setSize(new java
.awt
.Dimension(634,590));
428 topScrollPane
.setViewportView(getJContentPane1());
430 return topScrollPane
;
433 This method initializes jContentPane
435 @return javax.swing.JPanel
437 private JPanel
getJContentPane1() {
438 if (jContentPane
== null) {
440 jStarLabel1
= new StarLabel();
441 jStarLabel1
.setLocation(new java
.awt
.Point(1,7));
442 jLabel1ClassName
= new JLabel();
443 jLabel1ClassName
.setBounds(new java
.awt
.Rectangle(16,6,82,20));
444 jLabel1ClassName
.setText("Library Class");
447 starLabel
= new StarLabel();
448 starLabel
.setBounds(new java
.awt
.Rectangle(1,33,10,20));
449 jLabel2HelpText
= new JLabel();
450 jLabel2HelpText
.setBounds(new java
.awt
.Rectangle(16,33,82,20));
451 jLabel2HelpText
.setText("Help Text");
454 jStarLabel2
= new StarLabel();
455 jStarLabel2
.setLocation(new java
.awt
.Point(1,74));
456 jLabelHdr
= new JLabel();
457 jLabelHdr
.setBounds(new java
.awt
.Rectangle(14,74,199,22));
458 jLabelHdr
.setText("Include Header for Specified Class");
460 jLabel6SupModList
= new JLabel();
461 jLabel6SupModList
.setBounds(new java
.awt
.Rectangle(16,252,108,16));
462 jLabel6SupModList
.setText("Supported Module");
463 jLabel6SupModList
.setEnabled(true);
465 jLabel5SupArchList
= new JLabel();
466 jLabel5SupArchList
.setBounds(new java
.awt
.Rectangle(15,169,93,16));
467 jLabel5SupArchList
.setText("Supported Arch");
468 jLabel5SupArchList
.setEnabled(true);
469 jLabel4RecInstVer
= new JLabel();
470 jLabel4RecInstVer
.setBounds(new java
.awt
.Rectangle(16,138,196,16));
471 jLabel4RecInstVer
.setEnabled(true);
472 jLabel4RecInstVer
.setText("Recommended Instance Version");
473 jLabel3RecInstName
= new JLabel();
474 jLabel3RecInstName
.setBounds(new java
.awt
.Rectangle(17,112,195,16));
475 jLabel3RecInstName
.setEnabled(true);
476 jLabel3RecInstName
.setText("Recommended Instance Name");
478 jContentPane
= new JPanel();
479 jContentPane
.setPreferredSize(new Dimension(480, 400));
480 jContentPane
.setLayout(null);
481 jContentPane
.add(jLabelHdr
, null);
482 jContentPane
.add(jStarLabel1
, null);
483 jContentPane
.add(jStarLabel2
, null);
484 jContentPane
.add(getJTextFieldAdd(), null);
485 jContentPane
.add(getJComboBoxSelect(), null);
486 jContentPane
.add(getJScrollPane(), null);
487 jContentPane
.add(getJButtonAdd(), null);
488 jContentPane
.add(getJButtonRemove(), null);
489 jContentPane
.add(getJButtonRemoveAll(), null);
491 jContentPane
.add(getJTextFieldHdr(), null);
492 jContentPane
.add(getJButtonBrowse(), null);
493 jContentPane
.add(jLabel1ClassName
, null);
494 jContentPane
.add(starLabel
, null);
495 jContentPane
.add(jLabel2HelpText
, null);
496 jContentPane
.add(getJTextFieldHelp(), null);
497 // LAH Removed until we can fix permanently
498 // jContentPane.add(jLabel3RecInstName, null);
499 // jContentPane.add(getJTextField1RecInstName(), null);
500 // jContentPane.add(jLabel4RecInstVer, null);
501 // jContentPane.add(getJTextField2RecInstVer(), null);
502 jContentPane
.add(jLabel5SupArchList
, null);
503 jContentPane
.add(jLabel6SupModList
, null);
505 jContentPane
.add(getJScrollPaneModules(), null);
506 jContentPane
.add(getJScrollPane1Arch(), null);
507 // LAH jContentPane.add(getJComboBox(), null);
515 fill ComboBoxes with pre-defined contents
517 private void initFrame() {
518 jComboBoxSelect
.addItem("BaseCpuICacheFlush");
519 jComboBoxSelect
.addItem("BaseDebugLibNull");
520 jComboBoxSelect
.addItem("BaseDebugLibReportStatusCode");
521 jComboBoxSelect
.addItem("BaseIoLibIntrinsic");
522 jComboBoxSelect
.addItem("BaseLib");
523 jComboBoxSelect
.addItem("BaseMemoryLib");
524 jComboBoxSelect
.addItem("BaseMemoryLibMmx");
525 jComboBoxSelect
.addItem("BaseMemoryLibSse2");
526 jComboBoxSelect
.addItem("BasePeCoffGetEntryPointLib");
527 jComboBoxSelect
.addItem("BasePeCoffLib");
528 jComboBoxSelect
.addItem("BasePrintLib");
529 jComboBoxSelect
.addItem("BaseReportStatusCodeLibNull");
530 jComboBoxSelect
.addItem("CommonPciCf8Lib");
531 jComboBoxSelect
.addItem("CommonPciExpressLib");
532 jComboBoxSelect
.addItem("CommonPciLibCf8");
533 jComboBoxSelect
.addItem("CommonPciLibPciExpress");
534 jComboBoxSelect
.addItem("DxeCoreEntryPoint");
535 jComboBoxSelect
.addItem("DxeHobLib");
536 jComboBoxSelect
.addItem("DxeIoLibCpuIo");
537 jComboBoxSelect
.addItem("DxeLib");
538 jComboBoxSelect
.addItem("DxePcdLib");
539 jComboBoxSelect
.addItem("DxeReportStatusCodeLib");
540 jComboBoxSelect
.addItem("DxeServicesTableLib");
541 jComboBoxSelect
.addItem("PeiCoreEntryPoint");
542 jComboBoxSelect
.addItem("PeiMemoryLib");
543 jComboBoxSelect
.addItem("PeimEntryPoint");
544 jComboBoxSelect
.addItem("PeiReportStatusCodeLib");
545 jComboBoxSelect
.addItem("PeiServicesTablePointerLib");
546 jComboBoxSelect
.addItem("PeiServicesTablePointerLibMm7");
547 jComboBoxSelect
.addItem("UefiDebugLibConOut");
548 jComboBoxSelect
.addItem("UefiDebugLibStdErr");
549 jComboBoxSelect
.addItem("UefiDriverEntryPointMultiple");
550 jComboBoxSelect
.addItem("UefiDriverEntryPointSingle");
551 jComboBoxSelect
.addItem("UefiDriverEntryPointSingleUnload");
552 jComboBoxSelect
.addItem("UefiDriverModelLib");
553 jComboBoxSelect
.addItem("UefiDriverModelLibNoConfigNoDiag");
554 jComboBoxSelect
.addItem("UefiLib");
555 jComboBoxSelect
.addItem("UefiMemoryLib");
560 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
562 public void actionPerformed(ActionEvent arg0
) {
564 if (arg0
.getSource() == jButtonAdd
) {
566 //ToDo: check before add
567 // LAH WAS String[] row = {null, null, null, jComboBox.getSelectedItem()+"", jTextField2RecInstVer.getText(), null, null};
568 String
[] row
= {null, null, null, null, null, null, null};
569 row
[cnClassName
] = jTextFieldAdd
.getText();
570 row
[cnHdrFile
] = jTextFieldHdr
.getText().replace('\\', '/');
571 row
[cnHelpText
] = jTextFieldHelp
.getText();
572 row
[cnSupArch
] = vectorToString(iCheckBoxList
.getAllCheckedItemsString());
573 if (row
[cnSupArch
].length() == 0) {
574 row
[cnSupArch
] = null;
576 row
[cnSupMod
] = vectorToString(iCheckBoxListModules
.getAllCheckedItemsString());
577 if (row
[cnSupMod
].length() == 0){
578 row
[cnSupMod
] = null;
580 if (!dataValidation(row
)) {
584 jTable
.changeSelection(model
.getRowCount()-1, 0, false, false);
585 docConsole
.setSaved(false);
587 //convert to GUID before storing recommended lib instance.
589 getLibInstances(row
[cnClassName
]);
590 // LAH recommendGuid = nameToGuid(row[3]);
592 // LAH WAS sfc.genSpdLibClassDeclarations(row[0], recommendGuid, row[1], row[2], row[5], null, null, row[4], null, row[6]);
593 sfc
.genSpdLibClassDeclarations(row
[cnClassName
], null, row
[cnHdrFile
], row
[cnHelpText
], row
[cnSupArch
], null, null, row
[cnRecInstVer
], null, row
[cnSupMod
]);
597 // remove selected line
599 if (arg0
.getSource() == jButtonRemove
) {
600 if (jTable
.isEditing()){
601 jTable
.getCellEditor().stopCellEditing();
603 int rowSelected
= selectedRow
;
604 if (rowSelected
>= 0) {
605 model
.removeRow(rowSelected
);
606 sfc
.removeSpdLibClass(rowSelected
);
610 if (arg0
.getSource() == jButtonRemoveAll
) {
611 if (model
.getRowCount() == 0) {
615 model
.setRowCount(0);
616 sfc
.removeSpdLibClass();
620 private boolean dataValidation(String
[] row
) {
621 if (!DataValidation
.isKeywordType(row
[cnClassName
])) {
622 JOptionPane
.showMessageDialog(frame
, "Library Class is NOT KeyWord Type.");
625 if (!DataValidation
.isPathAndFilename(row
[cnHdrFile
])) {
626 JOptionPane
.showMessageDialog(frame
, "Include Header is NOT PathAndFilename Type.");
628 if (row
[cnHelpText
].length() == 0) {
629 JOptionPane
.showMessageDialog(frame
, "Help Text Must NOT be empty.");
634 Add contents in list to sfc
636 protected void save() {
641 This method initializes jTextField
643 @return javax.swing.JTextField
645 private JTextField
getJTextFieldHdr() {
646 if (jTextFieldHdr
== null) {
647 jTextFieldHdr
= new JTextField();
648 jTextFieldHdr
.setBounds(new java
.awt
.Rectangle(218,75,305,21));
649 jTextFieldHdr
.setPreferredSize(new java
.awt
.Dimension(260,20));
651 return jTextFieldHdr
;
655 This method initializes jButtonBrowse
657 @return javax.swing.JButton
659 private JButton
getJButtonBrowse() {
660 if (jButtonBrowse
== null) {
661 jButtonBrowse
= new JButton();
662 jButtonBrowse
.setBounds(new java
.awt
.Rectangle(527,75,90,20));
663 jButtonBrowse
.setText("Browse");
664 jButtonBrowse
.setPreferredSize(new java
.awt
.Dimension(99,20));
665 jButtonBrowse
.addActionListener(new AbstractAction() {
670 private static final long serialVersionUID
= 1L;
672 public void actionPerformed(ActionEvent arg0
) {
674 // Select files from current pkg
676 String dirPrefix
= Tools
.dirForNewSpd
.substring(0, Tools
.dirForNewSpd
.lastIndexOf(File
.separator
));
677 JFileChooser chooser
= new JFileChooser(dirPrefix
);
679 String headerDest
= null;
681 chooser
.setMultiSelectionEnabled(false);
682 chooser
.setFileSelectionMode(JFileChooser
.FILES_AND_DIRECTORIES
);
683 int retval
= chooser
.showOpenDialog(frame
);
684 if (retval
== JFileChooser
.APPROVE_OPTION
) {
686 theFile
= chooser
.getSelectedFile();
687 String file
= theFile
.getPath();
688 if (!file
.startsWith(dirPrefix
)) {
689 JOptionPane
.showMessageDialog(frame
, "You can only select files in current package!");
699 headerDest
= theFile
.getPath();
700 int fileIndex
= headerDest
.indexOf(System
.getProperty("file.separator"), dirPrefix
.length());
701 jTextFieldHdr
.setText(headerDest
.substring(fileIndex
+ 1).replace('\\', '/'));
707 return jButtonBrowse
;
710 public void componentResized(ComponentEvent arg0
) {
711 int intPreferredWidth
= 500;
713 resizeComponentWidth(this.jTextFieldAdd
, this.getWidth(), intPreferredWidth
);
714 resizeComponentWidth(this.jTextFieldHelp
, this.getWidth(), intPreferredWidth
);
715 resizeComponentWidth(this.jScrollPane
, this.getWidth(), intPreferredWidth
-10);
719 * This method initializes jTextFieldHelp
721 * @return javax.swing.JTextField
723 private JTextField
getJTextFieldHelp() {
724 if (jTextFieldHelp
== null) {
725 jTextFieldHelp
= new JTextField();
726 jTextFieldHelp
.setBounds(new java
.awt
.Rectangle(122,33,390,20));
727 jTextFieldHelp
.setPreferredSize(new java
.awt
.Dimension(260,20));
729 return jTextFieldHelp
;
733 * This method initializes jTextField1RecInstName
735 * @return javax.swing.JTextField
737 private JTextField
getJTextField1RecInstName() {
738 if (jTextField1RecInstName
== null) {
739 jTextField1RecInstName
= new JTextField();
740 jTextField1RecInstName
.setBounds(new java
.awt
.Rectangle(218,110,291,20));
741 jTextField1RecInstName
.setEnabled(true);
742 jTextField1RecInstName
.setVisible(false);
744 return jTextField1RecInstName
;
748 * This method initializes jTextField2RecInstVer
750 * @return javax.swing.JTextField
752 private JTextField
getJTextField2RecInstVer() {
753 if (jTextField2RecInstVer
== null) {
754 jTextField2RecInstVer
= new JTextField();
755 jTextField2RecInstVer
.setBounds(new java
.awt
.Rectangle(218,135,292,20));
756 jTextField2RecInstVer
.setEnabled(true);
758 return jTextField2RecInstVer
;
761 private JScrollPane
getJScrollPaneModules() {
762 if (jScrollPaneModules
== null) {
763 jScrollPaneModules
= new JScrollPane();
764 jScrollPaneModules
.setBounds(new java
.awt
.Rectangle(218,245,293,73));
765 jScrollPaneModules
.setPreferredSize(new java
.awt
.Dimension(320, 80));
766 jScrollPaneModules
.setViewportView(getICheckBoxListSupportedModules());
768 return jScrollPaneModules
;
771 private ICheckBoxList
getICheckBoxListSupportedModules() {
772 if (iCheckBoxListModules
== null) {
773 iCheckBoxListModules
= new ICheckBoxList();
774 iCheckBoxListModules
.setBounds(new java
.awt
.Rectangle(218,246,292,73));
775 Vector
<String
> v
= new Vector
<String
>();
782 v
.add("DXE_RUNTIME_DRIVER");
783 v
.add("DXE_SAL_DRIVER");
784 v
.add("DXE_SMM_DRIVER");
785 v
.add("UEFI_DRIVER");
786 v
.add("UEFI_APPLICATION");
787 v
.add("USER_DEFINED");
788 iCheckBoxListModules
.setAllItems(v
);
790 return iCheckBoxListModules
;
793 private String
vectorToString(Vector
<String
> v
) {
795 for (int i
= 0; i
< v
.size(); ++i
) {
802 private JScrollPane
getJScrollPane1Arch() {
803 if (jScrollPane1Arch
== null) {
804 jScrollPane1Arch
= new JScrollPane();
805 jScrollPane1Arch
.setBounds(new java
.awt
.Rectangle(218,170,293,73));
806 jScrollPane1Arch
.setPreferredSize(new java
.awt
.Dimension(320, 80));
807 jScrollPane1Arch
.setViewportView(getICheckBoxList());
809 return jScrollPane1Arch
;
812 * This method initializes iCheckBoxList
814 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
816 private ICheckBoxList
getICheckBoxList() {
817 if (iCheckBoxList
== null) {
818 iCheckBoxList
= new ICheckBoxList();
819 iCheckBoxList
.setBounds(new java
.awt
.Rectangle(218,171,292,66));
820 Vector
<String
> v
= new Vector
<String
>();
827 iCheckBoxList
.setAllItems(v
);
829 return iCheckBoxList
;
833 * This method initializes jComboBox
835 * @return javax.swing.JComboBox
837 private JComboBox
getJComboBox() {
838 if (jComboBox
== null) {
839 jComboBox
= new JComboBox();
840 jComboBox
.setPreferredSize(new java
.awt
.Dimension(31,20));
841 jComboBox
.setSize(new java
.awt
.Dimension(290,20));
842 jComboBox
.setLocation(new java
.awt
.Point(218,111));
843 jComboBox
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
844 public void focusGained(java
.awt
.event
.FocusEvent e
) {
845 if (jTextFieldAdd
.getText().length() == 0) {
848 jComboBox
.removeAllItems();
849 getLibInstances(jTextFieldAdd
.getText());
850 Set
<String
> libNames
= libNameGuidMap
.keySet();
851 Iterator
<String
> si
= libNames
.iterator();
852 while(si
.hasNext()) {
853 jComboBox
.addItem(si
.next());
862 private void getLibInstances(String libClass
){
863 libNameGuidMap
.clear();
865 GlobalData
.initInfo("Tools" + File
.separator
+ "Conf" + File
.separator
+ "FrameworkDatabase.db", System
.getenv("WORKSPACE"));
867 Set
<PackageIdentification
> spi
= GlobalData
.getPackageList();
868 Iterator ispi
= spi
.iterator();
870 while (ispi
.hasNext()) {
871 PackageIdentification pi
= (PackageIdentification
) ispi
.next();
873 Set
<ModuleIdentification
> smi
= GlobalData
.getModules(pi
);
874 Iterator ismi
= smi
.iterator();
875 while (ismi
.hasNext()) {
876 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
877 Map
<String
, XmlObject
> m
= GlobalData
.getNativeMsa(mi
);
878 SurfaceAreaQuery
.setDoc(m
);
879 String
[] classProduced
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED");
880 for (int i
= 0; i
< classProduced
.length
; ++i
) {
881 if (classProduced
[i
].equals(libClass
)) {
882 libNameGuidMap
.put(mi
.getName(), mi
.getGuid());
889 JOptionPane
.showMessageDialog(frame
, "Search Instances Fail.");
894 private String
nameToGuid(String name
) {
896 if (!libNameGuidMap
.containsKey(name
)) {
900 s
= libNameGuidMap
.get(name
);
904 private String
guidToName(String guid
){
906 if (!libNameGuidMap
.containsValue(guid
)) {
909 Set
<String
> key
= libNameGuidMap
.keySet();
910 Iterator
<String
> is
= key
.iterator();
911 while(is
.hasNext()) {
913 if (libNameGuidMap
.get(s
).equals(guid
)) {