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(500,419));
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("Recommended Instance");
226 model
.addColumn("Version");
227 model
.addColumn("Sup. Arch");
228 model
.addColumn("Mod. Types");
230 Vector
<String
> vArch
= new Vector
<String
>();
237 jTable
.getColumnModel().getColumn(cnSupArch
).setCellEditor(new ListEditor(vArch
));
239 Vector
<String
> vModule
= new Vector
<String
>();
242 vModule
.add("PEI_CORE");
244 vModule
.add("DXE_CORE");
245 vModule
.add("DXE_DRIVER");
246 vModule
.add("DXE_RUNTIME_DRIVER");
247 vModule
.add("DXE_SAL_DRIVER");
248 vModule
.add("DXE_SMM_DRIVER");
249 vModule
.add("UEFI_DRIVER");
250 vModule
.add("UEFI_APPLICATION");
251 vModule
.add("USER_DEFINED");
253 jTable
.getColumnModel().getColumn(cnSupMod
).setCellEditor(new ListEditor(vModule
));
255 jTable
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
256 jTable
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
257 public void valueChanged(ListSelectionEvent e
) {
258 if (e
.getValueIsAdjusting()){
261 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
262 if (lsm
.isSelectionEmpty()) {
266 selectedRow
= lsm
.getMinSelectionIndex();
271 jTable
.getModel().addTableModelListener(this);
278 public void tableChanged(TableModelEvent arg0
) {
279 // TODO Auto-generated method stub
280 int row
= arg0
.getFirstRow();
281 int column
= arg0
.getColumn();
282 TableModel m
= (TableModel
)arg0
.getSource();
283 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
) + "";
289 if (m
.getValueAt(row
, cnRecInstName
) != null) {
290 name
= m
.getValueAt(row
, cnRecInstName
).toString();
293 if (m
.getValueAt(row
, cnRecInstVer
) != null){
294 ver
= m
.getValueAt(row
, cnRecInstVer
).toString();
297 if (m
.getValueAt(row
, cnSupArch
) != null) {
298 arch
= m
.getValueAt(row
, cnSupArch
).toString();
300 String module
= null;
301 if (m
.getValueAt(row
, cnSupMod
) != null) {
302 module
= m
.getValueAt(row
, cnSupMod
).toString();
304 String
[] rowData
= {lib
, hdr
, hlp
, name
, ver
};
305 if (!dataValidation(rowData
)) {
310 if (name
!= null && name
.length() > 0) {
311 getLibInstances(lib
);
312 guid
= nameToGuid(name
);
315 String
[] sa
= new String
[7];
316 sfc
.getSpdLibClassDeclaration(sa
, row
);
317 Object cellData
= m
.getValueAt(row
, column
);
318 if (cellData
== null) {
321 if (column
== cnRecInstName
) {
323 if (sa
[cnRecInstName
] == null) {
328 if (guid
.equals(sa
[cnRecInstName
])) {
334 if (cellData
.equals(sa
[column
])) {
337 if (cellData
.toString().length() == 0 && sa
[column
] == null) {
341 docConsole
.setSaved(false);
342 sfc
.updateSpdLibClass(row
, lib
, hdr
, hlp
, guid
, ver
, arch
, module
);
347 This method initializes jButtonAdd
349 @return javax.swing.JButton
351 private JButton
getJButtonAdd() {
352 if (jButtonAdd
== null) {
353 jButtonAdd
= new JButton();
354 jButtonAdd
.setText("Add");
355 jButtonAdd
.setSize(new java
.awt
.Dimension(99,20));
356 jButtonAdd
.setBounds(new java
.awt
.Rectangle(321,326,99,20));
357 jButtonAdd
.addActionListener(this);
363 This method initializes jButtonRemove
365 @return javax.swing.JButton
367 private JButton
getJButtonRemove() {
368 if (jButtonRemove
== null) {
369 jButtonRemove
= new JButton();
370 jButtonRemove
.setText("Remove");
371 jButtonRemove
.setSize(new java
.awt
.Dimension(99,20));
372 jButtonRemove
.setBounds(new java
.awt
.Rectangle(424,326,99,20));
373 jButtonRemove
.addActionListener(this);
375 return jButtonRemove
;
379 This method initializes jButtonRemoveAll
381 @return javax.swing.JButton
383 private JButton
getJButtonRemoveAll() {
384 if (jButtonRemoveAll
== null) {
385 jButtonRemoveAll
= new JButton();
386 jButtonRemoveAll
.setText("Remove All");
387 jButtonRemoveAll
.setSize(new java
.awt
.Dimension(99,20));
388 jButtonRemoveAll
.setBounds(new java
.awt
.Rectangle(527,326,99,20));
389 jButtonRemoveAll
.addActionListener(this);
391 return jButtonRemoveAll
;
395 This is the default constructor
397 public SpdLibClassDecls() {
404 public SpdLibClassDecls(PackageSurfaceAreaDocument
.PackageSurfaceArea inPsa
){
406 sfc
= new SpdFileContents(inPsa
);
410 public SpdLibClassDecls(OpeningPackageType opt
) {
411 this(opt
.getXmlSpd());
415 This method initializes this
419 private void init() {
421 this.setContentPane(getJContentPane());
422 this.setTitle("Library Class Declarations");
423 this.setBounds(new java
.awt
.Rectangle(0, 0, 500, 370));
424 this.setVisible(true);
425 this.addInternalFrameListener(new InternalFrameAdapter(){
426 public void internalFrameDeactivated(InternalFrameEvent e
){
427 if (jTable
.isEditing()) {
428 jTable
.getCellEditor().stopCellEditing();
435 private void init(SpdFileContents sfc
) {
436 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
440 // initialize table using SpdFileContents object
442 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][7];
443 sfc
.getSpdLibClassDeclarations(saa
);
445 while (i
< saa
.length
) {
446 if (saa
[i
][3] != null && saa
[i
][3].length() > 0) {
447 getLibInstances(saa
[i
][0]);
448 saa
[i
][3] = guidToName(saa
[i
][3]);
451 model
.addRow(saa
[i
]);
455 private JScrollPane
getJContentPane(){
456 if (topScrollPane
== null){
457 topScrollPane
= new JScrollPane();
458 // topScrollPane.setSize(new java.awt.Dimension(634,590));
459 topScrollPane
.setViewportView(getJContentPane1());
461 return topScrollPane
;
464 This method initializes jContentPane
466 @return javax.swing.JPanel
468 private JPanel
getJContentPane1() {
469 if (jContentPane
== null) {
471 jStarLabel1
= new StarLabel();
472 jStarLabel1
.setLocation(new java
.awt
.Point(1,7));
473 jLabel1ClassName
= new JLabel();
474 jLabel1ClassName
.setBounds(new java
.awt
.Rectangle(16,6,82,20));
475 jLabel1ClassName
.setText("Library Class");
478 starLabel
= new StarLabel();
479 starLabel
.setBounds(new java
.awt
.Rectangle(1,33,10,20));
480 jLabel2HelpText
= new JLabel();
481 jLabel2HelpText
.setBounds(new java
.awt
.Rectangle(16,33,82,20));
482 jLabel2HelpText
.setText("Help Text");
485 jStarLabel2
= new StarLabel();
486 jStarLabel2
.setLocation(new java
.awt
.Point(1,74));
487 jLabelHdr
= new JLabel();
488 jLabelHdr
.setBounds(new java
.awt
.Rectangle(14,74,199,22));
489 jLabelHdr
.setText("Include Header for Specified Class");
491 jLabel6SupModList
= new JLabel();
492 jLabel6SupModList
.setBounds(new java
.awt
.Rectangle(16,252,108,16));
493 jLabel6SupModList
.setText("Supported Module");
494 jLabel6SupModList
.setEnabled(true);
496 jLabel5SupArchList
= new JLabel();
497 jLabel5SupArchList
.setBounds(new java
.awt
.Rectangle(15,169,93,16));
498 jLabel5SupArchList
.setText("Supported Arch");
499 jLabel5SupArchList
.setEnabled(true);
500 jLabel4RecInstVer
= new JLabel();
501 jLabel4RecInstVer
.setBounds(new java
.awt
.Rectangle(16,138,196,16));
502 jLabel4RecInstVer
.setEnabled(true);
503 jLabel4RecInstVer
.setText("Recommended Instance Version");
504 jLabel3RecInstName
= new JLabel();
505 jLabel3RecInstName
.setBounds(new java
.awt
.Rectangle(17,112,195,16));
506 jLabel3RecInstName
.setEnabled(true);
507 jLabel3RecInstName
.setText("Recommended Instance Name");
509 jContentPane
= new JPanel();
510 jContentPane
.setPreferredSize(new Dimension(680, 600));
511 jContentPane
.setLayout(null);
512 jContentPane
.add(jLabelHdr
, null);
513 jContentPane
.add(jStarLabel1
, null);
514 jContentPane
.add(jStarLabel2
, null);
515 jContentPane
.add(getJTextFieldAdd(), null);
516 jContentPane
.add(getJComboBoxSelect(), null);
517 jContentPane
.add(getJScrollPane(), null);
518 jContentPane
.add(getJButtonAdd(), null);
519 jContentPane
.add(getJButtonRemove(), null);
520 jContentPane
.add(getJButtonRemoveAll(), null);
522 jContentPane
.add(getJTextFieldHdr(), null);
523 jContentPane
.add(getJButtonBrowse(), null);
524 jContentPane
.add(jLabel1ClassName
, null);
525 jContentPane
.add(starLabel
, null);
526 jContentPane
.add(jLabel2HelpText
, null);
527 jContentPane
.add(getJTextFieldHelp(), null);
529 jContentPane
.add(jLabel3RecInstName
, null);
530 jContentPane
.add(getJTextField1RecInstName(), null);
531 jContentPane
.add(jLabel4RecInstVer
, null);
532 jContentPane
.add(getJTextField2RecInstVer(), null);
533 jContentPane
.add(jLabel5SupArchList
, null);
534 jContentPane
.add(jLabel6SupModList
, null);
536 jContentPane
.add(getJScrollPaneModules(), null);
537 jContentPane
.add(getJScrollPane1Arch(), null);
538 jContentPane
.add(getJComboBox(), null);
546 fill ComboBoxes with pre-defined contents
548 private void initFrame() {
549 jComboBoxSelect
.addItem("BaseCpuICacheFlush");
550 jComboBoxSelect
.addItem("BaseDebugLibNull");
551 jComboBoxSelect
.addItem("BaseDebugLibReportStatusCode");
552 jComboBoxSelect
.addItem("BaseIoLibIntrinsic");
553 jComboBoxSelect
.addItem("BaseLib");
554 jComboBoxSelect
.addItem("BaseMemoryLib");
555 jComboBoxSelect
.addItem("BaseMemoryLibMmx");
556 jComboBoxSelect
.addItem("BaseMemoryLibSse2");
557 jComboBoxSelect
.addItem("BasePeCoffGetEntryPointLib");
558 jComboBoxSelect
.addItem("BasePeCoffLib");
559 jComboBoxSelect
.addItem("BasePrintLib");
560 jComboBoxSelect
.addItem("BaseReportStatusCodeLibNull");
561 jComboBoxSelect
.addItem("CommonPciCf8Lib");
562 jComboBoxSelect
.addItem("CommonPciExpressLib");
563 jComboBoxSelect
.addItem("CommonPciLibCf8");
564 jComboBoxSelect
.addItem("CommonPciLibPciExpress");
565 jComboBoxSelect
.addItem("DxeCoreEntryPoint");
566 jComboBoxSelect
.addItem("DxeHobLib");
567 jComboBoxSelect
.addItem("DxeIoLibCpuIo");
568 jComboBoxSelect
.addItem("DxeLib");
569 jComboBoxSelect
.addItem("DxePcdLib");
570 jComboBoxSelect
.addItem("DxeReportStatusCodeLib");
571 jComboBoxSelect
.addItem("DxeServicesTableLib");
572 jComboBoxSelect
.addItem("PeiCoreEntryPoint");
573 jComboBoxSelect
.addItem("PeiMemoryLib");
574 jComboBoxSelect
.addItem("PeimEntryPoint");
575 jComboBoxSelect
.addItem("PeiReportStatusCodeLib");
576 jComboBoxSelect
.addItem("PeiServicesTablePointerLib");
577 jComboBoxSelect
.addItem("PeiServicesTablePointerLibMm7");
578 jComboBoxSelect
.addItem("UefiDebugLibConOut");
579 jComboBoxSelect
.addItem("UefiDebugLibStdErr");
580 jComboBoxSelect
.addItem("UefiDriverEntryPointMultiple");
581 jComboBoxSelect
.addItem("UefiDriverEntryPointSingle");
582 jComboBoxSelect
.addItem("UefiDriverEntryPointSingleUnload");
583 jComboBoxSelect
.addItem("UefiDriverModelLib");
584 jComboBoxSelect
.addItem("UefiDriverModelLibNoConfigNoDiag");
585 jComboBoxSelect
.addItem("UefiLib");
586 jComboBoxSelect
.addItem("UefiMemoryLib");
591 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
593 public void actionPerformed(ActionEvent arg0
) {
595 if (arg0
.getSource() == jButtonAdd
) {
597 //ToDo: check before add
598 // LAH WAS String[] row = {null, null, null, jComboBox.getSelectedItem()+"", jTextField2RecInstVer.getText(), null, null};
599 String
[] row
= {null, null, null, null, null, null, null};
600 row
[cnClassName
] = jTextFieldAdd
.getText();
601 row
[cnHdrFile
] = jTextFieldHdr
.getText().replace('\\', '/');
602 row
[cnHelpText
] = jTextFieldHelp
.getText();
603 row
[cnRecInstName
] = jComboBox
.getSelectedItem()+"";
604 row
[cnRecInstVer
] = jTextField2RecInstVer
.getText();
605 row
[cnSupArch
] = vectorToString(iCheckBoxList
.getAllCheckedItemsString());
606 if (row
[cnSupArch
].length() == 0) {
607 row
[cnSupArch
] = null;
609 row
[cnSupMod
] = vectorToString(iCheckBoxListModules
.getAllCheckedItemsString());
610 if (row
[cnSupMod
].length() == 0){
611 row
[cnSupMod
] = null;
613 if (!dataValidation(row
)) {
617 //convert to GUID before storing recommended lib instance.
619 getLibInstances(row
[cnClassName
]);
620 String recommendGuid
= nameToGuid(row
[cnRecInstName
]);
622 sfc
.genSpdLibClassDeclarations(row
[cnClassName
], recommendGuid
, row
[cnHdrFile
], row
[cnHelpText
], row
[cnSupArch
], null, null, row
[cnRecInstVer
], null, row
[cnSupMod
]);
624 jTable
.changeSelection(model
.getRowCount()-1, 0, false, false);
625 docConsole
.setSaved(false);
628 // remove selected line
630 if (arg0
.getSource() == jButtonRemove
) {
631 if (jTable
.isEditing()){
632 jTable
.getCellEditor().stopCellEditing();
634 int rowSelected
= selectedRow
;
635 if (rowSelected
>= 0) {
636 model
.removeRow(rowSelected
);
637 docConsole
.setSaved(false);
638 sfc
.removeSpdLibClass(rowSelected
);
642 if (arg0
.getSource() == jButtonRemoveAll
) {
643 if (model
.getRowCount() == 0) {
646 docConsole
.setSaved(false);
647 model
.setRowCount(0);
648 sfc
.removeSpdLibClass();
652 private boolean dataValidation(String
[] row
) {
653 if (!DataValidation
.isKeywordType(row
[cnClassName
])) {
654 JOptionPane
.showMessageDialog(frame
, "Library Class is NOT KeyWord Type.");
657 if (!DataValidation
.isPathAndFilename(row
[cnHdrFile
])) {
658 JOptionPane
.showMessageDialog(frame
, "Include Header is NOT PathAndFilename Type.");
661 if (row
[cnHelpText
].length() == 0) {
662 JOptionPane
.showMessageDialog(frame
, "Help Text Must NOT be empty.");
665 if (row
[cnRecInstVer
] != null && row
[cnRecInstVer
].length() > 0) {
666 if (row
[cnRecInstName
] == null || row
[cnRecInstName
].length() == 0) {
667 JOptionPane
.showMessageDialog(frame
, "Recommended Instance Version must associate with Instance Name.");
671 if (!DataValidation
.isVersionDataType(row
[cnRecInstVer
])) {
672 JOptionPane
.showMessageDialog(frame
, "Recommended Instance Version is NOT VersionDataType.");
679 Add contents in list to sfc
681 protected void save() {
686 This method initializes jTextField
688 @return javax.swing.JTextField
690 private JTextField
getJTextFieldHdr() {
691 if (jTextFieldHdr
== null) {
692 jTextFieldHdr
= new JTextField();
693 jTextFieldHdr
.setBounds(new java
.awt
.Rectangle(218,75,305,21));
694 jTextFieldHdr
.setPreferredSize(new java
.awt
.Dimension(260,20));
696 return jTextFieldHdr
;
700 This method initializes jButtonBrowse
702 @return javax.swing.JButton
704 private JButton
getJButtonBrowse() {
705 if (jButtonBrowse
== null) {
706 jButtonBrowse
= new JButton();
707 jButtonBrowse
.setBounds(new java
.awt
.Rectangle(527,75,90,20));
708 jButtonBrowse
.setText("Browse");
709 jButtonBrowse
.setPreferredSize(new java
.awt
.Dimension(99,20));
710 jButtonBrowse
.addActionListener(new AbstractAction() {
715 private static final long serialVersionUID
= 1L;
717 public void actionPerformed(ActionEvent arg0
) {
719 // Select files from current pkg
721 String dirPrefix
= Tools
.dirForNewSpd
.substring(0, Tools
.dirForNewSpd
.lastIndexOf(File
.separator
));
722 JFileChooser chooser
= new JFileChooser(dirPrefix
);
724 String headerDest
= null;
726 chooser
.setMultiSelectionEnabled(false);
727 chooser
.setFileSelectionMode(JFileChooser
.FILES_AND_DIRECTORIES
);
728 int retval
= chooser
.showOpenDialog(frame
);
729 if (retval
== JFileChooser
.APPROVE_OPTION
) {
731 theFile
= chooser
.getSelectedFile();
732 String file
= theFile
.getPath();
733 if (!file
.startsWith(dirPrefix
)) {
734 JOptionPane
.showMessageDialog(frame
, "You can only select files in current package!");
744 headerDest
= theFile
.getPath();
745 int fileIndex
= headerDest
.indexOf(System
.getProperty("file.separator"), dirPrefix
.length());
746 jTextFieldHdr
.setText(headerDest
.substring(fileIndex
+ 1).replace('\\', '/'));
752 return jButtonBrowse
;
755 public void componentResized(ComponentEvent arg0
) {
756 int intPreferredWidth
= 500;
758 resizeComponentWidth(this.jTextFieldAdd
, this.getWidth(), intPreferredWidth
);
759 resizeComponentWidth(this.jTextFieldHelp
, this.getWidth(), intPreferredWidth
);
760 resizeComponentWidth(this.jScrollPane
, this.getWidth(), intPreferredWidth
-10);
764 * This method initializes jTextFieldHelp
766 * @return javax.swing.JTextField
768 private JTextField
getJTextFieldHelp() {
769 if (jTextFieldHelp
== null) {
770 jTextFieldHelp
= new JTextField();
771 jTextFieldHelp
.setBounds(new java
.awt
.Rectangle(122,33,390,20));
772 jTextFieldHelp
.setPreferredSize(new java
.awt
.Dimension(260,20));
774 return jTextFieldHelp
;
778 * This method initializes jTextField1RecInstName
780 * @return javax.swing.JTextField
782 private JTextField
getJTextField1RecInstName() {
783 if (jTextField1RecInstName
== null) {
784 jTextField1RecInstName
= new JTextField();
785 jTextField1RecInstName
.setBounds(new java
.awt
.Rectangle(218,110,291,20));
786 jTextField1RecInstName
.setEnabled(true);
787 jTextField1RecInstName
.setVisible(false);
789 return jTextField1RecInstName
;
793 * This method initializes jTextField2RecInstVer
795 * @return javax.swing.JTextField
797 private JTextField
getJTextField2RecInstVer() {
798 if (jTextField2RecInstVer
== null) {
799 jTextField2RecInstVer
= new JTextField();
800 jTextField2RecInstVer
.setBounds(new java
.awt
.Rectangle(218,135,292,20));
801 jTextField2RecInstVer
.setEnabled(true);
803 return jTextField2RecInstVer
;
806 private JScrollPane
getJScrollPaneModules() {
807 if (jScrollPaneModules
== null) {
808 jScrollPaneModules
= new JScrollPane();
809 jScrollPaneModules
.setBounds(new java
.awt
.Rectangle(218,245,293,73));
810 jScrollPaneModules
.setPreferredSize(new java
.awt
.Dimension(320, 80));
811 jScrollPaneModules
.setViewportView(getICheckBoxListSupportedModules());
813 return jScrollPaneModules
;
816 private ICheckBoxList
getICheckBoxListSupportedModules() {
817 if (iCheckBoxListModules
== null) {
818 iCheckBoxListModules
= new ICheckBoxList();
819 iCheckBoxListModules
.setBounds(new java
.awt
.Rectangle(218,246,292,73));
820 Vector
<String
> v
= new Vector
<String
>();
827 v
.add("DXE_RUNTIME_DRIVER");
828 v
.add("DXE_SAL_DRIVER");
829 v
.add("DXE_SMM_DRIVER");
830 v
.add("UEFI_DRIVER");
831 v
.add("UEFI_APPLICATION");
832 v
.add("USER_DEFINED");
833 iCheckBoxListModules
.setAllItems(v
);
835 return iCheckBoxListModules
;
838 private String
vectorToString(Vector
<String
> v
) {
840 for (int i
= 0; i
< v
.size(); ++i
) {
847 private JScrollPane
getJScrollPane1Arch() {
848 if (jScrollPane1Arch
== null) {
849 jScrollPane1Arch
= new JScrollPane();
850 jScrollPane1Arch
.setBounds(new java
.awt
.Rectangle(218,170,293,73));
851 jScrollPane1Arch
.setPreferredSize(new java
.awt
.Dimension(320, 80));
852 jScrollPane1Arch
.setViewportView(getICheckBoxList());
854 return jScrollPane1Arch
;
857 * This method initializes iCheckBoxList
859 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
861 private ICheckBoxList
getICheckBoxList() {
862 if (iCheckBoxList
== null) {
863 iCheckBoxList
= new ICheckBoxList();
864 iCheckBoxList
.setBounds(new java
.awt
.Rectangle(218,171,292,66));
865 Vector
<String
> v
= new Vector
<String
>();
872 iCheckBoxList
.setAllItems(v
);
874 return iCheckBoxList
;
878 * This method initializes jComboBox
880 * @return javax.swing.JComboBox
882 private JComboBox
getJComboBox() {
883 if (jComboBox
== null) {
884 jComboBox
= new JComboBox();
885 jComboBox
.setPreferredSize(new java
.awt
.Dimension(31,20));
886 jComboBox
.setSize(new java
.awt
.Dimension(290,20));
887 jComboBox
.setLocation(new java
.awt
.Point(218,111));
888 jComboBox
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
889 public void focusGained(java
.awt
.event
.FocusEvent e
) {
890 if (jTextFieldAdd
.getText().length() == 0) {
893 jComboBox
.removeAllItems();
894 getLibInstances(jTextFieldAdd
.getText());
895 Set
<String
> libNames
= libNameGuidMap
.keySet();
896 Iterator
<String
> si
= libNames
.iterator();
897 while(si
.hasNext()) {
898 jComboBox
.addItem(si
.next());
907 private void getLibInstances(String libClass
){
908 libNameGuidMap
.clear();
910 GlobalData
.initInfo("Tools" + File
.separator
+ "Conf" + File
.separator
+ "FrameworkDatabase.db", System
.getenv("WORKSPACE"));
912 Set
<PackageIdentification
> spi
= GlobalData
.getPackageList();
913 Iterator ispi
= spi
.iterator();
915 while (ispi
.hasNext()) {
916 PackageIdentification pi
= (PackageIdentification
) ispi
.next();
918 Set
<ModuleIdentification
> smi
= GlobalData
.getModules(pi
);
919 Iterator ismi
= smi
.iterator();
920 while (ismi
.hasNext()) {
921 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
922 Map
<String
, XmlObject
> m
= GlobalData
.getNativeMsa(mi
);
923 SurfaceAreaQuery
.setDoc(m
);
924 String
[] classProduced
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED");
925 for (int i
= 0; i
< classProduced
.length
; ++i
) {
926 if (classProduced
[i
].equals(libClass
)) {
927 libNameGuidMap
.put(mi
.getName(), mi
.getGuid());
934 JOptionPane
.showMessageDialog(frame
, "Search Instances Fail.");
939 private String
nameToGuid(String name
) {
941 if (!libNameGuidMap
.containsKey(name
)) {
942 JOptionPane
.showMessageDialog(frame
, "Recommended Instance NOT exists.");
946 s
= libNameGuidMap
.get(name
);
950 private String
guidToName(String guid
){
952 if (!libNameGuidMap
.containsValue(guid
)) {
955 Set
<String
> key
= libNameGuidMap
.keySet();
956 Iterator
<String
> is
= key
.iterator();
957 while(is
.hasNext()) {
959 if (libNameGuidMap
.get(s
).equals(guid
)) {