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
.JTextArea
;
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
;
45 import org
.tianocore
.PackageSurfaceAreaDocument
;
46 import org
.tianocore
.frameworkwizard
.common
.DataType
;
47 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
48 import org
.tianocore
.frameworkwizard
.common
.GlobalData
;
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
.LongTextEditor
;
56 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
57 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
61 GUI for create library definition elements of spd file.
63 @since PackageEditor 1.0
65 public class SpdLibClassDecls
extends IInternalFrame
implements TableModelListener
{
69 private static final long serialVersionUID
= 1L;
73 private JTable jTable
= null;
75 private DefaultTableModel model
= null;
77 private JPanel jContentPane
= null;
79 private JTextField jTextFieldAddClass
= null;
81 private JComboBox jComboBoxSelect
= null;
83 private JScrollPane jScrollPaneTable
= null;
85 private JButton jButtonAdd
= null;
87 private JButton jButtonRemove
= null;
89 private JButton jButtonRemoveAll
= null;
91 private JLabel jLabelHdr
= null;
93 private JTextField jTextFieldHdr
= null;
95 private JButton jButtonBrowse
= null;
97 private StarLabel starLabel1
= null;
99 private StarLabel starLabel3
= null;
101 private SpdFileContents sfc
= null;
103 private OpeningPackageType docConsole
= null;
105 private JLabel jLabel1ClassName
= null;
107 private JScrollPane topScrollPane
= null; // @jve:decl-index=0:visual-constraint="10,53"
109 private int selectedRow
= -1;
111 private StarLabel starLabel2
= null;
113 private JLabel jLabel2HelpText
= null;
115 private JTextArea jTextAreaHelp
= null;
117 private JScrollPane jHelpTextScrollPane
= null;
119 private JLabel jLabel3RecInstName
= null;
121 private JTextField jTextField1RecInstName
= null;
123 private JLabel jLabel4RecInstVer
= null;
125 private JTextField jTextField2RecInstVer
= null;
127 private JLabel jLabel5SupArchList
= null;
129 private JLabel jLabel6SupModList
= null;
131 private JScrollPane jScrollPaneModules
= null;
133 private JScrollPane jScrollPane1Arch
= null;
135 private ICheckBoxList iCheckBoxListModules
= null;
137 private ICheckBoxList iCheckBoxListArch
= null;
139 private JComboBox jComboBox
= null;
141 private int cnClassName
= 0;
142 private int cnHdrFile
= 1;
143 private int cnHelpText
= 2;
144 private int cnRecInstName
= 3;
145 private int cnRecInstVer
= 4;
146 private int cnSupArch
= 5;
147 private int cnSupMod
= 6;
149 private final int shortLabel
= 90;
150 private final int longLabel
= 220;
151 private final int labelCol
= 12;
152 private final int shortValueCol
= labelCol
+ shortLabel
+ 6;
153 private final int longValueCol
= labelCol
+ longLabel
+ 6;
154 private final int longValueWidth
= 347;
155 private final int shortWidth
= 140;
156 private final int medWidth
= 240;
158 private final int buttonWidth
= 99;
160 private final int addButtonCol
= shortValueCol
+ 10;
161 private final int removeButtonCol
= addButtonCol
+ buttonWidth
+ 10;
162 private final int removeAllButtonCol
= removeButtonCol
+ buttonWidth
+ 10;
164 private final int rowOne
= 12;
165 private final int rowTwo
= rowOne
+ 25;
166 private final int rowThree
= rowTwo
+ 60 + 25;
167 private final int rowFour
= rowThree
+ 25;
168 private final int rowFive
= rowFour
+ 40 + 25;
169 private final int rowSix
= rowFive
+ 40 + 25;
170 private final int rowSeven
= rowSix
;
171 private final int rowEight
= rowSeven
+ 30;
173 HashMap
<String
, String
> libNameGuidMap
= new HashMap
<String
, String
>();
177 This method initializes this
180 private void initialize() {
182 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
187 This method initializes jTextFieldAddClass
189 @return javax.swing.JTextField
191 private JTextField
getJTextFieldAddClass() {
192 if (jTextFieldAddClass
== null) {
193 jTextFieldAddClass
= new JTextField();
194 jTextFieldAddClass
.setBounds(new java
.awt
.Rectangle(shortValueCol
,rowOne
,longValueWidth
,20));
195 jTextFieldAddClass
.setPreferredSize(new java
.awt
.Dimension(longValueWidth
,20));
196 jTextFieldAddClass
.setEnabled(true);
198 return jTextFieldAddClass
;
202 This method initializes jComboBoxSelect
204 @return javax.swing.JComboBox
206 private JComboBox
getJComboBoxSelect() {
207 if (jComboBoxSelect
== null) {
208 jComboBoxSelect
= new JComboBox();
209 jComboBoxSelect
.setBounds(new java
.awt
.Rectangle(220, 10, 260, 20));
210 jComboBoxSelect
.setPreferredSize(new java
.awt
.Dimension(260,22));
211 jComboBoxSelect
.setEnabled(true);
212 jComboBoxSelect
.setVisible(false);
214 return jComboBoxSelect
;
218 This method initializes jScrollPaneTable
220 @return javax.swing.JScrollPane
222 Used for the Table of Library Classes that are provided by this package
225 private JScrollPane
getJScrollPaneTable() {
226 if (jScrollPaneTable
== null) {
227 jScrollPaneTable
= new JScrollPane();
228 jScrollPaneTable
.setBounds(new java
.awt
.Rectangle(labelCol
,rowEight
,400,253));
229 jScrollPaneTable
.setViewportView(getJTable());
231 return jScrollPaneTable
;
235 This method initializes jTable
237 @return javax.swing.JTable
239 private JTable
getJTable() {
240 if (jTable
== null) {
241 model
= new DefaultTableModel();
242 jTable
= new JTable(model
);
243 jTable
.setRowHeight(20);
244 jTable
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
245 jTable
.setColumnSelectionAllowed(false);
246 model
.addColumn("Class Name");
247 model
.addColumn("Header");
248 model
.addColumn("Help Text");
249 model
.addColumn("Recommended Instance");
250 model
.addColumn("Version");
251 model
.addColumn("Supported Architectures");
252 model
.addColumn("Supported Module Types");
254 jTable
.getColumnModel().getColumn(cnHelpText
).setCellEditor(new LongTextEditor());
256 Vector
<String
> vArch
= new Vector
<String
>();
263 jTable
.getColumnModel().getColumn(cnSupArch
).setCellEditor(new ListEditor(vArch
));
265 Vector
<String
> vModule
= new Vector
<String
>();
268 vModule
.add("PEI_CORE");
270 vModule
.add("DXE_CORE");
271 vModule
.add("DXE_DRIVER");
272 vModule
.add("DXE_RUNTIME_DRIVER");
273 vModule
.add("DXE_SAL_DRIVER");
274 vModule
.add("DXE_SMM_DRIVER");
275 vModule
.add("UEFI_DRIVER");
276 vModule
.add("UEFI_APPLICATION");
277 vModule
.add("USER_DEFINED");
279 jTable
.getColumnModel().getColumn(cnSupMod
).setCellEditor(new ListEditor(vModule
));
281 jTable
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
282 jTable
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
283 public void valueChanged(ListSelectionEvent e
) {
284 if (e
.getValueIsAdjusting()){
287 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
288 if (lsm
.isSelectionEmpty()) {
292 selectedRow
= lsm
.getMinSelectionIndex();
297 jTable
.getModel().addTableModelListener(this);
304 public void tableChanged(TableModelEvent arg0
) {
305 // TODO Auto-generated method stub
306 int row
= arg0
.getFirstRow();
307 int column
= arg0
.getColumn();
308 TableModel m
= (TableModel
)arg0
.getSource();
309 if (arg0
.getType() == TableModelEvent
.UPDATE
){
311 String lib
= m
.getValueAt(row
, cnClassName
) + "";
312 String hdr
= m
.getValueAt(row
, cnHdrFile
) + "";
313 String hlp
= m
.getValueAt(row
, cnHelpText
) + "";
315 if (m
.getValueAt(row
, cnRecInstName
) != null) {
316 name
= m
.getValueAt(row
, cnRecInstName
).toString();
319 if (m
.getValueAt(row
, cnRecInstVer
) != null){
320 ver
= m
.getValueAt(row
, cnRecInstVer
).toString();
323 if (m
.getValueAt(row
, cnSupArch
) != null) {
324 arch
= m
.getValueAt(row
, cnSupArch
).toString();
326 String module
= null;
327 if (m
.getValueAt(row
, cnSupMod
) != null) {
328 module
= m
.getValueAt(row
, cnSupMod
).toString();
330 String
[] rowData
= {lib
, hdr
, hlp
, name
, ver
};
331 if (!dataValidation(rowData
)) {
336 if (name
!= null && name
.length() > 0) {
337 getLibInstances(lib
);
338 guid
= nameToGuid(name
);
340 JOptionPane
.showMessageDialog(frame
, "Recommended Instance does not exist.");
345 String
[] sa
= new String
[7];
346 sfc
.getSpdLibClassDeclaration(sa
, row
);
347 Object cellData
= m
.getValueAt(row
, column
);
348 if (cellData
== null) {
351 if (column
== cnRecInstName
) {
353 if (sa
[cnRecInstName
] == null) {
358 if (guid
.equals(sa
[cnRecInstName
])) {
364 if (cellData
.equals(sa
[column
])) {
367 if (cellData
.toString().length() == 0 && sa
[column
] == null) {
371 docConsole
.setSaved(false);
372 sfc
.updateSpdLibClass(row
, lib
, hdr
, hlp
, guid
, ver
, arch
, module
);
377 This method initializes jButtonAdd
379 @return javax.swing.JButton
381 private JButton
getJButtonAdd() {
382 if (jButtonAdd
== null) {
383 jButtonAdd
= new JButton();
384 jButtonAdd
.setText("Add");
385 jButtonAdd
.setSize(new java
.awt
.Dimension(buttonWidth
,20));
386 jButtonAdd
.setBounds(new java
.awt
.Rectangle(addButtonCol
,rowSeven
,buttonWidth
,20));
387 jButtonAdd
.addActionListener(this);
393 This method initializes jButtonRemove
395 @return javax.swing.JButton
397 private JButton
getJButtonRemove() {
398 if (jButtonRemove
== null) {
399 jButtonRemove
= new JButton();
400 jButtonRemove
.setText("Remove");
401 jButtonRemove
.setSize(new java
.awt
.Dimension(buttonWidth
,20));
402 jButtonRemove
.setBounds(new java
.awt
.Rectangle(removeButtonCol
,rowSeven
,buttonWidth
,20));
403 jButtonRemove
.addActionListener(this);
405 return jButtonRemove
;
409 This method initializes jButtonRemoveAll
411 @return javax.swing.JButton
413 private JButton
getJButtonRemoveAll() {
414 if (jButtonRemoveAll
== null) {
415 jButtonRemoveAll
= new JButton();
416 jButtonRemoveAll
.setText("Remove All");
417 jButtonRemoveAll
.setSize(new java
.awt
.Dimension(buttonWidth
,20));
418 jButtonRemoveAll
.setBounds(new java
.awt
.Rectangle(removeAllButtonCol
,rowSeven
,buttonWidth
,20));
419 jButtonRemoveAll
.addActionListener(this);
421 return jButtonRemoveAll
;
425 This is the default constructor
427 public SpdLibClassDecls() {
434 public SpdLibClassDecls(PackageSurfaceAreaDocument
.PackageSurfaceArea inPsa
){
436 sfc
= new SpdFileContents(inPsa
);
440 public SpdLibClassDecls(OpeningPackageType opt
) {
441 this(opt
.getXmlSpd());
445 This method initializes this
449 private void init() {
451 this.setContentPane(getJContentPane());
452 this.setTitle("Library Class Declarations");
453 this.setBounds(new java
.awt
.Rectangle(0, 0, 500, 370));
454 this.setVisible(true);
455 this.addInternalFrameListener(new InternalFrameAdapter(){
456 public void internalFrameDeactivated(InternalFrameEvent e
){
457 if (jTable
.isEditing()) {
458 jTable
.getCellEditor().stopCellEditing();
464 private void init(SpdFileContents sfc
) {
465 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
469 // initialize table using SpdFileContents object
471 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][7];
472 sfc
.getSpdLibClassDeclarations(saa
);
474 while (i
< saa
.length
) {
475 if (saa
[i
][3] != null && saa
[i
][3].length() > 0) {
476 getLibInstances(saa
[i
][0]);
477 saa
[i
][3] = guidToName(saa
[i
][3]);
480 model
.addRow(saa
[i
]);
484 private JScrollPane
getJContentPane(){
485 if (topScrollPane
== null){
486 topScrollPane
= new JScrollPane();
487 topScrollPane
.setViewportView(getJContentPane1());
489 return topScrollPane
;
492 This method initializes jContentPane
494 @return javax.swing.JPanel
496 private JPanel
getJContentPane1() {
497 if (jContentPane
== null) {
499 starLabel1
= new StarLabel();
500 starLabel1
.setLocation(new java
.awt
.Point(1,rowOne
));
501 jLabel1ClassName
= new JLabel();
502 jLabel1ClassName
.setBounds(new java
.awt
.Rectangle(labelCol
,rowOne
,shortLabel
,20));
503 jLabel1ClassName
.setText("Library Class");
506 starLabel2
= new StarLabel();
507 starLabel2
.setBounds(new java
.awt
.Rectangle(1,rowTwo
,10,20));
508 jLabel2HelpText
= new JLabel();
509 jLabel2HelpText
.setBounds(new java
.awt
.Rectangle(labelCol
,rowTwo
,shortLabel
,20));
510 jLabel2HelpText
.setText("Help Text");
513 starLabel3
= new StarLabel();
514 starLabel3
.setLocation(new java
.awt
.Point(1,rowThree
));
515 jLabelHdr
= new JLabel();
516 jLabelHdr
.setBounds(new java
.awt
.Rectangle(labelCol
,rowThree
,longLabel
,20));
517 jLabelHdr
.setText("Include Header for Specified Class");
519 jLabel6SupModList
= new JLabel();
520 jLabel6SupModList
.setBounds(new java
.awt
.Rectangle(labelCol
,rowFive
,longLabel
,20));
521 jLabel6SupModList
.setText("Supported Module Types");
522 jLabel6SupModList
.setEnabled(true);
524 jLabel5SupArchList
= new JLabel();
525 jLabel5SupArchList
.setBounds(new java
.awt
.Rectangle(labelCol
,rowFour
,longLabel
,20));
526 jLabel5SupArchList
.setText("Supported Architectures");
527 jLabel5SupArchList
.setEnabled(true);
529 jContentPane
= new JPanel();
530 jContentPane
.setPreferredSize(new Dimension(680, 600));
531 jContentPane
.setLayout(null);
532 jContentPane
.add(jLabelHdr
, null);
533 jContentPane
.add(starLabel1
, null);
534 jContentPane
.add(starLabel3
, null);
535 jContentPane
.add(getJTextFieldAddClass(), null);
536 jContentPane
.add(getJComboBoxSelect(), null);
537 jContentPane
.add(getJScrollPaneTable(), null);
538 jContentPane
.add(getJButtonAdd(), null);
539 jContentPane
.add(getJButtonRemove(), null);
540 jContentPane
.add(getJButtonRemoveAll(), null);
542 jContentPane
.add(getJTextFieldHdr(), null);
543 jContentPane
.add(getJButtonBrowse(), null);
544 jContentPane
.add(jLabel1ClassName
, null);
545 jContentPane
.add(starLabel2
, null);
546 jContentPane
.add(jLabel2HelpText
, null);
547 jContentPane
.add(getJHelpTextScrollPane(), null);
549 jContentPane
.add(jLabel5SupArchList
, null);
550 jContentPane
.add(jLabel6SupModList
, null);
552 jContentPane
.add(getJScrollPaneModules(), null);
553 jContentPane
.add(getJScrollPane1Arch(), null);
562 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
564 public void actionPerformed(ActionEvent arg0
) {
566 if (arg0
.getSource() == jButtonAdd
) {
568 //ToDo: check before add
569 // LAH WAS String[] row = {null, null, null, jComboBox.getSelectedItem()+"", jTextField2RecInstVer.getText(), null, null};
570 String
[] row
= {null, null, null, null, null, null, null};
571 row
[cnClassName
] = jTextFieldAddClass
.getText();
572 row
[cnHdrFile
] = jTextFieldHdr
.getText().replace('\\', '/');
573 row
[cnHelpText
] = jTextAreaHelp
.getText();
574 row
[cnRecInstName
] = jComboBox
.getSelectedItem()+"";
575 row
[cnRecInstVer
] = jTextField2RecInstVer
.getText();
576 row
[cnSupArch
] = vectorToString(iCheckBoxListArch
.getAllCheckedItemsString());
577 if (row
[cnSupArch
].length() == 0) {
578 row
[cnSupArch
] = null;
580 row
[cnSupMod
] = vectorToString(iCheckBoxListModules
.getAllCheckedItemsString());
581 if (row
[cnSupMod
].length() == 0){
582 row
[cnSupMod
] = null;
584 if (!dataValidation(row
)) {
588 //convert to GUID before storing recommended lib instance.
590 getLibInstances(row
[cnClassName
]);
591 String recommendGuid
= nameToGuid(row
[cnRecInstName
]);
592 if (row
[cnRecInstName
].equals("null")) {
593 row
[cnRecInstName
] = null;
596 if (recommendGuid
== null) {
597 JOptionPane
.showMessageDialog(frame
, "Recommended Instance does not exist.");
602 sfc
.genSpdLibClassDeclarations(row
[cnClassName
], recommendGuid
, row
[cnHdrFile
], row
[cnHelpText
], row
[cnSupArch
], null, null, row
[cnRecInstVer
], null, row
[cnSupMod
]);
604 jTable
.changeSelection(model
.getRowCount()-1, 0, false, false);
605 docConsole
.setSaved(false);
608 // remove selected line
610 if (arg0
.getSource() == jButtonRemove
) {
611 if (jTable
.isEditing()){
612 jTable
.getCellEditor().stopCellEditing();
614 int rowSelected
= selectedRow
;
615 if (rowSelected
>= 0) {
616 model
.removeRow(rowSelected
);
617 docConsole
.setSaved(false);
618 sfc
.removeSpdLibClass(rowSelected
);
622 if (arg0
.getSource() == jButtonRemoveAll
) {
623 if (model
.getRowCount() == 0) {
626 docConsole
.setSaved(false);
627 model
.setRowCount(0);
628 sfc
.removeSpdLibClass();
632 private boolean dataValidation(String
[] row
) {
633 if (!DataValidation
.isKeywordType(row
[cnClassName
])) {
634 JOptionPane
.showMessageDialog(frame
, "Library Class name entered does not match KeyWord datatype.");
637 if (!DataValidation
.isPathAndFilename(row
[cnHdrFile
])) {
638 JOptionPane
.showMessageDialog(frame
, "Include Header does not match the PathAndFilename datatype.");
641 if (row
[cnHelpText
].length() == 0) {
642 JOptionPane
.showMessageDialog(frame
, "Help Text must be entered!");
645 if (row
[cnRecInstVer
] != null && row
[cnRecInstVer
].length() > 0) {
646 if (row
[cnRecInstName
] == null || row
[cnRecInstName
].length() == 0) {
647 JOptionPane
.showMessageDialog(frame
, "Recommended Instance Version must associate with the Instance Name.");
651 if (!DataValidation
.isVersionDataType(row
[cnRecInstVer
])) {
652 JOptionPane
.showMessageDialog(frame
, "Recommended Instance Version does not match Version datatype.");
659 Add contents in list to sfc
661 protected void save() {
666 This method initializes jTextField
668 @return javax.swing.JTextField
670 private JTextField
getJTextFieldHdr() {
671 if (jTextFieldHdr
== null) {
672 jTextFieldHdr
= new JTextField();
673 jTextFieldHdr
.setPreferredSize(new java
.awt
.Dimension(shortWidth
,20));
674 jTextFieldHdr
.setLocation(new java
.awt
.Point(longValueCol
,rowThree
));
675 jTextFieldHdr
.setSize(new java
.awt
.Dimension(shortWidth
,20));
677 return jTextFieldHdr
;
681 This method initializes jButtonBrowse
683 @return javax.swing.JButton
685 private JButton
getJButtonBrowse() {
686 if (jButtonBrowse
== null) {
687 jButtonBrowse
= new JButton();
688 jButtonBrowse
.setBounds(new java
.awt
.Rectangle(longValueCol
+ shortWidth
+ 7,rowThree
,90,20));
689 jButtonBrowse
.setText("Browse");
690 jButtonBrowse
.setPreferredSize(new java
.awt
.Dimension(99,20));
691 jButtonBrowse
.addActionListener(new AbstractAction() {
696 private static final long serialVersionUID
= 1L;
698 public void actionPerformed(ActionEvent arg0
) {
700 // Select files from current pkg
702 String dirPrefix
= Tools
.dirForNewSpd
.substring(0, Tools
.dirForNewSpd
.lastIndexOf(File
.separator
));
703 JFileChooser chooser
= new JFileChooser(dirPrefix
);
705 String headerDest
= null;
707 chooser
.setMultiSelectionEnabled(false);
708 chooser
.setFileSelectionMode(JFileChooser
.FILES_AND_DIRECTORIES
);
709 int retval
= chooser
.showOpenDialog(frame
);
710 if (retval
== JFileChooser
.APPROVE_OPTION
) {
712 theFile
= chooser
.getSelectedFile();
713 String file
= theFile
.getPath();
714 if (!file
.startsWith(dirPrefix
)) {
715 JOptionPane
.showMessageDialog(frame
, "You can only select files in current package directory structure!");
725 headerDest
= theFile
.getPath();
726 int fileIndex
= headerDest
.indexOf(System
.getProperty("file.separator"), dirPrefix
.length());
727 jTextFieldHdr
.setText(headerDest
.substring(fileIndex
+ 1).replace('\\', '/'));
733 return jButtonBrowse
;
736 public void componentResized(ComponentEvent arg0
) {
737 int intPreferredWidth
= 500;
739 Tools
.resizeComponentWidth(this.jTextFieldAddClass
, this.getWidth(), intPreferredWidth
-28);
740 Tools
.resizeComponentWidth(this.jHelpTextScrollPane
, this.getWidth(), intPreferredWidth
-28);
741 Tools
.resizeComponentWidth(this.jScrollPaneTable
, this.getWidth(), intPreferredWidth
-10);
742 Tools
.resizeComponentWidth(this.jTextFieldHdr
, this.getWidth(), intPreferredWidth
- 7);
743 Tools
.relocateComponentX(this.jButtonBrowse
, this.getWidth(), intPreferredWidth
,
744 DataType
.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON
);
748 * This method initializes jHelpTextScrollPane
750 * @return javax.swing.JScrollPane jHelpTextScrollPane
752 private JScrollPane
getJHelpTextScrollPane() {
753 if (jHelpTextScrollPane
== null) {
754 jHelpTextScrollPane
= new JScrollPane();
755 jHelpTextScrollPane
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
756 jHelpTextScrollPane
.setPreferredSize(new java
.awt
.Dimension(longValueWidth
, 80));
757 jHelpTextScrollPane
.setSize(new java
.awt
.Dimension(longValueWidth
, 80));
758 jHelpTextScrollPane
.setLocation(new java
.awt
.Point(shortValueCol
,rowTwo
));
759 jHelpTextScrollPane
.setViewportView(getJTextAreaHelp());
761 return jHelpTextScrollPane
;
765 * This method initializes jTextAreaHelp
767 * @return javax.swing.JTextArea
769 private JTextArea
getJTextAreaHelp() {
770 if (jTextAreaHelp
== null) {
771 jTextAreaHelp
= new JTextArea();
772 jTextAreaHelp
.setLineWrap(true);
773 jTextAreaHelp
.setWrapStyleWord(true);
775 return jTextAreaHelp
;
778 private JScrollPane
getJScrollPaneModules() {
779 if (jScrollPaneModules
== null) {
780 jScrollPaneModules
= new JScrollPane();
781 jScrollPaneModules
.setBounds(new java
.awt
.Rectangle(longValueCol
,rowFive
,medWidth
,60));
782 jScrollPaneModules
.setPreferredSize(new java
.awt
.Dimension(medWidth
, 60));
783 jScrollPaneModules
.setViewportView(getICheckBoxListSupportedModules());
785 return jScrollPaneModules
;
788 private ICheckBoxList
getICheckBoxListSupportedModules() {
789 if (iCheckBoxListModules
== null) {
790 iCheckBoxListModules
= new ICheckBoxList();
791 iCheckBoxListModules
.setBounds(new java
.awt
.Rectangle(longValueCol
,rowFour
,medWidth
,60));
792 Vector
<String
> v
= new Vector
<String
>();
799 v
.add("DXE_RUNTIME_DRIVER");
800 v
.add("DXE_SAL_DRIVER");
801 v
.add("DXE_SMM_DRIVER");
802 v
.add("UEFI_DRIVER");
803 v
.add("UEFI_APPLICATION");
804 v
.add("USER_DEFINED");
805 iCheckBoxListModules
.setAllItems(v
);
807 return iCheckBoxListModules
;
810 private String
vectorToString(Vector
<String
> v
) {
812 for (int i
= 0; i
< v
.size(); ++i
) {
819 private JScrollPane
getJScrollPane1Arch() {
820 if (jScrollPane1Arch
== null) {
821 jScrollPane1Arch
= new JScrollPane();
822 jScrollPane1Arch
.setBounds(new java
.awt
.Rectangle(longValueCol
,rowFour
,medWidth
,60));
823 jScrollPane1Arch
.setPreferredSize(new java
.awt
.Dimension(medWidth
, 60));
824 jScrollPane1Arch
.setViewportView(getICheckBoxListArch());
826 return jScrollPane1Arch
;
829 * This method initializes iCheckBoxList
831 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
833 private ICheckBoxList
getICheckBoxListArch() {
834 if (iCheckBoxListArch
== null) {
835 iCheckBoxListArch
= new ICheckBoxList();
836 iCheckBoxListArch
.setBounds(new java
.awt
.Rectangle(longValueCol
,rowFour
,medWidth
,60));
837 Vector
<String
> v
= new Vector
<String
>();
844 iCheckBoxListArch
.setAllItems(v
);
846 return iCheckBoxListArch
;
849 private void getLibInstances(String libClass
){
850 libNameGuidMap
.clear();
852 Iterator ismi
= GlobalData
.vModuleList
.iterator();
853 while (ismi
.hasNext()) {
854 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
856 Vector
<String
> classProduced
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED", mi
);
857 for (int i
= 0; i
< classProduced
.size(); ++i
) {
858 if (classProduced
.get(i
).equals(libClass
)) {
859 libNameGuidMap
.put(mi
.getName(), mi
.getGuid());
866 JOptionPane
.showMessageDialog(frame
, "Search Instances Failed.");
871 private String
nameToGuid(String name
) {
873 if (!libNameGuidMap
.containsKey(name
)) {
877 s
= libNameGuidMap
.get(name
);
881 private String
guidToName(String guid
){
883 if (!libNameGuidMap
.containsValue(guid
)) {
886 Set
<String
> key
= libNameGuidMap
.keySet();
887 Iterator
<String
> is
= key
.iterator();
888 while(is
.hasNext()) {
890 if (libNameGuidMap
.get(s
).equals(guid
)) {