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
;
22 import java
.util
.Vector
;
24 import javax
.swing
.AbstractAction
;
25 import javax
.swing
.JFileChooser
;
26 import javax
.swing
.JOptionPane
;
27 import javax
.swing
.JPanel
;
28 import javax
.swing
.JTable
;
29 import javax
.swing
.JTextField
;
30 import javax
.swing
.JComboBox
;
31 import javax
.swing
.JLabel
;
32 import javax
.swing
.JScrollPane
;
33 import javax
.swing
.JButton
;
34 import javax
.swing
.JFrame
;
35 import javax
.swing
.ListSelectionModel
;
36 import javax
.swing
.event
.InternalFrameAdapter
;
37 import javax
.swing
.event
.InternalFrameEvent
;
38 import javax
.swing
.event
.ListSelectionEvent
;
39 import javax
.swing
.event
.ListSelectionListener
;
40 import javax
.swing
.event
.TableModelEvent
;
41 import javax
.swing
.event
.TableModelListener
;
42 import javax
.swing
.table
.DefaultTableModel
;
43 import javax
.swing
.table
.TableModel
;
44 import org
.tianocore
.PackageSurfaceAreaDocument
;
45 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
46 import org
.tianocore
.frameworkwizard
.common
.GlobalData
;
47 import org
.tianocore
.frameworkwizard
.common
.Tools
;
48 import org
.tianocore
.frameworkwizard
.common
.Identifications
.OpeningPackageType
;
49 import org
.tianocore
.frameworkwizard
.common
.ui
.IInternalFrame
;
50 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
51 import org
.tianocore
.frameworkwizard
.common
.ui
.iCheckBoxList
.ICheckBoxList
;
52 import org
.tianocore
.frameworkwizard
.platform
.ui
.ListEditor
;
53 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
54 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
58 GUI for create library definition elements of spd file.
60 @since PackageEditor 1.0
62 public class SpdLibClassDecls
extends IInternalFrame
implements TableModelListener
{
66 private static final long serialVersionUID
= 1L;
70 private JTable jTable
= null;
72 private DefaultTableModel model
= null;
74 private JPanel jContentPane
= null;
76 private JTextField jTextFieldClass
= null;
78 private JComboBox jComboBoxSelect
= null;
80 private JScrollPane jScrollPane
= null;
82 private JButton jButtonAdd
= null;
84 private JButton jButtonRemove
= null;
86 private JButton jButtonRemoveAll
= null;
88 private JLabel jLabelHdr
= null;
90 private JTextField jTextFieldHdr
= null;
92 private JButton jButtonBrowse
= null;
94 private StarLabel jStarLabel1
= null;
96 private StarLabel jStarLabel2
= null;
98 private SpdFileContents sfc
= null;
100 private OpeningPackageType docConsole
= null;
102 private JLabel jLabel1ClassName
= null;
104 private JScrollPane topScrollPane
= null; // @jve:decl-index=0:visual-constraint="10,53"
106 private int selectedRow
= -1;
108 private StarLabel starLabel
= null;
110 private JLabel jLabel2HelpText
= null;
112 private JTextField jTextFieldHelp
= null;
114 private JLabel jLabel3RecInstName
= null;
116 private JTextField jTextField1RecInstName
= null;
118 private JLabel jLabel4RecInstVer
= null;
120 private JTextField jTextField2RecInstVer
= null;
122 private JLabel jLabel5SupArchList
= null;
124 private JLabel jLabel6SupModList
= null;
126 private JScrollPane jScrollPaneModules
= null;
128 private JScrollPane jScrollPane1Arch
= null;
130 private ICheckBoxList iCheckBoxListModules
= null;
132 private ICheckBoxList iCheckBoxListArch
= null;
134 private JComboBox jComboBox
= null;
136 private int cnClassName
= 0;
137 private int cnHdrFile
= 1;
138 private int cnHelpText
= 2;
139 private int cnRecInstName
= 3;
140 private int cnRecInstVer
= 4;
141 private int cnSupArch
= 5;
142 private int cnSupMod
= 6;
144 HashMap
<String
, String
> libNameGuidMap
= new HashMap
<String
, String
>();
148 This method initializes this
151 private void initialize() {
153 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
158 This method initializes jTextFieldAdd
160 @return javax.swing.JTextField
162 private JTextField
getJTextFieldClass() {
163 if (jTextFieldClass
== null) {
164 jTextFieldClass
= new JTextField();
165 jTextFieldClass
.setBounds(new java
.awt
.Rectangle(122,6,390,20));
166 jTextFieldClass
.setPreferredSize(new java
.awt
.Dimension(260,20));
167 jTextFieldClass
.setEnabled(true);
169 return jTextFieldClass
;
173 This method initializes jComboBoxSelect
175 @return javax.swing.JComboBox
177 private JComboBox
getJComboBoxSelect() {
178 if (jComboBoxSelect
== null) {
179 jComboBoxSelect
= new JComboBox();
180 jComboBoxSelect
.setBounds(new java
.awt
.Rectangle(220, 10, 260, 20));
181 jComboBoxSelect
.setPreferredSize(new java
.awt
.Dimension(260,22));
182 jComboBoxSelect
.setEnabled(true);
183 jComboBoxSelect
.setVisible(false);
185 return jComboBoxSelect
;
189 This method initializes jScrollPane
191 @return javax.swing.JScrollPane
193 Used for the Table of Library Classes that are provided by this package
196 private JScrollPane
getJScrollPane() {
197 if (jScrollPane
== null) {
198 jScrollPane
= new JScrollPane();
199 jScrollPane
.setBounds(new java
.awt
.Rectangle(12,351,400,253));
200 jScrollPane
.setViewportView(getJTable());
206 This method initializes jTable
208 @return javax.swing.JTable
210 private JTable
getJTable() {
211 if (jTable
== null) {
212 model
= new DefaultTableModel();
213 jTable
= new JTable(model
);
214 jTable
.setRowHeight(20);
215 jTable
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
216 jTable
.setColumnSelectionAllowed(false);
217 model
.addColumn("Class Name");
218 model
.addColumn("Header");
219 model
.addColumn("Help Text");
220 model
.addColumn("Recommended Instance");
221 model
.addColumn("Version");
222 model
.addColumn("Supported Architectures");
223 model
.addColumn("Supported Module Types");
225 Vector
<String
> vArch
= new Vector
<String
>();
232 jTable
.getColumnModel().getColumn(cnSupArch
).setCellEditor(new ListEditor(vArch
));
234 Vector
<String
> vModule
= new Vector
<String
>();
237 vModule
.add("PEI_CORE");
239 vModule
.add("DXE_CORE");
240 vModule
.add("DXE_DRIVER");
241 vModule
.add("DXE_RUNTIME_DRIVER");
242 vModule
.add("DXE_SAL_DRIVER");
243 vModule
.add("DXE_SMM_DRIVER");
244 vModule
.add("UEFI_DRIVER");
245 vModule
.add("UEFI_APPLICATION");
246 vModule
.add("USER_DEFINED");
248 jTable
.getColumnModel().getColumn(cnSupMod
).setCellEditor(new ListEditor(vModule
));
250 jTable
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
251 jTable
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
252 public void valueChanged(ListSelectionEvent e
) {
253 if (e
.getValueIsAdjusting()){
256 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
257 if (lsm
.isSelectionEmpty()) {
261 selectedRow
= lsm
.getMinSelectionIndex();
266 jTable
.getModel().addTableModelListener(this);
273 public void tableChanged(TableModelEvent arg0
) {
274 // TODO Auto-generated method stub
275 int row
= arg0
.getFirstRow();
276 int column
= arg0
.getColumn();
277 TableModel m
= (TableModel
)arg0
.getSource();
278 if (arg0
.getType() == TableModelEvent
.UPDATE
){
280 String lib
= m
.getValueAt(row
, cnClassName
) + "";
281 String hdr
= m
.getValueAt(row
, cnHdrFile
) + "";
282 String hlp
= m
.getValueAt(row
, cnHelpText
) + "";
284 if (m
.getValueAt(row
, cnRecInstName
) != null) {
285 name
= m
.getValueAt(row
, cnRecInstName
).toString();
288 if (m
.getValueAt(row
, cnRecInstVer
) != null){
289 ver
= m
.getValueAt(row
, cnRecInstVer
).toString();
292 if (m
.getValueAt(row
, cnSupArch
) != null) {
293 arch
= m
.getValueAt(row
, cnSupArch
).toString();
295 String module
= null;
296 if (m
.getValueAt(row
, cnSupMod
) != null) {
297 module
= m
.getValueAt(row
, cnSupMod
).toString();
299 String
[] rowData
= {lib
, hdr
, hlp
, name
, ver
};
300 if (!dataValidation(rowData
)) {
305 if (name
!= null && name
.length() > 0) {
306 getLibInstances(lib
);
307 guid
= nameToGuid(name
);
309 JOptionPane
.showMessageDialog(frame
, "Recommended Instance does not exist.");
314 String
[] sa
= new String
[7];
315 sfc
.getSpdLibClassDeclaration(sa
, row
);
316 Object cellData
= m
.getValueAt(row
, column
);
317 if (cellData
== null) {
320 if (column
== cnRecInstName
) {
322 if (sa
[cnRecInstName
] == null) {
327 if (guid
.equals(sa
[cnRecInstName
])) {
333 if (cellData
.equals(sa
[column
])) {
336 if (cellData
.toString().length() == 0 && sa
[column
] == null) {
340 docConsole
.setSaved(false);
341 sfc
.updateSpdLibClass(row
, lib
, hdr
, hlp
, guid
, ver
, arch
, module
);
346 This method initializes jButtonAdd
348 @return javax.swing.JButton
350 private JButton
getJButtonAdd() {
351 if (jButtonAdd
== null) {
352 jButtonAdd
= new JButton();
353 jButtonAdd
.setText("Add");
354 jButtonAdd
.setSize(new java
.awt
.Dimension(99,20));
355 jButtonAdd
.setBounds(new java
.awt
.Rectangle(321,326,99,20));
356 jButtonAdd
.addActionListener(this);
362 This method initializes jButtonRemove
364 @return javax.swing.JButton
366 private JButton
getJButtonRemove() {
367 if (jButtonRemove
== null) {
368 jButtonRemove
= new JButton();
369 jButtonRemove
.setText("Remove");
370 jButtonRemove
.setSize(new java
.awt
.Dimension(99,20));
371 jButtonRemove
.setBounds(new java
.awt
.Rectangle(424,326,99,20));
372 jButtonRemove
.addActionListener(this);
374 return jButtonRemove
;
378 This method initializes jButtonRemoveAll
380 @return javax.swing.JButton
382 private JButton
getJButtonRemoveAll() {
383 if (jButtonRemoveAll
== null) {
384 jButtonRemoveAll
= new JButton();
385 jButtonRemoveAll
.setText("Remove All");
386 jButtonRemoveAll
.setSize(new java
.awt
.Dimension(99,20));
387 jButtonRemoveAll
.setBounds(new java
.awt
.Rectangle(527,326,99,20));
388 jButtonRemoveAll
.addActionListener(this);
390 return jButtonRemoveAll
;
394 This is the default constructor
396 public SpdLibClassDecls() {
403 public SpdLibClassDecls(PackageSurfaceAreaDocument
.PackageSurfaceArea inPsa
){
405 sfc
= new SpdFileContents(inPsa
);
409 public SpdLibClassDecls(OpeningPackageType opt
) {
410 this(opt
.getXmlSpd());
414 This method initializes this
418 private void init() {
420 this.setContentPane(getJContentPane());
421 this.setTitle("Library Class Declarations");
422 this.setBounds(new java
.awt
.Rectangle(0, 0, 500, 370));
423 this.setVisible(true);
424 this.addInternalFrameListener(new InternalFrameAdapter(){
425 public void internalFrameDeactivated(InternalFrameEvent e
){
426 if (jTable
.isEditing()) {
427 jTable
.getCellEditor().stopCellEditing();
434 private void init(SpdFileContents sfc
) {
435 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
439 // initialize table using SpdFileContents object
441 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][7];
442 sfc
.getSpdLibClassDeclarations(saa
);
444 while (i
< saa
.length
) {
445 if (saa
[i
][3] != null && saa
[i
][3].length() > 0) {
446 getLibInstances(saa
[i
][0]);
447 saa
[i
][3] = guidToName(saa
[i
][3]);
450 model
.addRow(saa
[i
]);
454 private JScrollPane
getJContentPane(){
455 if (topScrollPane
== null){
456 topScrollPane
= new JScrollPane();
457 // topScrollPane.setSize(new java.awt.Dimension(634,590));
458 topScrollPane
.setViewportView(getJContentPane1());
460 return topScrollPane
;
463 This method initializes jContentPane
465 @return javax.swing.JPanel
467 private JPanel
getJContentPane1() {
468 if (jContentPane
== null) {
470 jStarLabel1
= new StarLabel();
471 jStarLabel1
.setLocation(new java
.awt
.Point(1,7));
472 jLabel1ClassName
= new JLabel();
473 jLabel1ClassName
.setBounds(new java
.awt
.Rectangle(16,6,82,20));
474 jLabel1ClassName
.setText("Library Class");
477 starLabel
= new StarLabel();
478 starLabel
.setBounds(new java
.awt
.Rectangle(1,33,10,20));
479 jLabel2HelpText
= new JLabel();
480 jLabel2HelpText
.setBounds(new java
.awt
.Rectangle(16,33,82,20));
481 jLabel2HelpText
.setText("Help Text");
484 jStarLabel2
= new StarLabel();
485 jStarLabel2
.setLocation(new java
.awt
.Point(1,74));
486 jLabelHdr
= new JLabel();
487 jLabelHdr
.setBounds(new java
.awt
.Rectangle(14,74,199,22));
488 jLabelHdr
.setText("Include Header for Specified Class");
490 jLabel6SupModList
= new JLabel();
491 jLabel6SupModList
.setBounds(new java
.awt
.Rectangle(16,252,108,16));
492 jLabel6SupModList
.setText("Supported Module");
493 jLabel6SupModList
.setEnabled(true);
495 jLabel5SupArchList
= new JLabel();
496 jLabel5SupArchList
.setBounds(new java
.awt
.Rectangle(15,169,93,16));
497 jLabel5SupArchList
.setText("Supported Arch");
498 jLabel5SupArchList
.setEnabled(true);
499 jLabel4RecInstVer
= new JLabel();
500 jLabel4RecInstVer
.setBounds(new java
.awt
.Rectangle(16,138,196,16));
501 jLabel4RecInstVer
.setEnabled(true);
502 jLabel4RecInstVer
.setText("Recommended Instance Version");
503 jLabel3RecInstName
= new JLabel();
504 jLabel3RecInstName
.setBounds(new java
.awt
.Rectangle(17,112,195,16));
505 jLabel3RecInstName
.setEnabled(true);
506 jLabel3RecInstName
.setText("Recommended Instance Name");
508 jContentPane
= new JPanel();
509 jContentPane
.setPreferredSize(new Dimension(680, 600));
510 jContentPane
.setLayout(null);
511 jContentPane
.add(jLabelHdr
, null);
512 jContentPane
.add(jStarLabel1
, null);
513 jContentPane
.add(jStarLabel2
, null);
514 jContentPane
.add(getJTextFieldClass(), null);
515 jContentPane
.add(getJComboBoxSelect(), null);
516 jContentPane
.add(getJScrollPane(), null);
517 jContentPane
.add(getJButtonAdd(), null);
518 jContentPane
.add(getJButtonRemove(), null);
519 jContentPane
.add(getJButtonRemoveAll(), null);
521 jContentPane
.add(getJTextFieldHdr(), null);
522 jContentPane
.add(getJButtonBrowse(), null);
523 jContentPane
.add(jLabel1ClassName
, null);
524 jContentPane
.add(starLabel
, null);
525 jContentPane
.add(jLabel2HelpText
, null);
526 jContentPane
.add(getJTextFieldHelp(), null);
528 jContentPane
.add(jLabel3RecInstName
, null);
529 jContentPane
.add(getJTextField1RecInstName(), null);
530 jContentPane
.add(jLabel4RecInstVer
, null);
531 jContentPane
.add(getJTextField2RecInstVer(), null);
532 jContentPane
.add(jLabel5SupArchList
, null);
533 jContentPane
.add(jLabel6SupModList
, null);
535 jContentPane
.add(getJScrollPaneModules(), null);
536 jContentPane
.add(getJScrollPane1Arch(), null);
537 jContentPane
.add(getJComboBox(), null);
545 fill ComboBoxes with pre-defined contents
547 private void initFrame() {
548 jComboBoxSelect
.addItem("BaseCpuICacheFlush");
549 jComboBoxSelect
.addItem("BaseDebugLibNull");
550 jComboBoxSelect
.addItem("BaseDebugLibReportStatusCode");
551 jComboBoxSelect
.addItem("BaseIoLibIntrinsic");
552 jComboBoxSelect
.addItem("BaseLib");
553 jComboBoxSelect
.addItem("BaseMemoryLib");
554 jComboBoxSelect
.addItem("BaseMemoryLibMmx");
555 jComboBoxSelect
.addItem("BaseMemoryLibSse2");
556 jComboBoxSelect
.addItem("BasePeCoffGetEntryPointLib");
557 jComboBoxSelect
.addItem("BasePeCoffLib");
558 jComboBoxSelect
.addItem("BasePrintLib");
559 jComboBoxSelect
.addItem("BaseReportStatusCodeLibNull");
560 jComboBoxSelect
.addItem("CommonPciCf8Lib");
561 jComboBoxSelect
.addItem("CommonPciExpressLib");
562 jComboBoxSelect
.addItem("CommonPciLibCf8");
563 jComboBoxSelect
.addItem("CommonPciLibPciExpress");
564 jComboBoxSelect
.addItem("DxeCoreEntryPoint");
565 jComboBoxSelect
.addItem("DxeHobLib");
566 jComboBoxSelect
.addItem("DxeIoLibCpuIo");
567 jComboBoxSelect
.addItem("DxeLib");
568 jComboBoxSelect
.addItem("DxePcdLib");
569 jComboBoxSelect
.addItem("DxeReportStatusCodeLib");
570 jComboBoxSelect
.addItem("DxeServicesTableLib");
571 jComboBoxSelect
.addItem("PeiCoreEntryPoint");
572 jComboBoxSelect
.addItem("PeiMemoryLib");
573 jComboBoxSelect
.addItem("PeimEntryPoint");
574 jComboBoxSelect
.addItem("PeiReportStatusCodeLib");
575 jComboBoxSelect
.addItem("PeiServicesTablePointerLib");
576 jComboBoxSelect
.addItem("PeiServicesTablePointerLibMm7");
577 jComboBoxSelect
.addItem("UefiDebugLibConOut");
578 jComboBoxSelect
.addItem("UefiDebugLibStdErr");
579 jComboBoxSelect
.addItem("UefiDriverEntryPointMultiple");
580 jComboBoxSelect
.addItem("UefiDriverEntryPointSingle");
581 jComboBoxSelect
.addItem("UefiDriverEntryPointSingleUnload");
582 jComboBoxSelect
.addItem("UefiDriverModelLib");
583 jComboBoxSelect
.addItem("UefiDriverModelLibNoConfigNoDiag");
584 jComboBoxSelect
.addItem("UefiLib");
585 jComboBoxSelect
.addItem("UefiMemoryLib");
590 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
592 public void actionPerformed(ActionEvent arg0
) {
594 if (arg0
.getSource() == jButtonAdd
) {
596 //ToDo: check before add
597 // LAH WAS String[] row = {null, null, null, jComboBox.getSelectedItem()+"", jTextField2RecInstVer.getText(), null, null};
598 String
[] row
= {null, null, null, null, null, null, null};
599 row
[cnClassName
] = jTextFieldClass
.getText();
600 row
[cnHdrFile
] = jTextFieldHdr
.getText().replace('\\', '/');
601 row
[cnHelpText
] = jTextFieldHelp
.getText();
602 row
[cnRecInstName
] = jComboBox
.getSelectedItem()+"";
603 row
[cnRecInstVer
] = jTextField2RecInstVer
.getText();
604 row
[cnSupArch
] = vectorToString(iCheckBoxListArch
.getAllCheckedItemsString());
605 if (row
[cnSupArch
].length() == 0) {
606 row
[cnSupArch
] = null;
608 row
[cnSupMod
] = vectorToString(iCheckBoxListModules
.getAllCheckedItemsString());
609 if (row
[cnSupMod
].length() == 0){
610 row
[cnSupMod
] = null;
612 if (!dataValidation(row
)) {
616 //convert to GUID before storing recommended lib instance.
618 getLibInstances(row
[cnClassName
]);
619 String recommendGuid
= nameToGuid(row
[cnRecInstName
]);
620 if (row
[cnRecInstName
].equals("null")) {
621 row
[cnRecInstName
] = null;
624 if (recommendGuid
== null) {
625 JOptionPane
.showMessageDialog(frame
, "Recommended Instance does not exist.");
630 sfc
.genSpdLibClassDeclarations(row
[cnClassName
], recommendGuid
, row
[cnHdrFile
], row
[cnHelpText
], row
[cnSupArch
], null, null, row
[cnRecInstVer
], null, row
[cnSupMod
]);
632 jTable
.changeSelection(model
.getRowCount()-1, 0, false, false);
633 docConsole
.setSaved(false);
636 // remove selected line
638 if (arg0
.getSource() == jButtonRemove
) {
639 if (jTable
.isEditing()){
640 jTable
.getCellEditor().stopCellEditing();
642 int rowSelected
= selectedRow
;
643 if (rowSelected
>= 0) {
644 model
.removeRow(rowSelected
);
645 docConsole
.setSaved(false);
646 sfc
.removeSpdLibClass(rowSelected
);
650 if (arg0
.getSource() == jButtonRemoveAll
) {
651 if (model
.getRowCount() == 0) {
654 docConsole
.setSaved(false);
655 model
.setRowCount(0);
656 sfc
.removeSpdLibClass();
660 private boolean dataValidation(String
[] row
) {
661 if (!DataValidation
.isKeywordType(row
[cnClassName
])) {
662 JOptionPane
.showMessageDialog(frame
, "Library Class name entered does not match KeyWord datatype.");
665 if (!DataValidation
.isPathAndFilename(row
[cnHdrFile
])) {
666 JOptionPane
.showMessageDialog(frame
, "Include Header does not match the PathAndFilename datatype.");
669 if (row
[cnHelpText
].length() == 0) {
670 JOptionPane
.showMessageDialog(frame
, "Help Text must be entered!");
673 if (row
[cnRecInstVer
] != null && row
[cnRecInstVer
].length() > 0) {
674 if (row
[cnRecInstName
] == null || row
[cnRecInstName
].length() == 0) {
675 JOptionPane
.showMessageDialog(frame
, "Recommended Instance Version must associate with the Instance Name.");
679 if (!DataValidation
.isVersionDataType(row
[cnRecInstVer
])) {
680 JOptionPane
.showMessageDialog(frame
, "Recommended Instance Version does not match Version datatype.");
687 Add contents in list to sfc
689 protected void save() {
694 This method initializes jTextField
696 @return javax.swing.JTextField
698 private JTextField
getJTextFieldHdr() {
699 if (jTextFieldHdr
== null) {
700 jTextFieldHdr
= new JTextField();
701 jTextFieldHdr
.setBounds(new java
.awt
.Rectangle(218,75,305,21));
702 jTextFieldHdr
.setPreferredSize(new java
.awt
.Dimension(260,20));
704 return jTextFieldHdr
;
708 This method initializes jButtonBrowse
710 @return javax.swing.JButton
712 private JButton
getJButtonBrowse() {
713 if (jButtonBrowse
== null) {
714 jButtonBrowse
= new JButton();
715 jButtonBrowse
.setBounds(new java
.awt
.Rectangle(527,75,90,20));
716 jButtonBrowse
.setText("Browse");
717 jButtonBrowse
.setPreferredSize(new java
.awt
.Dimension(99,20));
718 jButtonBrowse
.addActionListener(new AbstractAction() {
723 private static final long serialVersionUID
= 1L;
725 public void actionPerformed(ActionEvent arg0
) {
727 // Select files from current pkg
729 String dirPrefix
= Tools
.dirForNewSpd
.substring(0, Tools
.dirForNewSpd
.lastIndexOf(File
.separator
));
730 JFileChooser chooser
= new JFileChooser(dirPrefix
);
732 String headerDest
= null;
734 chooser
.setMultiSelectionEnabled(false);
735 chooser
.setFileSelectionMode(JFileChooser
.FILES_AND_DIRECTORIES
);
736 int retval
= chooser
.showOpenDialog(frame
);
737 if (retval
== JFileChooser
.APPROVE_OPTION
) {
739 theFile
= chooser
.getSelectedFile();
740 String file
= theFile
.getPath();
741 if (!file
.startsWith(dirPrefix
)) {
742 JOptionPane
.showMessageDialog(frame
, "You can only select files in current package directory structure!");
752 headerDest
= theFile
.getPath();
753 int fileIndex
= headerDest
.indexOf(System
.getProperty("file.separator"), dirPrefix
.length());
754 jTextFieldHdr
.setText(headerDest
.substring(fileIndex
+ 1).replace('\\', '/'));
760 return jButtonBrowse
;
763 public void componentResized(ComponentEvent arg0
) {
764 int intPreferredWidth
= 500;
766 Tools
.resizeComponentWidth(this.jTextFieldClass
, this.getWidth(), intPreferredWidth
);
767 Tools
.resizeComponentWidth(this.jTextFieldHelp
, this.getWidth(), intPreferredWidth
);
768 Tools
.resizeComponentWidth(this.jScrollPane
, this.getWidth(), intPreferredWidth
-10);
772 * This method initializes jTextFieldHelp
774 * @return javax.swing.JTextField
776 private JTextField
getJTextFieldHelp() {
777 if (jTextFieldHelp
== null) {
778 jTextFieldHelp
= new JTextField();
779 jTextFieldHelp
.setBounds(new java
.awt
.Rectangle(122,33,390,20));
780 jTextFieldHelp
.setPreferredSize(new java
.awt
.Dimension(260,20));
782 return jTextFieldHelp
;
786 * This method initializes jTextField1RecInstName
788 * @return javax.swing.JTextField
790 private JTextField
getJTextField1RecInstName() {
791 if (jTextField1RecInstName
== null) {
792 jTextField1RecInstName
= new JTextField();
793 jTextField1RecInstName
.setBounds(new java
.awt
.Rectangle(218,110,291,20));
794 jTextField1RecInstName
.setEnabled(true);
795 jTextField1RecInstName
.setVisible(false);
797 return jTextField1RecInstName
;
801 * This method initializes jTextField2RecInstVer
803 * @return javax.swing.JTextField
805 private JTextField
getJTextField2RecInstVer() {
806 if (jTextField2RecInstVer
== null) {
807 jTextField2RecInstVer
= new JTextField();
808 jTextField2RecInstVer
.setBounds(new java
.awt
.Rectangle(218,135,292,20));
809 jTextField2RecInstVer
.setEnabled(true);
811 return jTextField2RecInstVer
;
814 private JScrollPane
getJScrollPaneModules() {
815 if (jScrollPaneModules
== null) {
816 jScrollPaneModules
= new JScrollPane();
817 jScrollPaneModules
.setBounds(new java
.awt
.Rectangle(218,245,293,73));
818 jScrollPaneModules
.setPreferredSize(new java
.awt
.Dimension(320, 80));
819 jScrollPaneModules
.setViewportView(getICheckBoxListSupportedModules());
821 return jScrollPaneModules
;
824 private ICheckBoxList
getICheckBoxListSupportedModules() {
825 if (iCheckBoxListModules
== null) {
826 iCheckBoxListModules
= new ICheckBoxList();
827 iCheckBoxListModules
.setBounds(new java
.awt
.Rectangle(218,246,292,73));
828 Vector
<String
> v
= new Vector
<String
>();
835 v
.add("DXE_RUNTIME_DRIVER");
836 v
.add("DXE_SAL_DRIVER");
837 v
.add("DXE_SMM_DRIVER");
838 v
.add("UEFI_DRIVER");
839 v
.add("UEFI_APPLICATION");
840 v
.add("USER_DEFINED");
841 iCheckBoxListModules
.setAllItems(v
);
843 return iCheckBoxListModules
;
846 private String
vectorToString(Vector
<String
> v
) {
848 for (int i
= 0; i
< v
.size(); ++i
) {
855 private JScrollPane
getJScrollPane1Arch() {
856 if (jScrollPane1Arch
== null) {
857 jScrollPane1Arch
= new JScrollPane();
858 jScrollPane1Arch
.setBounds(new java
.awt
.Rectangle(218,170,293,73));
859 jScrollPane1Arch
.setPreferredSize(new java
.awt
.Dimension(320, 80));
860 jScrollPane1Arch
.setViewportView(getICheckBoxListArch());
862 return jScrollPane1Arch
;
865 * This method initializes iCheckBoxList
867 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
869 private ICheckBoxList
getICheckBoxListArch() {
870 if (iCheckBoxListArch
== null) {
871 iCheckBoxListArch
= new ICheckBoxList();
872 iCheckBoxListArch
.setBounds(new java
.awt
.Rectangle(218,171,292,66));
873 Vector
<String
> v
= new Vector
<String
>();
880 iCheckBoxListArch
.setAllItems(v
);
882 return iCheckBoxListArch
;
886 * This method initializes jComboBox
888 * @return javax.swing.JComboBox
890 private JComboBox
getJComboBox() {
891 if (jComboBox
== null) {
892 jComboBox
= new JComboBox();
893 jComboBox
.setPreferredSize(new java
.awt
.Dimension(31,20));
894 jComboBox
.setSize(new java
.awt
.Dimension(290,20));
895 jComboBox
.setLocation(new java
.awt
.Point(218,111));
896 jComboBox
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
897 public void focusGained(java
.awt
.event
.FocusEvent e
) {
898 if (jTextFieldClass
.getText().length() == 0) {
901 jComboBox
.removeAllItems();
902 getLibInstances(jTextFieldClass
.getText());
903 Set
<String
> libNames
= libNameGuidMap
.keySet();
904 Iterator
<String
> si
= libNames
.iterator();
905 while(si
.hasNext()) {
906 jComboBox
.addItem(si
.next());
915 private void getLibInstances(String libClass
){
916 libNameGuidMap
.clear();
918 Iterator ismi
= GlobalData
.vModuleList
.iterator();
919 while (ismi
.hasNext()) {
920 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
922 Vector
<String
> classProduced
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED", mi
);
923 for (int i
= 0; i
< classProduced
.size(); ++i
) {
924 if (classProduced
.get(i
).equals(libClass
)) {
925 libNameGuidMap
.put(mi
.getName(), mi
.getGuid());
932 JOptionPane
.showMessageDialog(frame
, "Search Instances Failed.");
937 private String
nameToGuid(String name
) {
939 if (!libNameGuidMap
.containsKey(name
)) {
943 s
= libNameGuidMap
.get(name
);
947 private String
guidToName(String guid
){
949 if (!libNameGuidMap
.containsValue(guid
)) {
952 Set
<String
> key
= libNameGuidMap
.keySet();
953 Iterator
<String
> is
= key
.iterator();
954 while(is
.hasNext()) {
956 if (libNameGuidMap
.get(s
).equals(guid
)) {