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
.WorkspaceProfile
;
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 jTextFieldClass
= 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 iCheckBoxListArch
= 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
getJTextFieldClass() {
167 if (jTextFieldClass
== null) {
168 jTextFieldClass
= new JTextField();
169 jTextFieldClass
.setBounds(new java
.awt
.Rectangle(122,6,390,20));
170 jTextFieldClass
.setPreferredSize(new java
.awt
.Dimension(260,20));
171 jTextFieldClass
.setEnabled(true);
173 return jTextFieldClass
;
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,400,253));
204 jScrollPane
.setViewportView(getJTable());
210 This method initializes jTable
212 @return javax.swing.JTable
214 private JTable
getJTable() {
215 if (jTable
== null) {
216 model
= new DefaultTableModel();
217 jTable
= new JTable(model
);
218 jTable
.setRowHeight(20);
219 jTable
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
220 jTable
.setColumnSelectionAllowed(false);
221 model
.addColumn("Class Name");
222 model
.addColumn("Header");
223 model
.addColumn("Help Text");
224 model
.addColumn("Recommended Instance");
225 model
.addColumn("Version");
226 model
.addColumn("Supported Architectures");
227 model
.addColumn("Supported Module Types");
229 Vector
<String
> vArch
= new Vector
<String
>();
236 jTable
.getColumnModel().getColumn(cnSupArch
).setCellEditor(new ListEditor(vArch
));
238 Vector
<String
> vModule
= new Vector
<String
>();
241 vModule
.add("PEI_CORE");
243 vModule
.add("DXE_CORE");
244 vModule
.add("DXE_DRIVER");
245 vModule
.add("DXE_RUNTIME_DRIVER");
246 vModule
.add("DXE_SAL_DRIVER");
247 vModule
.add("DXE_SMM_DRIVER");
248 vModule
.add("UEFI_DRIVER");
249 vModule
.add("UEFI_APPLICATION");
250 vModule
.add("USER_DEFINED");
252 jTable
.getColumnModel().getColumn(cnSupMod
).setCellEditor(new ListEditor(vModule
));
254 jTable
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
255 jTable
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
256 public void valueChanged(ListSelectionEvent e
) {
257 if (e
.getValueIsAdjusting()){
260 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
261 if (lsm
.isSelectionEmpty()) {
265 selectedRow
= lsm
.getMinSelectionIndex();
270 jTable
.getModel().addTableModelListener(this);
277 public void tableChanged(TableModelEvent arg0
) {
278 // TODO Auto-generated method stub
279 int row
= arg0
.getFirstRow();
280 int column
= arg0
.getColumn();
281 TableModel m
= (TableModel
)arg0
.getSource();
282 if (arg0
.getType() == TableModelEvent
.UPDATE
){
284 String lib
= m
.getValueAt(row
, cnClassName
) + "";
285 String hdr
= m
.getValueAt(row
, cnHdrFile
) + "";
286 String hlp
= m
.getValueAt(row
, cnHelpText
) + "";
288 if (m
.getValueAt(row
, cnRecInstName
) != null) {
289 name
= m
.getValueAt(row
, cnRecInstName
).toString();
292 if (m
.getValueAt(row
, cnRecInstVer
) != null){
293 ver
= m
.getValueAt(row
, cnRecInstVer
).toString();
296 if (m
.getValueAt(row
, cnSupArch
) != null) {
297 arch
= m
.getValueAt(row
, cnSupArch
).toString();
299 String module
= null;
300 if (m
.getValueAt(row
, cnSupMod
) != null) {
301 module
= m
.getValueAt(row
, cnSupMod
).toString();
303 String
[] rowData
= {lib
, hdr
, hlp
, name
, ver
};
304 if (!dataValidation(rowData
)) {
309 if (name
!= null && name
.length() > 0) {
310 getLibInstances(lib
);
311 guid
= nameToGuid(name
);
313 JOptionPane
.showMessageDialog(frame
, "Recommended Instance does not exist.");
318 String
[] sa
= new String
[7];
319 sfc
.getSpdLibClassDeclaration(sa
, row
);
320 Object cellData
= m
.getValueAt(row
, column
);
321 if (cellData
== null) {
324 if (column
== cnRecInstName
) {
326 if (sa
[cnRecInstName
] == null) {
331 if (guid
.equals(sa
[cnRecInstName
])) {
337 if (cellData
.equals(sa
[column
])) {
340 if (cellData
.toString().length() == 0 && sa
[column
] == null) {
344 docConsole
.setSaved(false);
345 sfc
.updateSpdLibClass(row
, lib
, hdr
, hlp
, guid
, ver
, arch
, module
);
350 This method initializes jButtonAdd
352 @return javax.swing.JButton
354 private JButton
getJButtonAdd() {
355 if (jButtonAdd
== null) {
356 jButtonAdd
= new JButton();
357 jButtonAdd
.setText("Add");
358 jButtonAdd
.setSize(new java
.awt
.Dimension(99,20));
359 jButtonAdd
.setBounds(new java
.awt
.Rectangle(321,326,99,20));
360 jButtonAdd
.addActionListener(this);
366 This method initializes jButtonRemove
368 @return javax.swing.JButton
370 private JButton
getJButtonRemove() {
371 if (jButtonRemove
== null) {
372 jButtonRemove
= new JButton();
373 jButtonRemove
.setText("Remove");
374 jButtonRemove
.setSize(new java
.awt
.Dimension(99,20));
375 jButtonRemove
.setBounds(new java
.awt
.Rectangle(424,326,99,20));
376 jButtonRemove
.addActionListener(this);
378 return jButtonRemove
;
382 This method initializes jButtonRemoveAll
384 @return javax.swing.JButton
386 private JButton
getJButtonRemoveAll() {
387 if (jButtonRemoveAll
== null) {
388 jButtonRemoveAll
= new JButton();
389 jButtonRemoveAll
.setText("Remove All");
390 jButtonRemoveAll
.setSize(new java
.awt
.Dimension(99,20));
391 jButtonRemoveAll
.setBounds(new java
.awt
.Rectangle(527,326,99,20));
392 jButtonRemoveAll
.addActionListener(this);
394 return jButtonRemoveAll
;
398 This is the default constructor
400 public SpdLibClassDecls() {
407 public SpdLibClassDecls(PackageSurfaceAreaDocument
.PackageSurfaceArea inPsa
){
409 sfc
= new SpdFileContents(inPsa
);
413 public SpdLibClassDecls(OpeningPackageType opt
) {
414 this(opt
.getXmlSpd());
418 This method initializes this
422 private void init() {
424 this.setContentPane(getJContentPane());
425 this.setTitle("Library Class Declarations");
426 this.setBounds(new java
.awt
.Rectangle(0, 0, 500, 370));
427 this.setVisible(true);
428 this.addInternalFrameListener(new InternalFrameAdapter(){
429 public void internalFrameDeactivated(InternalFrameEvent e
){
430 if (jTable
.isEditing()) {
431 jTable
.getCellEditor().stopCellEditing();
438 private void init(SpdFileContents sfc
) {
439 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
443 // initialize table using SpdFileContents object
445 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][7];
446 sfc
.getSpdLibClassDeclarations(saa
);
448 while (i
< saa
.length
) {
449 if (saa
[i
][3] != null && saa
[i
][3].length() > 0) {
450 getLibInstances(saa
[i
][0]);
451 saa
[i
][3] = guidToName(saa
[i
][3]);
454 model
.addRow(saa
[i
]);
458 private JScrollPane
getJContentPane(){
459 if (topScrollPane
== null){
460 topScrollPane
= new JScrollPane();
461 // topScrollPane.setSize(new java.awt.Dimension(634,590));
462 topScrollPane
.setViewportView(getJContentPane1());
464 return topScrollPane
;
467 This method initializes jContentPane
469 @return javax.swing.JPanel
471 private JPanel
getJContentPane1() {
472 if (jContentPane
== null) {
474 jStarLabel1
= new StarLabel();
475 jStarLabel1
.setLocation(new java
.awt
.Point(1,7));
476 jLabel1ClassName
= new JLabel();
477 jLabel1ClassName
.setBounds(new java
.awt
.Rectangle(16,6,82,20));
478 jLabel1ClassName
.setText("Library Class");
481 starLabel
= new StarLabel();
482 starLabel
.setBounds(new java
.awt
.Rectangle(1,33,10,20));
483 jLabel2HelpText
= new JLabel();
484 jLabel2HelpText
.setBounds(new java
.awt
.Rectangle(16,33,82,20));
485 jLabel2HelpText
.setText("Help Text");
488 jStarLabel2
= new StarLabel();
489 jStarLabel2
.setLocation(new java
.awt
.Point(1,74));
490 jLabelHdr
= new JLabel();
491 jLabelHdr
.setBounds(new java
.awt
.Rectangle(14,74,199,22));
492 jLabelHdr
.setText("Include Header for Specified Class");
494 jLabel6SupModList
= new JLabel();
495 jLabel6SupModList
.setBounds(new java
.awt
.Rectangle(16,252,108,16));
496 jLabel6SupModList
.setText("Supported Module");
497 jLabel6SupModList
.setEnabled(true);
499 jLabel5SupArchList
= new JLabel();
500 jLabel5SupArchList
.setBounds(new java
.awt
.Rectangle(15,169,93,16));
501 jLabel5SupArchList
.setText("Supported Arch");
502 jLabel5SupArchList
.setEnabled(true);
503 jLabel4RecInstVer
= new JLabel();
504 jLabel4RecInstVer
.setBounds(new java
.awt
.Rectangle(16,138,196,16));
505 jLabel4RecInstVer
.setEnabled(true);
506 jLabel4RecInstVer
.setText("Recommended Instance Version");
507 jLabel3RecInstName
= new JLabel();
508 jLabel3RecInstName
.setBounds(new java
.awt
.Rectangle(17,112,195,16));
509 jLabel3RecInstName
.setEnabled(true);
510 jLabel3RecInstName
.setText("Recommended Instance Name");
512 jContentPane
= new JPanel();
513 jContentPane
.setPreferredSize(new Dimension(680, 600));
514 jContentPane
.setLayout(null);
515 jContentPane
.add(jLabelHdr
, null);
516 jContentPane
.add(jStarLabel1
, null);
517 jContentPane
.add(jStarLabel2
, null);
518 jContentPane
.add(getJTextFieldClass(), null);
519 jContentPane
.add(getJComboBoxSelect(), null);
520 jContentPane
.add(getJScrollPane(), null);
521 jContentPane
.add(getJButtonAdd(), null);
522 jContentPane
.add(getJButtonRemove(), null);
523 jContentPane
.add(getJButtonRemoveAll(), null);
525 jContentPane
.add(getJTextFieldHdr(), null);
526 jContentPane
.add(getJButtonBrowse(), null);
527 jContentPane
.add(jLabel1ClassName
, null);
528 jContentPane
.add(starLabel
, null);
529 jContentPane
.add(jLabel2HelpText
, null);
530 jContentPane
.add(getJTextFieldHelp(), null);
532 jContentPane
.add(jLabel3RecInstName
, null);
533 jContentPane
.add(getJTextField1RecInstName(), null);
534 jContentPane
.add(jLabel4RecInstVer
, null);
535 jContentPane
.add(getJTextField2RecInstVer(), null);
536 jContentPane
.add(jLabel5SupArchList
, null);
537 jContentPane
.add(jLabel6SupModList
, null);
539 jContentPane
.add(getJScrollPaneModules(), null);
540 jContentPane
.add(getJScrollPane1Arch(), null);
541 jContentPane
.add(getJComboBox(), null);
549 fill ComboBoxes with pre-defined contents
551 private void initFrame() {
552 jComboBoxSelect
.addItem("BaseCpuICacheFlush");
553 jComboBoxSelect
.addItem("BaseDebugLibNull");
554 jComboBoxSelect
.addItem("BaseDebugLibReportStatusCode");
555 jComboBoxSelect
.addItem("BaseIoLibIntrinsic");
556 jComboBoxSelect
.addItem("BaseLib");
557 jComboBoxSelect
.addItem("BaseMemoryLib");
558 jComboBoxSelect
.addItem("BaseMemoryLibMmx");
559 jComboBoxSelect
.addItem("BaseMemoryLibSse2");
560 jComboBoxSelect
.addItem("BasePeCoffGetEntryPointLib");
561 jComboBoxSelect
.addItem("BasePeCoffLib");
562 jComboBoxSelect
.addItem("BasePrintLib");
563 jComboBoxSelect
.addItem("BaseReportStatusCodeLibNull");
564 jComboBoxSelect
.addItem("CommonPciCf8Lib");
565 jComboBoxSelect
.addItem("CommonPciExpressLib");
566 jComboBoxSelect
.addItem("CommonPciLibCf8");
567 jComboBoxSelect
.addItem("CommonPciLibPciExpress");
568 jComboBoxSelect
.addItem("DxeCoreEntryPoint");
569 jComboBoxSelect
.addItem("DxeHobLib");
570 jComboBoxSelect
.addItem("DxeIoLibCpuIo");
571 jComboBoxSelect
.addItem("DxeLib");
572 jComboBoxSelect
.addItem("DxePcdLib");
573 jComboBoxSelect
.addItem("DxeReportStatusCodeLib");
574 jComboBoxSelect
.addItem("DxeServicesTableLib");
575 jComboBoxSelect
.addItem("PeiCoreEntryPoint");
576 jComboBoxSelect
.addItem("PeiMemoryLib");
577 jComboBoxSelect
.addItem("PeimEntryPoint");
578 jComboBoxSelect
.addItem("PeiReportStatusCodeLib");
579 jComboBoxSelect
.addItem("PeiServicesTablePointerLib");
580 jComboBoxSelect
.addItem("PeiServicesTablePointerLibMm7");
581 jComboBoxSelect
.addItem("UefiDebugLibConOut");
582 jComboBoxSelect
.addItem("UefiDebugLibStdErr");
583 jComboBoxSelect
.addItem("UefiDriverEntryPointMultiple");
584 jComboBoxSelect
.addItem("UefiDriverEntryPointSingle");
585 jComboBoxSelect
.addItem("UefiDriverEntryPointSingleUnload");
586 jComboBoxSelect
.addItem("UefiDriverModelLib");
587 jComboBoxSelect
.addItem("UefiDriverModelLibNoConfigNoDiag");
588 jComboBoxSelect
.addItem("UefiLib");
589 jComboBoxSelect
.addItem("UefiMemoryLib");
594 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
596 public void actionPerformed(ActionEvent arg0
) {
598 if (arg0
.getSource() == jButtonAdd
) {
600 //ToDo: check before add
601 // LAH WAS String[] row = {null, null, null, jComboBox.getSelectedItem()+"", jTextField2RecInstVer.getText(), null, null};
602 String
[] row
= {null, null, null, null, null, null, null};
603 row
[cnClassName
] = jTextFieldClass
.getText();
604 row
[cnHdrFile
] = jTextFieldHdr
.getText().replace('\\', '/');
605 row
[cnHelpText
] = jTextFieldHelp
.getText();
606 row
[cnRecInstName
] = jComboBox
.getSelectedItem()+"";
607 row
[cnRecInstVer
] = jTextField2RecInstVer
.getText();
608 row
[cnSupArch
] = vectorToString(iCheckBoxListArch
.getAllCheckedItemsString());
609 if (row
[cnSupArch
].length() == 0) {
610 row
[cnSupArch
] = null;
612 row
[cnSupMod
] = vectorToString(iCheckBoxListModules
.getAllCheckedItemsString());
613 if (row
[cnSupMod
].length() == 0){
614 row
[cnSupMod
] = null;
616 if (!dataValidation(row
)) {
620 //convert to GUID before storing recommended lib instance.
622 getLibInstances(row
[cnClassName
]);
623 String recommendGuid
= nameToGuid(row
[cnRecInstName
]);
624 if (row
[cnRecInstName
].equals("null")) {
625 row
[cnRecInstName
] = null;
628 if (recommendGuid
== null) {
629 JOptionPane
.showMessageDialog(frame
, "Recommended Instance does not exist.");
634 sfc
.genSpdLibClassDeclarations(row
[cnClassName
], recommendGuid
, row
[cnHdrFile
], row
[cnHelpText
], row
[cnSupArch
], null, null, row
[cnRecInstVer
], null, row
[cnSupMod
]);
636 jTable
.changeSelection(model
.getRowCount()-1, 0, false, false);
637 docConsole
.setSaved(false);
640 // remove selected line
642 if (arg0
.getSource() == jButtonRemove
) {
643 if (jTable
.isEditing()){
644 jTable
.getCellEditor().stopCellEditing();
646 int rowSelected
= selectedRow
;
647 if (rowSelected
>= 0) {
648 model
.removeRow(rowSelected
);
649 docConsole
.setSaved(false);
650 sfc
.removeSpdLibClass(rowSelected
);
654 if (arg0
.getSource() == jButtonRemoveAll
) {
655 if (model
.getRowCount() == 0) {
658 docConsole
.setSaved(false);
659 model
.setRowCount(0);
660 sfc
.removeSpdLibClass();
664 private boolean dataValidation(String
[] row
) {
665 if (!DataValidation
.isKeywordType(row
[cnClassName
])) {
666 JOptionPane
.showMessageDialog(frame
, "Library Class name entered does not match KeyWord datatype.");
669 if (!DataValidation
.isPathAndFilename(row
[cnHdrFile
])) {
670 JOptionPane
.showMessageDialog(frame
, "Include Header does not match the PathAndFilename datatype.");
673 if (row
[cnHelpText
].length() == 0) {
674 JOptionPane
.showMessageDialog(frame
, "Help Text must be entered!");
677 if (row
[cnRecInstVer
] != null && row
[cnRecInstVer
].length() > 0) {
678 if (row
[cnRecInstName
] == null || row
[cnRecInstName
].length() == 0) {
679 JOptionPane
.showMessageDialog(frame
, "Recommended Instance Version must associate with the Instance Name.");
683 if (!DataValidation
.isVersionDataType(row
[cnRecInstVer
])) {
684 JOptionPane
.showMessageDialog(frame
, "Recommended Instance Version does not match Version datatype.");
691 Add contents in list to sfc
693 protected void save() {
698 This method initializes jTextField
700 @return javax.swing.JTextField
702 private JTextField
getJTextFieldHdr() {
703 if (jTextFieldHdr
== null) {
704 jTextFieldHdr
= new JTextField();
705 jTextFieldHdr
.setBounds(new java
.awt
.Rectangle(218,75,305,21));
706 jTextFieldHdr
.setPreferredSize(new java
.awt
.Dimension(260,20));
708 return jTextFieldHdr
;
712 This method initializes jButtonBrowse
714 @return javax.swing.JButton
716 private JButton
getJButtonBrowse() {
717 if (jButtonBrowse
== null) {
718 jButtonBrowse
= new JButton();
719 jButtonBrowse
.setBounds(new java
.awt
.Rectangle(527,75,90,20));
720 jButtonBrowse
.setText("Browse");
721 jButtonBrowse
.setPreferredSize(new java
.awt
.Dimension(99,20));
722 jButtonBrowse
.addActionListener(new AbstractAction() {
727 private static final long serialVersionUID
= 1L;
729 public void actionPerformed(ActionEvent arg0
) {
731 // Select files from current pkg
733 String dirPrefix
= Tools
.dirForNewSpd
.substring(0, Tools
.dirForNewSpd
.lastIndexOf(File
.separator
));
734 JFileChooser chooser
= new JFileChooser(dirPrefix
);
736 String headerDest
= null;
738 chooser
.setMultiSelectionEnabled(false);
739 chooser
.setFileSelectionMode(JFileChooser
.FILES_AND_DIRECTORIES
);
740 int retval
= chooser
.showOpenDialog(frame
);
741 if (retval
== JFileChooser
.APPROVE_OPTION
) {
743 theFile
= chooser
.getSelectedFile();
744 String file
= theFile
.getPath();
745 if (!file
.startsWith(dirPrefix
)) {
746 JOptionPane
.showMessageDialog(frame
, "You can only select files in current package directory structure!");
756 headerDest
= theFile
.getPath();
757 int fileIndex
= headerDest
.indexOf(System
.getProperty("file.separator"), dirPrefix
.length());
758 jTextFieldHdr
.setText(headerDest
.substring(fileIndex
+ 1).replace('\\', '/'));
764 return jButtonBrowse
;
767 public void componentResized(ComponentEvent arg0
) {
768 int intPreferredWidth
= 500;
770 Tools
.resizeComponentWidth(this.jTextFieldClass
, this.getWidth(), intPreferredWidth
);
771 Tools
.resizeComponentWidth(this.jTextFieldHelp
, this.getWidth(), intPreferredWidth
);
772 Tools
.resizeComponentWidth(this.jScrollPane
, this.getWidth(), intPreferredWidth
-10);
776 * This method initializes jTextFieldHelp
778 * @return javax.swing.JTextField
780 private JTextField
getJTextFieldHelp() {
781 if (jTextFieldHelp
== null) {
782 jTextFieldHelp
= new JTextField();
783 jTextFieldHelp
.setBounds(new java
.awt
.Rectangle(122,33,390,20));
784 jTextFieldHelp
.setPreferredSize(new java
.awt
.Dimension(260,20));
786 return jTextFieldHelp
;
790 * This method initializes jTextField1RecInstName
792 * @return javax.swing.JTextField
794 private JTextField
getJTextField1RecInstName() {
795 if (jTextField1RecInstName
== null) {
796 jTextField1RecInstName
= new JTextField();
797 jTextField1RecInstName
.setBounds(new java
.awt
.Rectangle(218,110,291,20));
798 jTextField1RecInstName
.setEnabled(true);
799 jTextField1RecInstName
.setVisible(false);
801 return jTextField1RecInstName
;
805 * This method initializes jTextField2RecInstVer
807 * @return javax.swing.JTextField
809 private JTextField
getJTextField2RecInstVer() {
810 if (jTextField2RecInstVer
== null) {
811 jTextField2RecInstVer
= new JTextField();
812 jTextField2RecInstVer
.setBounds(new java
.awt
.Rectangle(218,135,292,20));
813 jTextField2RecInstVer
.setEnabled(true);
815 return jTextField2RecInstVer
;
818 private JScrollPane
getJScrollPaneModules() {
819 if (jScrollPaneModules
== null) {
820 jScrollPaneModules
= new JScrollPane();
821 jScrollPaneModules
.setBounds(new java
.awt
.Rectangle(218,245,293,73));
822 jScrollPaneModules
.setPreferredSize(new java
.awt
.Dimension(320, 80));
823 jScrollPaneModules
.setViewportView(getICheckBoxListSupportedModules());
825 return jScrollPaneModules
;
828 private ICheckBoxList
getICheckBoxListSupportedModules() {
829 if (iCheckBoxListModules
== null) {
830 iCheckBoxListModules
= new ICheckBoxList();
831 iCheckBoxListModules
.setBounds(new java
.awt
.Rectangle(218,246,292,73));
832 Vector
<String
> v
= new Vector
<String
>();
839 v
.add("DXE_RUNTIME_DRIVER");
840 v
.add("DXE_SAL_DRIVER");
841 v
.add("DXE_SMM_DRIVER");
842 v
.add("UEFI_DRIVER");
843 v
.add("UEFI_APPLICATION");
844 v
.add("USER_DEFINED");
845 iCheckBoxListModules
.setAllItems(v
);
847 return iCheckBoxListModules
;
850 private String
vectorToString(Vector
<String
> v
) {
852 for (int i
= 0; i
< v
.size(); ++i
) {
859 private JScrollPane
getJScrollPane1Arch() {
860 if (jScrollPane1Arch
== null) {
861 jScrollPane1Arch
= new JScrollPane();
862 jScrollPane1Arch
.setBounds(new java
.awt
.Rectangle(218,170,293,73));
863 jScrollPane1Arch
.setPreferredSize(new java
.awt
.Dimension(320, 80));
864 jScrollPane1Arch
.setViewportView(getICheckBoxListArch());
866 return jScrollPane1Arch
;
869 * This method initializes iCheckBoxList
871 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
873 private ICheckBoxList
getICheckBoxListArch() {
874 if (iCheckBoxListArch
== null) {
875 iCheckBoxListArch
= new ICheckBoxList();
876 iCheckBoxListArch
.setBounds(new java
.awt
.Rectangle(218,171,292,66));
877 Vector
<String
> v
= new Vector
<String
>();
884 iCheckBoxListArch
.setAllItems(v
);
886 return iCheckBoxListArch
;
890 * This method initializes jComboBox
892 * @return javax.swing.JComboBox
894 private JComboBox
getJComboBox() {
895 if (jComboBox
== null) {
896 jComboBox
= new JComboBox();
897 jComboBox
.setPreferredSize(new java
.awt
.Dimension(31,20));
898 jComboBox
.setSize(new java
.awt
.Dimension(290,20));
899 jComboBox
.setLocation(new java
.awt
.Point(218,111));
900 jComboBox
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
901 public void focusGained(java
.awt
.event
.FocusEvent e
) {
902 if (jTextFieldClass
.getText().length() == 0) {
905 jComboBox
.removeAllItems();
906 getLibInstances(jTextFieldClass
.getText());
907 Set
<String
> libNames
= libNameGuidMap
.keySet();
908 Iterator
<String
> si
= libNames
.iterator();
909 while(si
.hasNext()) {
910 jComboBox
.addItem(si
.next());
919 private void getLibInstances(String libClass
){
920 libNameGuidMap
.clear();
922 WorkspaceProfile
.initInfo("Tools" + File
.separator
+ "Conf" + File
.separator
+ "FrameworkDatabase.db", System
.getenv("WORKSPACE"));
924 Set
<PackageIdentification
> spi
= WorkspaceProfile
.getPackageList();
925 Iterator ispi
= spi
.iterator();
927 while (ispi
.hasNext()) {
928 PackageIdentification pi
= (PackageIdentification
) ispi
.next();
930 Set
<ModuleIdentification
> smi
= WorkspaceProfile
.getModules(pi
);
931 Iterator ismi
= smi
.iterator();
932 while (ismi
.hasNext()) {
933 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
934 Map
<String
, XmlObject
> m
= WorkspaceProfile
.getNativeMsa(mi
);
935 SurfaceAreaQuery
.setDoc(m
);
936 Vector
<String
> classProduced
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED", mi
);
937 for (int i
= 0; i
< classProduced
.size(); ++i
) {
938 if (classProduced
.get(i
).equals(libClass
)) {
939 libNameGuidMap
.put(mi
.getName(), mi
.getGuid());
946 JOptionPane
.showMessageDialog(frame
, "Search Instances Failed.");
951 private String
nameToGuid(String name
) {
953 if (!libNameGuidMap
.containsKey(name
)) {
957 s
= libNameGuidMap
.get(name
);
961 private String
guidToName(String guid
){
963 if (!libNameGuidMap
.containsValue(guid
)) {
966 Set
<String
> key
= libNameGuidMap
.keySet();
967 Iterator
<String
> is
= key
.iterator();
968 while(is
.hasNext()) {
970 if (libNameGuidMap
.get(s
).equals(guid
)) {