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
.LongTextEditor
;
54 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
55 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
59 GUI for create library definition elements of spd file.
61 @since PackageEditor 1.0
63 public class SpdLibClassDecls
extends IInternalFrame
implements TableModelListener
{
67 private static final long serialVersionUID
= 1L;
71 private JTable jTable
= null;
73 private DefaultTableModel model
= null;
75 private JPanel jContentPane
= null;
77 private JTextField jTextFieldClass
= null;
79 private JComboBox jComboBoxSelect
= null;
81 private JScrollPane jScrollPane
= null;
83 private JButton jButtonAdd
= null;
85 private JButton jButtonRemove
= null;
87 private JButton jButtonRemoveAll
= null;
89 private JLabel jLabelHdr
= null;
91 private JTextField jTextFieldHdr
= null;
93 private JButton jButtonBrowse
= null;
95 private StarLabel jStarLabel1
= null;
97 private StarLabel jStarLabel2
= null;
99 private SpdFileContents sfc
= null;
101 private OpeningPackageType docConsole
= null;
103 private JLabel jLabel1ClassName
= null;
105 private JScrollPane topScrollPane
= null; // @jve:decl-index=0:visual-constraint="10,53"
107 private int selectedRow
= -1;
109 private StarLabel starLabel
= null;
111 private JLabel jLabel2HelpText
= null;
113 private JTextField jTextFieldHelp
= null;
115 private JLabel jLabel3RecInstName
= null;
117 private JTextField jTextField1RecInstName
= null;
119 private JLabel jLabel4RecInstVer
= null;
121 private JTextField jTextField2RecInstVer
= null;
123 private JLabel jLabel5SupArchList
= null;
125 private JLabel jLabel6SupModList
= null;
127 private JScrollPane jScrollPaneModules
= null;
129 private JScrollPane jScrollPane1Arch
= null;
131 private ICheckBoxList iCheckBoxListModules
= null;
133 private ICheckBoxList iCheckBoxListArch
= null;
135 private JComboBox jComboBox
= null;
137 private int cnClassName
= 0;
138 private int cnHdrFile
= 1;
139 private int cnHelpText
= 2;
140 private int cnRecInstName
= 3;
141 private int cnRecInstVer
= 4;
142 private int cnSupArch
= 5;
143 private int cnSupMod
= 6;
145 HashMap
<String
, String
> libNameGuidMap
= new HashMap
<String
, String
>();
149 This method initializes this
152 private void initialize() {
154 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
159 This method initializes jTextFieldAdd
161 @return javax.swing.JTextField
163 private JTextField
getJTextFieldClass() {
164 if (jTextFieldClass
== null) {
165 jTextFieldClass
= new JTextField();
166 jTextFieldClass
.setBounds(new java
.awt
.Rectangle(122,6,390,20));
167 jTextFieldClass
.setPreferredSize(new java
.awt
.Dimension(260,20));
168 jTextFieldClass
.setEnabled(true);
170 return jTextFieldClass
;
174 This method initializes jComboBoxSelect
176 @return javax.swing.JComboBox
178 private JComboBox
getJComboBoxSelect() {
179 if (jComboBoxSelect
== null) {
180 jComboBoxSelect
= new JComboBox();
181 jComboBoxSelect
.setBounds(new java
.awt
.Rectangle(220, 10, 260, 20));
182 jComboBoxSelect
.setPreferredSize(new java
.awt
.Dimension(260,22));
183 jComboBoxSelect
.setEnabled(true);
184 jComboBoxSelect
.setVisible(false);
186 return jComboBoxSelect
;
190 This method initializes jScrollPane
192 @return javax.swing.JScrollPane
194 Used for the Table of Library Classes that are provided by this package
197 private JScrollPane
getJScrollPane() {
198 if (jScrollPane
== null) {
199 jScrollPane
= new JScrollPane();
200 jScrollPane
.setBounds(new java
.awt
.Rectangle(12,351,400,253));
201 jScrollPane
.setViewportView(getJTable());
207 This method initializes jTable
209 @return javax.swing.JTable
211 private JTable
getJTable() {
212 if (jTable
== null) {
213 model
= new DefaultTableModel();
214 jTable
= new JTable(model
);
215 jTable
.setRowHeight(20);
216 jTable
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
217 jTable
.setColumnSelectionAllowed(false);
218 model
.addColumn("Class Name");
219 model
.addColumn("Header");
220 model
.addColumn("Help Text");
221 model
.addColumn("Recommended Instance");
222 model
.addColumn("Version");
223 model
.addColumn("Supported Architectures");
224 model
.addColumn("Supported Module Types");
226 jTable
.getColumnModel().getColumn(cnHelpText
).setCellEditor(new LongTextEditor());
228 Vector
<String
> vArch
= new Vector
<String
>();
235 jTable
.getColumnModel().getColumn(cnSupArch
).setCellEditor(new ListEditor(vArch
));
237 Vector
<String
> vModule
= new Vector
<String
>();
240 vModule
.add("PEI_CORE");
242 vModule
.add("DXE_CORE");
243 vModule
.add("DXE_DRIVER");
244 vModule
.add("DXE_RUNTIME_DRIVER");
245 vModule
.add("DXE_SAL_DRIVER");
246 vModule
.add("DXE_SMM_DRIVER");
247 vModule
.add("UEFI_DRIVER");
248 vModule
.add("UEFI_APPLICATION");
249 vModule
.add("USER_DEFINED");
251 jTable
.getColumnModel().getColumn(cnSupMod
).setCellEditor(new ListEditor(vModule
));
253 jTable
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
254 jTable
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
255 public void valueChanged(ListSelectionEvent e
) {
256 if (e
.getValueIsAdjusting()){
259 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
260 if (lsm
.isSelectionEmpty()) {
264 selectedRow
= lsm
.getMinSelectionIndex();
269 jTable
.getModel().addTableModelListener(this);
276 public void tableChanged(TableModelEvent arg0
) {
277 // TODO Auto-generated method stub
278 int row
= arg0
.getFirstRow();
279 int column
= arg0
.getColumn();
280 TableModel m
= (TableModel
)arg0
.getSource();
281 if (arg0
.getType() == TableModelEvent
.UPDATE
){
283 String lib
= m
.getValueAt(row
, cnClassName
) + "";
284 String hdr
= m
.getValueAt(row
, cnHdrFile
) + "";
285 String hlp
= m
.getValueAt(row
, cnHelpText
) + "";
287 if (m
.getValueAt(row
, cnRecInstName
) != null) {
288 name
= m
.getValueAt(row
, cnRecInstName
).toString();
291 if (m
.getValueAt(row
, cnRecInstVer
) != null){
292 ver
= m
.getValueAt(row
, cnRecInstVer
).toString();
295 if (m
.getValueAt(row
, cnSupArch
) != null) {
296 arch
= m
.getValueAt(row
, cnSupArch
).toString();
298 String module
= null;
299 if (m
.getValueAt(row
, cnSupMod
) != null) {
300 module
= m
.getValueAt(row
, cnSupMod
).toString();
302 String
[] rowData
= {lib
, hdr
, hlp
, name
, ver
};
303 if (!dataValidation(rowData
)) {
308 if (name
!= null && name
.length() > 0) {
309 getLibInstances(lib
);
310 guid
= nameToGuid(name
);
312 JOptionPane
.showMessageDialog(frame
, "Recommended Instance does not exist.");
317 String
[] sa
= new String
[7];
318 sfc
.getSpdLibClassDeclaration(sa
, row
);
319 Object cellData
= m
.getValueAt(row
, column
);
320 if (cellData
== null) {
323 if (column
== cnRecInstName
) {
325 if (sa
[cnRecInstName
] == null) {
330 if (guid
.equals(sa
[cnRecInstName
])) {
336 if (cellData
.equals(sa
[column
])) {
339 if (cellData
.toString().length() == 0 && sa
[column
] == null) {
343 docConsole
.setSaved(false);
344 sfc
.updateSpdLibClass(row
, lib
, hdr
, hlp
, guid
, ver
, arch
, module
);
349 This method initializes jButtonAdd
351 @return javax.swing.JButton
353 private JButton
getJButtonAdd() {
354 if (jButtonAdd
== null) {
355 jButtonAdd
= new JButton();
356 jButtonAdd
.setText("Add");
357 jButtonAdd
.setSize(new java
.awt
.Dimension(99,20));
358 jButtonAdd
.setBounds(new java
.awt
.Rectangle(321,326,99,20));
359 jButtonAdd
.addActionListener(this);
365 This method initializes jButtonRemove
367 @return javax.swing.JButton
369 private JButton
getJButtonRemove() {
370 if (jButtonRemove
== null) {
371 jButtonRemove
= new JButton();
372 jButtonRemove
.setText("Remove");
373 jButtonRemove
.setSize(new java
.awt
.Dimension(99,20));
374 jButtonRemove
.setBounds(new java
.awt
.Rectangle(424,326,99,20));
375 jButtonRemove
.addActionListener(this);
377 return jButtonRemove
;
381 This method initializes jButtonRemoveAll
383 @return javax.swing.JButton
385 private JButton
getJButtonRemoveAll() {
386 if (jButtonRemoveAll
== null) {
387 jButtonRemoveAll
= new JButton();
388 jButtonRemoveAll
.setText("Remove All");
389 jButtonRemoveAll
.setSize(new java
.awt
.Dimension(99,20));
390 jButtonRemoveAll
.setBounds(new java
.awt
.Rectangle(527,326,99,20));
391 jButtonRemoveAll
.addActionListener(this);
393 return jButtonRemoveAll
;
397 This is the default constructor
399 public SpdLibClassDecls() {
406 public SpdLibClassDecls(PackageSurfaceAreaDocument
.PackageSurfaceArea inPsa
){
408 sfc
= new SpdFileContents(inPsa
);
412 public SpdLibClassDecls(OpeningPackageType opt
) {
413 this(opt
.getXmlSpd());
417 This method initializes this
421 private void init() {
423 this.setContentPane(getJContentPane());
424 this.setTitle("Library Class Declarations");
425 this.setBounds(new java
.awt
.Rectangle(0, 0, 500, 370));
426 this.setVisible(true);
427 this.addInternalFrameListener(new InternalFrameAdapter(){
428 public void internalFrameDeactivated(InternalFrameEvent e
){
429 if (jTable
.isEditing()) {
430 jTable
.getCellEditor().stopCellEditing();
437 private void init(SpdFileContents sfc
) {
438 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
442 // initialize table using SpdFileContents object
444 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][7];
445 sfc
.getSpdLibClassDeclarations(saa
);
447 while (i
< saa
.length
) {
448 if (saa
[i
][3] != null && saa
[i
][3].length() > 0) {
449 getLibInstances(saa
[i
][0]);
450 saa
[i
][3] = guidToName(saa
[i
][3]);
453 model
.addRow(saa
[i
]);
457 private JScrollPane
getJContentPane(){
458 if (topScrollPane
== null){
459 topScrollPane
= new JScrollPane();
460 // topScrollPane.setSize(new java.awt.Dimension(634,590));
461 topScrollPane
.setViewportView(getJContentPane1());
463 return topScrollPane
;
466 This method initializes jContentPane
468 @return javax.swing.JPanel
470 private JPanel
getJContentPane1() {
471 if (jContentPane
== null) {
473 jStarLabel1
= new StarLabel();
474 jStarLabel1
.setLocation(new java
.awt
.Point(1,7));
475 jLabel1ClassName
= new JLabel();
476 jLabel1ClassName
.setBounds(new java
.awt
.Rectangle(16,6,82,20));
477 jLabel1ClassName
.setText("Library Class");
480 starLabel
= new StarLabel();
481 starLabel
.setBounds(new java
.awt
.Rectangle(1,33,10,20));
482 jLabel2HelpText
= new JLabel();
483 jLabel2HelpText
.setBounds(new java
.awt
.Rectangle(16,33,82,20));
484 jLabel2HelpText
.setText("Help Text");
487 jStarLabel2
= new StarLabel();
488 jStarLabel2
.setLocation(new java
.awt
.Point(1,74));
489 jLabelHdr
= new JLabel();
490 jLabelHdr
.setBounds(new java
.awt
.Rectangle(14,74,199,22));
491 jLabelHdr
.setText("Include Header for Specified Class");
493 jLabel6SupModList
= new JLabel();
494 jLabel6SupModList
.setBounds(new java
.awt
.Rectangle(16,252,108,16));
495 jLabel6SupModList
.setText("Supported Module");
496 jLabel6SupModList
.setEnabled(true);
498 jLabel5SupArchList
= new JLabel();
499 jLabel5SupArchList
.setBounds(new java
.awt
.Rectangle(15,169,93,16));
500 jLabel5SupArchList
.setText("Supported Arch");
501 jLabel5SupArchList
.setEnabled(true);
502 jLabel4RecInstVer
= new JLabel();
503 jLabel4RecInstVer
.setBounds(new java
.awt
.Rectangle(16,138,196,16));
504 jLabel4RecInstVer
.setEnabled(true);
505 jLabel4RecInstVer
.setText("Recommended Instance Version");
506 jLabel3RecInstName
= new JLabel();
507 jLabel3RecInstName
.setBounds(new java
.awt
.Rectangle(17,112,195,16));
508 jLabel3RecInstName
.setEnabled(true);
509 jLabel3RecInstName
.setText("Recommended Instance Name");
511 jContentPane
= new JPanel();
512 jContentPane
.setPreferredSize(new Dimension(680, 600));
513 jContentPane
.setLayout(null);
514 jContentPane
.add(jLabelHdr
, null);
515 jContentPane
.add(jStarLabel1
, null);
516 jContentPane
.add(jStarLabel2
, null);
517 jContentPane
.add(getJTextFieldClass(), null);
518 jContentPane
.add(getJComboBoxSelect(), null);
519 jContentPane
.add(getJScrollPane(), null);
520 jContentPane
.add(getJButtonAdd(), null);
521 jContentPane
.add(getJButtonRemove(), null);
522 jContentPane
.add(getJButtonRemoveAll(), null);
524 jContentPane
.add(getJTextFieldHdr(), null);
525 jContentPane
.add(getJButtonBrowse(), null);
526 jContentPane
.add(jLabel1ClassName
, null);
527 jContentPane
.add(starLabel
, null);
528 jContentPane
.add(jLabel2HelpText
, null);
529 jContentPane
.add(getJTextFieldHelp(), null);
531 jContentPane
.add(jLabel3RecInstName
, null);
532 jContentPane
.add(getJTextField1RecInstName(), null);
533 jContentPane
.add(jLabel4RecInstVer
, null);
534 jContentPane
.add(getJTextField2RecInstVer(), null);
535 jContentPane
.add(jLabel5SupArchList
, null);
536 jContentPane
.add(jLabel6SupModList
, null);
538 jContentPane
.add(getJScrollPaneModules(), null);
539 jContentPane
.add(getJScrollPane1Arch(), null);
540 jContentPane
.add(getJComboBox(), null);
548 fill ComboBoxes with pre-defined contents
550 private void initFrame() {
551 jComboBoxSelect
.addItem("BaseCpuICacheFlush");
552 jComboBoxSelect
.addItem("BaseDebugLibNull");
553 jComboBoxSelect
.addItem("BaseDebugLibReportStatusCode");
554 jComboBoxSelect
.addItem("BaseIoLibIntrinsic");
555 jComboBoxSelect
.addItem("BaseLib");
556 jComboBoxSelect
.addItem("BaseMemoryLib");
557 jComboBoxSelect
.addItem("BaseMemoryLibMmx");
558 jComboBoxSelect
.addItem("BaseMemoryLibSse2");
559 jComboBoxSelect
.addItem("BasePeCoffGetEntryPointLib");
560 jComboBoxSelect
.addItem("BasePeCoffLib");
561 jComboBoxSelect
.addItem("BasePrintLib");
562 jComboBoxSelect
.addItem("BaseReportStatusCodeLibNull");
563 jComboBoxSelect
.addItem("CommonPciCf8Lib");
564 jComboBoxSelect
.addItem("CommonPciExpressLib");
565 jComboBoxSelect
.addItem("CommonPciLibCf8");
566 jComboBoxSelect
.addItem("CommonPciLibPciExpress");
567 jComboBoxSelect
.addItem("DxeCoreEntryPoint");
568 jComboBoxSelect
.addItem("DxeHobLib");
569 jComboBoxSelect
.addItem("DxeIoLibCpuIo");
570 jComboBoxSelect
.addItem("DxeLib");
571 jComboBoxSelect
.addItem("DxePcdLib");
572 jComboBoxSelect
.addItem("DxeReportStatusCodeLib");
573 jComboBoxSelect
.addItem("DxeServicesTableLib");
574 jComboBoxSelect
.addItem("PeiCoreEntryPoint");
575 jComboBoxSelect
.addItem("PeiMemoryLib");
576 jComboBoxSelect
.addItem("PeimEntryPoint");
577 jComboBoxSelect
.addItem("PeiReportStatusCodeLib");
578 jComboBoxSelect
.addItem("PeiServicesTablePointerLib");
579 jComboBoxSelect
.addItem("PeiServicesTablePointerLibMm7");
580 jComboBoxSelect
.addItem("UefiDebugLibConOut");
581 jComboBoxSelect
.addItem("UefiDebugLibStdErr");
582 jComboBoxSelect
.addItem("UefiDriverEntryPointMultiple");
583 jComboBoxSelect
.addItem("UefiDriverEntryPointSingle");
584 jComboBoxSelect
.addItem("UefiDriverEntryPointSingleUnload");
585 jComboBoxSelect
.addItem("UefiDriverModelLib");
586 jComboBoxSelect
.addItem("UefiDriverModelLibNoConfigNoDiag");
587 jComboBoxSelect
.addItem("UefiLib");
588 jComboBoxSelect
.addItem("UefiMemoryLib");
593 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
595 public void actionPerformed(ActionEvent arg0
) {
597 if (arg0
.getSource() == jButtonAdd
) {
599 //ToDo: check before add
600 // LAH WAS String[] row = {null, null, null, jComboBox.getSelectedItem()+"", jTextField2RecInstVer.getText(), null, null};
601 String
[] row
= {null, null, null, null, null, null, null};
602 row
[cnClassName
] = jTextFieldClass
.getText();
603 row
[cnHdrFile
] = jTextFieldHdr
.getText().replace('\\', '/');
604 row
[cnHelpText
] = jTextFieldHelp
.getText();
605 row
[cnRecInstName
] = jComboBox
.getSelectedItem()+"";
606 row
[cnRecInstVer
] = jTextField2RecInstVer
.getText();
607 row
[cnSupArch
] = vectorToString(iCheckBoxListArch
.getAllCheckedItemsString());
608 if (row
[cnSupArch
].length() == 0) {
609 row
[cnSupArch
] = null;
611 row
[cnSupMod
] = vectorToString(iCheckBoxListModules
.getAllCheckedItemsString());
612 if (row
[cnSupMod
].length() == 0){
613 row
[cnSupMod
] = null;
615 if (!dataValidation(row
)) {
619 //convert to GUID before storing recommended lib instance.
621 getLibInstances(row
[cnClassName
]);
622 String recommendGuid
= nameToGuid(row
[cnRecInstName
]);
623 if (row
[cnRecInstName
].equals("null")) {
624 row
[cnRecInstName
] = null;
627 if (recommendGuid
== null) {
628 JOptionPane
.showMessageDialog(frame
, "Recommended Instance does not exist.");
633 sfc
.genSpdLibClassDeclarations(row
[cnClassName
], recommendGuid
, row
[cnHdrFile
], row
[cnHelpText
], row
[cnSupArch
], null, null, row
[cnRecInstVer
], null, row
[cnSupMod
]);
635 jTable
.changeSelection(model
.getRowCount()-1, 0, false, false);
636 docConsole
.setSaved(false);
639 // remove selected line
641 if (arg0
.getSource() == jButtonRemove
) {
642 if (jTable
.isEditing()){
643 jTable
.getCellEditor().stopCellEditing();
645 int rowSelected
= selectedRow
;
646 if (rowSelected
>= 0) {
647 model
.removeRow(rowSelected
);
648 docConsole
.setSaved(false);
649 sfc
.removeSpdLibClass(rowSelected
);
653 if (arg0
.getSource() == jButtonRemoveAll
) {
654 if (model
.getRowCount() == 0) {
657 docConsole
.setSaved(false);
658 model
.setRowCount(0);
659 sfc
.removeSpdLibClass();
663 private boolean dataValidation(String
[] row
) {
664 if (!DataValidation
.isKeywordType(row
[cnClassName
])) {
665 JOptionPane
.showMessageDialog(frame
, "Library Class name entered does not match KeyWord datatype.");
668 if (!DataValidation
.isPathAndFilename(row
[cnHdrFile
])) {
669 JOptionPane
.showMessageDialog(frame
, "Include Header does not match the PathAndFilename datatype.");
672 if (row
[cnHelpText
].length() == 0) {
673 JOptionPane
.showMessageDialog(frame
, "Help Text must be entered!");
676 if (row
[cnRecInstVer
] != null && row
[cnRecInstVer
].length() > 0) {
677 if (row
[cnRecInstName
] == null || row
[cnRecInstName
].length() == 0) {
678 JOptionPane
.showMessageDialog(frame
, "Recommended Instance Version must associate with the Instance Name.");
682 if (!DataValidation
.isVersionDataType(row
[cnRecInstVer
])) {
683 JOptionPane
.showMessageDialog(frame
, "Recommended Instance Version does not match Version datatype.");
690 Add contents in list to sfc
692 protected void save() {
697 This method initializes jTextField
699 @return javax.swing.JTextField
701 private JTextField
getJTextFieldHdr() {
702 if (jTextFieldHdr
== null) {
703 jTextFieldHdr
= new JTextField();
704 jTextFieldHdr
.setBounds(new java
.awt
.Rectangle(218,75,305,21));
705 jTextFieldHdr
.setPreferredSize(new java
.awt
.Dimension(260,20));
707 return jTextFieldHdr
;
711 This method initializes jButtonBrowse
713 @return javax.swing.JButton
715 private JButton
getJButtonBrowse() {
716 if (jButtonBrowse
== null) {
717 jButtonBrowse
= new JButton();
718 jButtonBrowse
.setBounds(new java
.awt
.Rectangle(527,75,90,20));
719 jButtonBrowse
.setText("Browse");
720 jButtonBrowse
.setPreferredSize(new java
.awt
.Dimension(99,20));
721 jButtonBrowse
.addActionListener(new AbstractAction() {
726 private static final long serialVersionUID
= 1L;
728 public void actionPerformed(ActionEvent arg0
) {
730 // Select files from current pkg
732 String dirPrefix
= Tools
.dirForNewSpd
.substring(0, Tools
.dirForNewSpd
.lastIndexOf(File
.separator
));
733 JFileChooser chooser
= new JFileChooser(dirPrefix
);
735 String headerDest
= null;
737 chooser
.setMultiSelectionEnabled(false);
738 chooser
.setFileSelectionMode(JFileChooser
.FILES_AND_DIRECTORIES
);
739 int retval
= chooser
.showOpenDialog(frame
);
740 if (retval
== JFileChooser
.APPROVE_OPTION
) {
742 theFile
= chooser
.getSelectedFile();
743 String file
= theFile
.getPath();
744 if (!file
.startsWith(dirPrefix
)) {
745 JOptionPane
.showMessageDialog(frame
, "You can only select files in current package directory structure!");
755 headerDest
= theFile
.getPath();
756 int fileIndex
= headerDest
.indexOf(System
.getProperty("file.separator"), dirPrefix
.length());
757 jTextFieldHdr
.setText(headerDest
.substring(fileIndex
+ 1).replace('\\', '/'));
763 return jButtonBrowse
;
766 public void componentResized(ComponentEvent arg0
) {
767 int intPreferredWidth
= 500;
769 Tools
.resizeComponentWidth(this.jTextFieldClass
, this.getWidth(), intPreferredWidth
);
770 Tools
.resizeComponentWidth(this.jTextFieldHelp
, this.getWidth(), intPreferredWidth
);
771 Tools
.resizeComponentWidth(this.jScrollPane
, this.getWidth(), intPreferredWidth
-10);
775 * This method initializes jTextFieldHelp
777 * @return javax.swing.JTextField
779 private JTextField
getJTextFieldHelp() {
780 if (jTextFieldHelp
== null) {
781 jTextFieldHelp
= new JTextField();
782 jTextFieldHelp
.setBounds(new java
.awt
.Rectangle(122,33,390,20));
783 jTextFieldHelp
.setPreferredSize(new java
.awt
.Dimension(260,20));
785 return jTextFieldHelp
;
789 * This method initializes jTextField1RecInstName
791 * @return javax.swing.JTextField
793 private JTextField
getJTextField1RecInstName() {
794 if (jTextField1RecInstName
== null) {
795 jTextField1RecInstName
= new JTextField();
796 jTextField1RecInstName
.setBounds(new java
.awt
.Rectangle(218,110,291,20));
797 jTextField1RecInstName
.setEnabled(true);
798 jTextField1RecInstName
.setVisible(false);
800 return jTextField1RecInstName
;
804 * This method initializes jTextField2RecInstVer
806 * @return javax.swing.JTextField
808 private JTextField
getJTextField2RecInstVer() {
809 if (jTextField2RecInstVer
== null) {
810 jTextField2RecInstVer
= new JTextField();
811 jTextField2RecInstVer
.setBounds(new java
.awt
.Rectangle(218,135,292,20));
812 jTextField2RecInstVer
.setEnabled(true);
814 return jTextField2RecInstVer
;
817 private JScrollPane
getJScrollPaneModules() {
818 if (jScrollPaneModules
== null) {
819 jScrollPaneModules
= new JScrollPane();
820 jScrollPaneModules
.setBounds(new java
.awt
.Rectangle(218,245,293,73));
821 jScrollPaneModules
.setPreferredSize(new java
.awt
.Dimension(320, 80));
822 jScrollPaneModules
.setViewportView(getICheckBoxListSupportedModules());
824 return jScrollPaneModules
;
827 private ICheckBoxList
getICheckBoxListSupportedModules() {
828 if (iCheckBoxListModules
== null) {
829 iCheckBoxListModules
= new ICheckBoxList();
830 iCheckBoxListModules
.setBounds(new java
.awt
.Rectangle(218,246,292,73));
831 Vector
<String
> v
= new Vector
<String
>();
838 v
.add("DXE_RUNTIME_DRIVER");
839 v
.add("DXE_SAL_DRIVER");
840 v
.add("DXE_SMM_DRIVER");
841 v
.add("UEFI_DRIVER");
842 v
.add("UEFI_APPLICATION");
843 v
.add("USER_DEFINED");
844 iCheckBoxListModules
.setAllItems(v
);
846 return iCheckBoxListModules
;
849 private String
vectorToString(Vector
<String
> v
) {
851 for (int i
= 0; i
< v
.size(); ++i
) {
858 private JScrollPane
getJScrollPane1Arch() {
859 if (jScrollPane1Arch
== null) {
860 jScrollPane1Arch
= new JScrollPane();
861 jScrollPane1Arch
.setBounds(new java
.awt
.Rectangle(218,170,293,73));
862 jScrollPane1Arch
.setPreferredSize(new java
.awt
.Dimension(320, 80));
863 jScrollPane1Arch
.setViewportView(getICheckBoxListArch());
865 return jScrollPane1Arch
;
868 * This method initializes iCheckBoxList
870 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
872 private ICheckBoxList
getICheckBoxListArch() {
873 if (iCheckBoxListArch
== null) {
874 iCheckBoxListArch
= new ICheckBoxList();
875 iCheckBoxListArch
.setBounds(new java
.awt
.Rectangle(218,171,292,66));
876 Vector
<String
> v
= new Vector
<String
>();
883 iCheckBoxListArch
.setAllItems(v
);
885 return iCheckBoxListArch
;
889 * This method initializes jComboBox
891 * @return javax.swing.JComboBox
893 private JComboBox
getJComboBox() {
894 if (jComboBox
== null) {
895 jComboBox
= new JComboBox();
896 jComboBox
.setPreferredSize(new java
.awt
.Dimension(31,20));
897 jComboBox
.setSize(new java
.awt
.Dimension(290,20));
898 jComboBox
.setLocation(new java
.awt
.Point(218,111));
899 jComboBox
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
900 public void focusGained(java
.awt
.event
.FocusEvent e
) {
901 if (jTextFieldClass
.getText().length() == 0) {
904 jComboBox
.removeAllItems();
905 getLibInstances(jTextFieldClass
.getText());
906 Set
<String
> libNames
= libNameGuidMap
.keySet();
907 Iterator
<String
> si
= libNames
.iterator();
908 while(si
.hasNext()) {
909 jComboBox
.addItem(si
.next());
918 private void getLibInstances(String libClass
){
919 libNameGuidMap
.clear();
921 Iterator ismi
= GlobalData
.vModuleList
.iterator();
922 while (ismi
.hasNext()) {
923 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
925 Vector
<String
> classProduced
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED", mi
);
926 for (int i
= 0; i
< classProduced
.size(); ++i
) {
927 if (classProduced
.get(i
).equals(libClass
)) {
928 libNameGuidMap
.put(mi
.getName(), mi
.getGuid());
935 JOptionPane
.showMessageDialog(frame
, "Search Instances Failed.");
940 private String
nameToGuid(String name
) {
942 if (!libNameGuidMap
.containsKey(name
)) {
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
)) {