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 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,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
);
314 JOptionPane
.showMessageDialog(frame
, "Recommended Instance NOT exists.");
319 String
[] sa
= new String
[7];
320 sfc
.getSpdLibClassDeclaration(sa
, row
);
321 Object cellData
= m
.getValueAt(row
, column
);
322 if (cellData
== null) {
325 if (column
== cnRecInstName
) {
327 if (sa
[cnRecInstName
] == null) {
332 if (guid
.equals(sa
[cnRecInstName
])) {
338 if (cellData
.equals(sa
[column
])) {
341 if (cellData
.toString().length() == 0 && sa
[column
] == null) {
345 docConsole
.setSaved(false);
346 sfc
.updateSpdLibClass(row
, lib
, hdr
, hlp
, guid
, ver
, arch
, module
);
351 This method initializes jButtonAdd
353 @return javax.swing.JButton
355 private JButton
getJButtonAdd() {
356 if (jButtonAdd
== null) {
357 jButtonAdd
= new JButton();
358 jButtonAdd
.setText("Add");
359 jButtonAdd
.setSize(new java
.awt
.Dimension(99,20));
360 jButtonAdd
.setBounds(new java
.awt
.Rectangle(321,326,99,20));
361 jButtonAdd
.addActionListener(this);
367 This method initializes jButtonRemove
369 @return javax.swing.JButton
371 private JButton
getJButtonRemove() {
372 if (jButtonRemove
== null) {
373 jButtonRemove
= new JButton();
374 jButtonRemove
.setText("Remove");
375 jButtonRemove
.setSize(new java
.awt
.Dimension(99,20));
376 jButtonRemove
.setBounds(new java
.awt
.Rectangle(424,326,99,20));
377 jButtonRemove
.addActionListener(this);
379 return jButtonRemove
;
383 This method initializes jButtonRemoveAll
385 @return javax.swing.JButton
387 private JButton
getJButtonRemoveAll() {
388 if (jButtonRemoveAll
== null) {
389 jButtonRemoveAll
= new JButton();
390 jButtonRemoveAll
.setText("Remove All");
391 jButtonRemoveAll
.setSize(new java
.awt
.Dimension(99,20));
392 jButtonRemoveAll
.setBounds(new java
.awt
.Rectangle(527,326,99,20));
393 jButtonRemoveAll
.addActionListener(this);
395 return jButtonRemoveAll
;
399 This is the default constructor
401 public SpdLibClassDecls() {
408 public SpdLibClassDecls(PackageSurfaceAreaDocument
.PackageSurfaceArea inPsa
){
410 sfc
= new SpdFileContents(inPsa
);
414 public SpdLibClassDecls(OpeningPackageType opt
) {
415 this(opt
.getXmlSpd());
419 This method initializes this
423 private void init() {
425 this.setContentPane(getJContentPane());
426 this.setTitle("Library Class Declarations");
427 this.setBounds(new java
.awt
.Rectangle(0, 0, 500, 370));
428 this.setVisible(true);
429 this.addInternalFrameListener(new InternalFrameAdapter(){
430 public void internalFrameDeactivated(InternalFrameEvent e
){
431 if (jTable
.isEditing()) {
432 jTable
.getCellEditor().stopCellEditing();
439 private void init(SpdFileContents sfc
) {
440 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
444 // initialize table using SpdFileContents object
446 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][7];
447 sfc
.getSpdLibClassDeclarations(saa
);
449 while (i
< saa
.length
) {
450 if (saa
[i
][3] != null && saa
[i
][3].length() > 0) {
451 getLibInstances(saa
[i
][0]);
452 saa
[i
][3] = guidToName(saa
[i
][3]);
455 model
.addRow(saa
[i
]);
459 private JScrollPane
getJContentPane(){
460 if (topScrollPane
== null){
461 topScrollPane
= new JScrollPane();
462 // topScrollPane.setSize(new java.awt.Dimension(634,590));
463 topScrollPane
.setViewportView(getJContentPane1());
465 return topScrollPane
;
468 This method initializes jContentPane
470 @return javax.swing.JPanel
472 private JPanel
getJContentPane1() {
473 if (jContentPane
== null) {
475 jStarLabel1
= new StarLabel();
476 jStarLabel1
.setLocation(new java
.awt
.Point(1,7));
477 jLabel1ClassName
= new JLabel();
478 jLabel1ClassName
.setBounds(new java
.awt
.Rectangle(16,6,82,20));
479 jLabel1ClassName
.setText("Library Class");
482 starLabel
= new StarLabel();
483 starLabel
.setBounds(new java
.awt
.Rectangle(1,33,10,20));
484 jLabel2HelpText
= new JLabel();
485 jLabel2HelpText
.setBounds(new java
.awt
.Rectangle(16,33,82,20));
486 jLabel2HelpText
.setText("Help Text");
489 jStarLabel2
= new StarLabel();
490 jStarLabel2
.setLocation(new java
.awt
.Point(1,74));
491 jLabelHdr
= new JLabel();
492 jLabelHdr
.setBounds(new java
.awt
.Rectangle(14,74,199,22));
493 jLabelHdr
.setText("Include Header for Specified Class");
495 jLabel6SupModList
= new JLabel();
496 jLabel6SupModList
.setBounds(new java
.awt
.Rectangle(16,252,108,16));
497 jLabel6SupModList
.setText("Supported Module");
498 jLabel6SupModList
.setEnabled(true);
500 jLabel5SupArchList
= new JLabel();
501 jLabel5SupArchList
.setBounds(new java
.awt
.Rectangle(15,169,93,16));
502 jLabel5SupArchList
.setText("Supported Arch");
503 jLabel5SupArchList
.setEnabled(true);
504 jLabel4RecInstVer
= new JLabel();
505 jLabel4RecInstVer
.setBounds(new java
.awt
.Rectangle(16,138,196,16));
506 jLabel4RecInstVer
.setEnabled(true);
507 jLabel4RecInstVer
.setText("Recommended Instance Version");
508 jLabel3RecInstName
= new JLabel();
509 jLabel3RecInstName
.setBounds(new java
.awt
.Rectangle(17,112,195,16));
510 jLabel3RecInstName
.setEnabled(true);
511 jLabel3RecInstName
.setText("Recommended Instance Name");
513 jContentPane
= new JPanel();
514 jContentPane
.setPreferredSize(new Dimension(680, 600));
515 jContentPane
.setLayout(null);
516 jContentPane
.add(jLabelHdr
, null);
517 jContentPane
.add(jStarLabel1
, null);
518 jContentPane
.add(jStarLabel2
, null);
519 jContentPane
.add(getJTextFieldClass(), null);
520 jContentPane
.add(getJComboBoxSelect(), null);
521 jContentPane
.add(getJScrollPane(), null);
522 jContentPane
.add(getJButtonAdd(), null);
523 jContentPane
.add(getJButtonRemove(), null);
524 jContentPane
.add(getJButtonRemoveAll(), null);
526 jContentPane
.add(getJTextFieldHdr(), null);
527 jContentPane
.add(getJButtonBrowse(), null);
528 jContentPane
.add(jLabel1ClassName
, null);
529 jContentPane
.add(starLabel
, null);
530 jContentPane
.add(jLabel2HelpText
, null);
531 jContentPane
.add(getJTextFieldHelp(), null);
533 jContentPane
.add(jLabel3RecInstName
, null);
534 jContentPane
.add(getJTextField1RecInstName(), null);
535 jContentPane
.add(jLabel4RecInstVer
, null);
536 jContentPane
.add(getJTextField2RecInstVer(), null);
537 jContentPane
.add(jLabel5SupArchList
, null);
538 jContentPane
.add(jLabel6SupModList
, null);
540 jContentPane
.add(getJScrollPaneModules(), null);
541 jContentPane
.add(getJScrollPane1Arch(), null);
542 jContentPane
.add(getJComboBox(), null);
550 fill ComboBoxes with pre-defined contents
552 private void initFrame() {
553 jComboBoxSelect
.addItem("BaseCpuICacheFlush");
554 jComboBoxSelect
.addItem("BaseDebugLibNull");
555 jComboBoxSelect
.addItem("BaseDebugLibReportStatusCode");
556 jComboBoxSelect
.addItem("BaseIoLibIntrinsic");
557 jComboBoxSelect
.addItem("BaseLib");
558 jComboBoxSelect
.addItem("BaseMemoryLib");
559 jComboBoxSelect
.addItem("BaseMemoryLibMmx");
560 jComboBoxSelect
.addItem("BaseMemoryLibSse2");
561 jComboBoxSelect
.addItem("BasePeCoffGetEntryPointLib");
562 jComboBoxSelect
.addItem("BasePeCoffLib");
563 jComboBoxSelect
.addItem("BasePrintLib");
564 jComboBoxSelect
.addItem("BaseReportStatusCodeLibNull");
565 jComboBoxSelect
.addItem("CommonPciCf8Lib");
566 jComboBoxSelect
.addItem("CommonPciExpressLib");
567 jComboBoxSelect
.addItem("CommonPciLibCf8");
568 jComboBoxSelect
.addItem("CommonPciLibPciExpress");
569 jComboBoxSelect
.addItem("DxeCoreEntryPoint");
570 jComboBoxSelect
.addItem("DxeHobLib");
571 jComboBoxSelect
.addItem("DxeIoLibCpuIo");
572 jComboBoxSelect
.addItem("DxeLib");
573 jComboBoxSelect
.addItem("DxePcdLib");
574 jComboBoxSelect
.addItem("DxeReportStatusCodeLib");
575 jComboBoxSelect
.addItem("DxeServicesTableLib");
576 jComboBoxSelect
.addItem("PeiCoreEntryPoint");
577 jComboBoxSelect
.addItem("PeiMemoryLib");
578 jComboBoxSelect
.addItem("PeimEntryPoint");
579 jComboBoxSelect
.addItem("PeiReportStatusCodeLib");
580 jComboBoxSelect
.addItem("PeiServicesTablePointerLib");
581 jComboBoxSelect
.addItem("PeiServicesTablePointerLibMm7");
582 jComboBoxSelect
.addItem("UefiDebugLibConOut");
583 jComboBoxSelect
.addItem("UefiDebugLibStdErr");
584 jComboBoxSelect
.addItem("UefiDriverEntryPointMultiple");
585 jComboBoxSelect
.addItem("UefiDriverEntryPointSingle");
586 jComboBoxSelect
.addItem("UefiDriverEntryPointSingleUnload");
587 jComboBoxSelect
.addItem("UefiDriverModelLib");
588 jComboBoxSelect
.addItem("UefiDriverModelLibNoConfigNoDiag");
589 jComboBoxSelect
.addItem("UefiLib");
590 jComboBoxSelect
.addItem("UefiMemoryLib");
595 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
597 public void actionPerformed(ActionEvent arg0
) {
599 if (arg0
.getSource() == jButtonAdd
) {
601 //ToDo: check before add
602 // LAH WAS String[] row = {null, null, null, jComboBox.getSelectedItem()+"", jTextField2RecInstVer.getText(), null, null};
603 String
[] row
= {null, null, null, null, null, null, null};
604 row
[cnClassName
] = jTextFieldClass
.getText();
605 row
[cnHdrFile
] = jTextFieldHdr
.getText().replace('\\', '/');
606 row
[cnHelpText
] = jTextFieldHelp
.getText();
607 row
[cnRecInstName
] = jComboBox
.getSelectedItem()+"";
608 row
[cnRecInstVer
] = jTextField2RecInstVer
.getText();
609 row
[cnSupArch
] = vectorToString(iCheckBoxListArch
.getAllCheckedItemsString());
610 if (row
[cnSupArch
].length() == 0) {
611 row
[cnSupArch
] = null;
613 row
[cnSupMod
] = vectorToString(iCheckBoxListModules
.getAllCheckedItemsString());
614 if (row
[cnSupMod
].length() == 0){
615 row
[cnSupMod
] = null;
617 if (!dataValidation(row
)) {
621 //convert to GUID before storing recommended lib instance.
623 getLibInstances(row
[cnClassName
]);
624 String recommendGuid
= nameToGuid(row
[cnRecInstName
]);
625 if (row
[cnRecInstName
].equals("null")) {
626 row
[cnRecInstName
] = null;
629 if (recommendGuid
== null) {
630 JOptionPane
.showMessageDialog(frame
, "Recommended Instance NOT exists.");
635 sfc
.genSpdLibClassDeclarations(row
[cnClassName
], recommendGuid
, row
[cnHdrFile
], row
[cnHelpText
], row
[cnSupArch
], null, null, row
[cnRecInstVer
], null, row
[cnSupMod
]);
637 jTable
.changeSelection(model
.getRowCount()-1, 0, false, false);
638 docConsole
.setSaved(false);
641 // remove selected line
643 if (arg0
.getSource() == jButtonRemove
) {
644 if (jTable
.isEditing()){
645 jTable
.getCellEditor().stopCellEditing();
647 int rowSelected
= selectedRow
;
648 if (rowSelected
>= 0) {
649 model
.removeRow(rowSelected
);
650 docConsole
.setSaved(false);
651 sfc
.removeSpdLibClass(rowSelected
);
655 if (arg0
.getSource() == jButtonRemoveAll
) {
656 if (model
.getRowCount() == 0) {
659 docConsole
.setSaved(false);
660 model
.setRowCount(0);
661 sfc
.removeSpdLibClass();
665 private boolean dataValidation(String
[] row
) {
666 if (!DataValidation
.isKeywordType(row
[cnClassName
])) {
667 JOptionPane
.showMessageDialog(frame
, "Library Class is NOT KeyWord Type.");
670 if (!DataValidation
.isPathAndFilename(row
[cnHdrFile
])) {
671 JOptionPane
.showMessageDialog(frame
, "Include Header is NOT PathAndFilename Type.");
674 if (row
[cnHelpText
].length() == 0) {
675 JOptionPane
.showMessageDialog(frame
, "Help Text Must NOT be empty.");
678 if (row
[cnRecInstVer
] != null && row
[cnRecInstVer
].length() > 0) {
679 if (row
[cnRecInstName
] == null || row
[cnRecInstName
].length() == 0) {
680 JOptionPane
.showMessageDialog(frame
, "Recommended Instance Version must associate with Instance Name.");
684 if (!DataValidation
.isVersionDataType(row
[cnRecInstVer
])) {
685 JOptionPane
.showMessageDialog(frame
, "Recommended Instance Version is NOT VersionDataType.");
692 Add contents in list to sfc
694 protected void save() {
699 This method initializes jTextField
701 @return javax.swing.JTextField
703 private JTextField
getJTextFieldHdr() {
704 if (jTextFieldHdr
== null) {
705 jTextFieldHdr
= new JTextField();
706 jTextFieldHdr
.setBounds(new java
.awt
.Rectangle(218,75,305,21));
707 jTextFieldHdr
.setPreferredSize(new java
.awt
.Dimension(260,20));
709 return jTextFieldHdr
;
713 This method initializes jButtonBrowse
715 @return javax.swing.JButton
717 private JButton
getJButtonBrowse() {
718 if (jButtonBrowse
== null) {
719 jButtonBrowse
= new JButton();
720 jButtonBrowse
.setBounds(new java
.awt
.Rectangle(527,75,90,20));
721 jButtonBrowse
.setText("Browse");
722 jButtonBrowse
.setPreferredSize(new java
.awt
.Dimension(99,20));
723 jButtonBrowse
.addActionListener(new AbstractAction() {
728 private static final long serialVersionUID
= 1L;
730 public void actionPerformed(ActionEvent arg0
) {
732 // Select files from current pkg
734 String dirPrefix
= Tools
.dirForNewSpd
.substring(0, Tools
.dirForNewSpd
.lastIndexOf(File
.separator
));
735 JFileChooser chooser
= new JFileChooser(dirPrefix
);
737 String headerDest
= null;
739 chooser
.setMultiSelectionEnabled(false);
740 chooser
.setFileSelectionMode(JFileChooser
.FILES_AND_DIRECTORIES
);
741 int retval
= chooser
.showOpenDialog(frame
);
742 if (retval
== JFileChooser
.APPROVE_OPTION
) {
744 theFile
= chooser
.getSelectedFile();
745 String file
= theFile
.getPath();
746 if (!file
.startsWith(dirPrefix
)) {
747 JOptionPane
.showMessageDialog(frame
, "You can only select files in current package!");
757 headerDest
= theFile
.getPath();
758 int fileIndex
= headerDest
.indexOf(System
.getProperty("file.separator"), dirPrefix
.length());
759 jTextFieldHdr
.setText(headerDest
.substring(fileIndex
+ 1).replace('\\', '/'));
765 return jButtonBrowse
;
768 public void componentResized(ComponentEvent arg0
) {
769 int intPreferredWidth
= 500;
771 resizeComponentWidth(this.jTextFieldClass
, this.getWidth(), intPreferredWidth
);
772 resizeComponentWidth(this.jTextFieldHelp
, this.getWidth(), intPreferredWidth
);
773 resizeComponentWidth(this.jScrollPane
, this.getWidth(), intPreferredWidth
-10);
777 * This method initializes jTextFieldHelp
779 * @return javax.swing.JTextField
781 private JTextField
getJTextFieldHelp() {
782 if (jTextFieldHelp
== null) {
783 jTextFieldHelp
= new JTextField();
784 jTextFieldHelp
.setBounds(new java
.awt
.Rectangle(122,33,390,20));
785 jTextFieldHelp
.setPreferredSize(new java
.awt
.Dimension(260,20));
787 return jTextFieldHelp
;
791 * This method initializes jTextField1RecInstName
793 * @return javax.swing.JTextField
795 private JTextField
getJTextField1RecInstName() {
796 if (jTextField1RecInstName
== null) {
797 jTextField1RecInstName
= new JTextField();
798 jTextField1RecInstName
.setBounds(new java
.awt
.Rectangle(218,110,291,20));
799 jTextField1RecInstName
.setEnabled(true);
800 jTextField1RecInstName
.setVisible(false);
802 return jTextField1RecInstName
;
806 * This method initializes jTextField2RecInstVer
808 * @return javax.swing.JTextField
810 private JTextField
getJTextField2RecInstVer() {
811 if (jTextField2RecInstVer
== null) {
812 jTextField2RecInstVer
= new JTextField();
813 jTextField2RecInstVer
.setBounds(new java
.awt
.Rectangle(218,135,292,20));
814 jTextField2RecInstVer
.setEnabled(true);
816 return jTextField2RecInstVer
;
819 private JScrollPane
getJScrollPaneModules() {
820 if (jScrollPaneModules
== null) {
821 jScrollPaneModules
= new JScrollPane();
822 jScrollPaneModules
.setBounds(new java
.awt
.Rectangle(218,245,293,73));
823 jScrollPaneModules
.setPreferredSize(new java
.awt
.Dimension(320, 80));
824 jScrollPaneModules
.setViewportView(getICheckBoxListSupportedModules());
826 return jScrollPaneModules
;
829 private ICheckBoxList
getICheckBoxListSupportedModules() {
830 if (iCheckBoxListModules
== null) {
831 iCheckBoxListModules
= new ICheckBoxList();
832 iCheckBoxListModules
.setBounds(new java
.awt
.Rectangle(218,246,292,73));
833 Vector
<String
> v
= new Vector
<String
>();
840 v
.add("DXE_RUNTIME_DRIVER");
841 v
.add("DXE_SAL_DRIVER");
842 v
.add("DXE_SMM_DRIVER");
843 v
.add("UEFI_DRIVER");
844 v
.add("UEFI_APPLICATION");
845 v
.add("USER_DEFINED");
846 iCheckBoxListModules
.setAllItems(v
);
848 return iCheckBoxListModules
;
851 private String
vectorToString(Vector
<String
> v
) {
853 for (int i
= 0; i
< v
.size(); ++i
) {
860 private JScrollPane
getJScrollPane1Arch() {
861 if (jScrollPane1Arch
== null) {
862 jScrollPane1Arch
= new JScrollPane();
863 jScrollPane1Arch
.setBounds(new java
.awt
.Rectangle(218,170,293,73));
864 jScrollPane1Arch
.setPreferredSize(new java
.awt
.Dimension(320, 80));
865 jScrollPane1Arch
.setViewportView(getICheckBoxListArch());
867 return jScrollPane1Arch
;
870 * This method initializes iCheckBoxList
872 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
874 private ICheckBoxList
getICheckBoxListArch() {
875 if (iCheckBoxListArch
== null) {
876 iCheckBoxListArch
= new ICheckBoxList();
877 iCheckBoxListArch
.setBounds(new java
.awt
.Rectangle(218,171,292,66));
878 Vector
<String
> v
= new Vector
<String
>();
885 iCheckBoxListArch
.setAllItems(v
);
887 return iCheckBoxListArch
;
891 * This method initializes jComboBox
893 * @return javax.swing.JComboBox
895 private JComboBox
getJComboBox() {
896 if (jComboBox
== null) {
897 jComboBox
= new JComboBox();
898 jComboBox
.setPreferredSize(new java
.awt
.Dimension(31,20));
899 jComboBox
.setSize(new java
.awt
.Dimension(290,20));
900 jComboBox
.setLocation(new java
.awt
.Point(218,111));
901 jComboBox
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
902 public void focusGained(java
.awt
.event
.FocusEvent e
) {
903 if (jTextFieldClass
.getText().length() == 0) {
906 jComboBox
.removeAllItems();
907 getLibInstances(jTextFieldClass
.getText());
908 Set
<String
> libNames
= libNameGuidMap
.keySet();
909 Iterator
<String
> si
= libNames
.iterator();
910 while(si
.hasNext()) {
911 jComboBox
.addItem(si
.next());
920 private void getLibInstances(String libClass
){
921 libNameGuidMap
.clear();
923 GlobalData
.initInfo("Tools" + File
.separator
+ "Conf" + File
.separator
+ "FrameworkDatabase.db", System
.getenv("WORKSPACE"));
925 Set
<PackageIdentification
> spi
= GlobalData
.getPackageList();
926 Iterator ispi
= spi
.iterator();
928 while (ispi
.hasNext()) {
929 PackageIdentification pi
= (PackageIdentification
) ispi
.next();
931 Set
<ModuleIdentification
> smi
= GlobalData
.getModules(pi
);
932 Iterator ismi
= smi
.iterator();
933 while (ismi
.hasNext()) {
934 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
935 Map
<String
, XmlObject
> m
= GlobalData
.getNativeMsa(mi
);
936 SurfaceAreaQuery
.setDoc(m
);
937 Vector
<String
> classProduced
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED", mi
);
938 for (int i
= 0; i
< classProduced
.size(); ++i
) {
939 if (classProduced
.get(i
).equals(libClass
)) {
940 libNameGuidMap
.put(mi
.getName(), mi
.getGuid());
947 JOptionPane
.showMessageDialog(frame
, "Search Instances Fail.");
952 private String
nameToGuid(String name
) {
954 if (!libNameGuidMap
.containsKey(name
)) {
958 s
= libNameGuidMap
.get(name
);
962 private String
guidToName(String guid
){
964 if (!libNameGuidMap
.containsValue(guid
)) {
967 Set
<String
> key
= libNameGuidMap
.keySet();
968 Iterator
<String
> is
= key
.iterator();
969 while(is
.hasNext()) {
971 if (libNameGuidMap
.get(s
).equals(guid
)) {