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
.FontMetrics
;
17 import java
.awt
.event
.ActionEvent
;
18 import java
.awt
.event
.ComponentEvent
;
20 import java
.util
.HashMap
;
21 //import java.util.Iterator;
22 //import java.util.Set;
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
.JTextArea
;
32 import javax
.swing
.JComboBox
;
33 import javax
.swing
.JLabel
;
34 import javax
.swing
.JScrollPane
;
35 import javax
.swing
.JButton
;
36 import javax
.swing
.JFrame
;
37 import javax
.swing
.ListSelectionModel
;
38 import javax
.swing
.event
.InternalFrameAdapter
;
39 import javax
.swing
.event
.InternalFrameEvent
;
40 import javax
.swing
.event
.ListSelectionEvent
;
41 import javax
.swing
.event
.ListSelectionListener
;
42 import javax
.swing
.event
.TableModelEvent
;
43 import javax
.swing
.event
.TableModelListener
;
44 import javax
.swing
.table
.DefaultTableModel
;
45 import javax
.swing
.table
.TableColumn
;
46 import javax
.swing
.table
.TableModel
;
47 import org
.tianocore
.PackageSurfaceAreaDocument
;
48 import org
.tianocore
.frameworkwizard
.common
.DataType
;
49 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
50 //import org.tianocore.frameworkwizard.common.GlobalData;
51 import org
.tianocore
.frameworkwizard
.common
.Tools
;
52 import org
.tianocore
.frameworkwizard
.common
.Identifications
.OpeningPackageType
;
53 import org
.tianocore
.frameworkwizard
.common
.ui
.IInternalFrame
;
54 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
55 import org
.tianocore
.frameworkwizard
.common
.ui
.iCheckBoxList
.ICheckBoxList
;
56 import org
.tianocore
.frameworkwizard
.platform
.ui
.ListEditor
;
57 import org
.tianocore
.frameworkwizard
.platform
.ui
.LongTextEditor
;
58 //import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
59 //import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
63 GUI for create library definition elements of spd file.
65 @since PackageEditor 1.0
67 public class SpdLibClassDecls
extends IInternalFrame
implements TableModelListener
{
71 private static final long serialVersionUID
= 1L;
73 private JFrame topFrame
;
75 private JTable jTable
= null;
77 private DefaultTableModel model
= null;
79 private JPanel jContentPane
= null;
81 private JTextField jTextFieldAddClass
= null;
83 private JComboBox jComboBoxSelect
= null;
85 private JScrollPane jScrollPaneTable
= null;
87 private JButton jButtonAdd
= null;
89 private JButton jButtonRemove
= null;
91 private JButton jButtonRemoveAll
= null;
93 private JLabel jLabelHdr
= null;
95 private JTextField jTextFieldHdr
= null;
97 private JButton jButtonBrowse
= null;
99 private StarLabel starLabel1
= null;
101 private StarLabel starLabel3
= null;
103 private SpdFileContents sfc
= null;
105 private OpeningPackageType docConsole
= null;
107 private JLabel jLabel1ClassName
= null;
109 private JScrollPane topScrollPane
= null; // @jve:decl-index=0:visual-constraint="10,53"
111 private int selectedRow
= -1;
113 private StarLabel starLabel2
= null;
115 private JLabel jLabel2HelpText
= null;
117 private JTextArea jTextAreaHelp
= null;
119 private JScrollPane jHelpTextScrollPane
= null;
121 private JLabel jLabel5SupArchList
= null;
123 private JLabel jLabel6SupModList
= null;
125 private JScrollPane jScrollPaneModules
= null;
127 private JScrollPane jScrollPane1Arch
= null;
129 private ICheckBoxList iCheckBoxListModules
= null;
131 private ICheckBoxList iCheckBoxListArch
= null;
133 private int cnClassName
= 0;
134 private int cnHdrFile
= 1;
135 private int cnHelpText
= 2;
136 // private int cnRecInstName = 3;
137 // private int cnRecInstVer = 4;
138 private int cnSupArch
= 5;
139 private int cnSupMod
= 6;
141 private final int classNameMinWidth
= 200;
142 private final int hdrFileMinWidth
= 300;
143 private final int helpTextMinWidth
= 300;
144 private final int supArchMinWidth
= 200;
145 private final int supModMinWidth
= 200;
147 private final int shortLabel
= 90;
148 private final int longLabel
= 220;
149 private final int labelCol
= 12;
150 private final int shortValueCol
= labelCol
+ shortLabel
+ 6;
151 private final int longValueCol
= labelCol
+ longLabel
+ 6;
152 private final int longValueWidth
= 347;
153 private final int shortWidth
= 140;
154 private final int medWidth
= 240;
156 private final int buttonWidth
= 99;
158 private final int addButtonCol
= shortValueCol
+ 10;
159 private final int removeButtonCol
= addButtonCol
+ buttonWidth
+ 10;
160 private final int removeAllButtonCol
= removeButtonCol
+ buttonWidth
+ 10;
162 private final int rowOne
= 12;
163 private final int rowTwo
= rowOne
+ 25;
164 private final int rowThree
= rowTwo
+ 60 + 25;
165 private final int rowFour
= rowThree
+ 25;
166 private final int rowFive
= rowFour
+ 40 + 25;
167 private final int rowSix
= rowFive
+ 40 + 25;
168 private final int rowSeven
= rowSix
;
169 private final int rowEight
= rowSeven
+ 30;
171 HashMap
<String
, String
> libNameGuidMap
= new HashMap
<String
, String
>();
175 This method initializes this
178 private void initialize() {
180 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
185 This method initializes jTextFieldAddClass
187 @return javax.swing.JTextField
189 private JTextField
getJTextFieldAddClass() {
190 if (jTextFieldAddClass
== null) {
191 jTextFieldAddClass
= new JTextField();
192 jTextFieldAddClass
.setBounds(new java
.awt
.Rectangle(shortValueCol
,rowOne
,longValueWidth
,20));
193 jTextFieldAddClass
.setPreferredSize(new java
.awt
.Dimension(longValueWidth
,20));
194 jTextFieldAddClass
.setEnabled(true);
196 return jTextFieldAddClass
;
200 This method initializes jComboBoxSelect
202 @return javax.swing.JComboBox
204 private JComboBox
getJComboBoxSelect() {
205 if (jComboBoxSelect
== null) {
206 jComboBoxSelect
= new JComboBox();
207 jComboBoxSelect
.setBounds(new java
.awt
.Rectangle(220, 10, 260, 20));
208 jComboBoxSelect
.setPreferredSize(new java
.awt
.Dimension(260,22));
209 jComboBoxSelect
.setEnabled(true);
210 jComboBoxSelect
.setVisible(false);
212 return jComboBoxSelect
;
216 This method initializes jScrollPaneTable
218 @return javax.swing.JScrollPane
220 Used for the Table of Library Classes that are provided by this package
223 private JScrollPane
getJScrollPaneTable() {
224 if (jScrollPaneTable
== null) {
225 jScrollPaneTable
= new JScrollPane();
226 jScrollPaneTable
.setBounds(new java
.awt
.Rectangle(labelCol
,rowEight
,400,253));
227 jScrollPaneTable
.setViewportView(getJTable());
229 return jScrollPaneTable
;
233 This method initializes jTable
235 @return javax.swing.JTable
237 private JTable
getJTable() {
238 if (jTable
== null) {
239 model
= new DefaultTableModel();
240 jTable
= new JTable(model
);
241 jTable
.setRowHeight(20);
242 jTable
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
243 jTable
.setColumnSelectionAllowed(false);
244 model
.addColumn("Class Name");
245 model
.addColumn("Header");
246 model
.addColumn("Help Text");
247 model
.addColumn("Recommended Instance");
248 model
.addColumn("Version");
249 model
.addColumn("Supported Architectures");
250 model
.addColumn("Supported Module Types");
252 jTable
.getColumnModel().getColumn(cnHelpText
).setCellEditor(new LongTextEditor(topFrame
));
254 jTable
.removeColumn(jTable
.getColumnModel().getColumn(3));
255 jTable
.removeColumn(jTable
.getColumnModel().getColumn(3));
257 Vector
<String
> vArch
= new Vector
<String
>();
264 jTable
.getColumnModel().getColumn(cnSupArch
- 2).setCellEditor(new ListEditor(vArch
, topFrame
));
266 Vector
<String
> vModule
= new Vector
<String
>();
269 vModule
.add("PEI_CORE");
271 vModule
.add("DXE_CORE");
272 vModule
.add("DXE_DRIVER");
273 vModule
.add("DXE_RUNTIME_DRIVER");
274 vModule
.add("DXE_SAL_DRIVER");
275 vModule
.add("DXE_SMM_DRIVER");
276 vModule
.add("UEFI_DRIVER");
277 vModule
.add("UEFI_APPLICATION");
278 vModule
.add("USER_DEFINED");
280 jTable
.getColumnModel().getColumn(cnSupMod
- 2).setCellEditor(new ListEditor(vModule
, topFrame
));
282 TableColumn column
= jTable
.getColumnModel().getColumn(this.cnClassName
);
283 column
.setMinWidth(this.classNameMinWidth
);
284 column
= jTable
.getColumnModel().getColumn(this.cnHdrFile
);
285 column
.setMinWidth(this.hdrFileMinWidth
);
286 column
= jTable
.getColumnModel().getColumn(this.cnHelpText
);
287 column
.setMinWidth(this.helpTextMinWidth
);
288 column
= jTable
.getColumnModel().getColumn(this.cnSupArch
- 2);
289 column
.setMinWidth(this.supArchMinWidth
);
290 column
= jTable
.getColumnModel().getColumn(this.cnSupMod
- 2);
291 column
.setMinWidth(this.supModMinWidth
);
293 jTable
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
294 jTable
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
295 public void valueChanged(ListSelectionEvent e
) {
296 if (e
.getValueIsAdjusting()){
299 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
300 if (lsm
.isSelectionEmpty()) {
304 selectedRow
= lsm
.getMinSelectionIndex();
309 jTable
.getModel().addTableModelListener(this);
316 public void tableChanged(TableModelEvent arg0
) {
317 // TODO Auto-generated method stub
318 int row
= arg0
.getFirstRow();
319 int column
= arg0
.getColumn();
320 TableModel m
= (TableModel
)arg0
.getSource();
321 if (arg0
.getType() == TableModelEvent
.UPDATE
){
323 String lib
= m
.getValueAt(row
, cnClassName
) + "";
324 String hdr
= m
.getValueAt(row
, cnHdrFile
) + "";
325 String hlp
= m
.getValueAt(row
, cnHelpText
) + "";
327 // if (m.getValueAt(row, cnRecInstName) != null) {
328 // name = m.getValueAt(row, cnRecInstName).toString();
330 // String ver = null;
331 // if (m.getValueAt(row, cnRecInstVer) != null){
332 // ver = m.getValueAt(row, cnRecInstVer).toString();
335 if (m
.getValueAt(row
, cnSupArch
) != null) {
336 arch
= m
.getValueAt(row
, cnSupArch
).toString();
338 String module
= null;
339 if (m
.getValueAt(row
, cnSupMod
) != null) {
340 module
= m
.getValueAt(row
, cnSupMod
).toString();
342 String
[] rowData
= {lib
, hdr
, hlp
, name
};
343 if (!dataValidation(rowData
)) {
348 // if (name != null && name.length() > 0) {
349 // getLibInstances(lib);
350 // guid = nameToGuid(name);
351 // if (guid == null){
352 // JOptionPane.showMessageDialog(frame, "Recommended Instance does not exist.");
357 String
[] sa
= new String
[7];
358 sfc
.getSpdLibClassDeclaration(sa
, row
);
359 Object cellData
= m
.getValueAt(row
, column
);
360 if (cellData
== null) {
363 // if (column == cnRecInstName) {
364 // if (guid == null) {
365 // if (sa[cnRecInstName] == null) {
370 // if (guid.equals(sa[cnRecInstName])) {
375 if (cellData
.equals(sa
[column
])) {
378 if (cellData
.toString().length() == 0 && sa
[column
] == null) {
381 docConsole
.setSaved(false);
382 sfc
.updateSpdLibClass(row
, lib
, hdr
, hlp
, guid
, null, arch
, module
);
387 This method initializes jButtonAdd
389 @return javax.swing.JButton
391 private JButton
getJButtonAdd() {
392 if (jButtonAdd
== null) {
393 jButtonAdd
= new JButton();
394 jButtonAdd
.setText("Add");
395 jButtonAdd
.setSize(new java
.awt
.Dimension(buttonWidth
,20));
396 jButtonAdd
.setBounds(new java
.awt
.Rectangle(addButtonCol
,rowSeven
,buttonWidth
,20));
397 jButtonAdd
.addActionListener(this);
403 This method initializes jButtonRemove
405 @return javax.swing.JButton
407 private JButton
getJButtonRemove() {
408 if (jButtonRemove
== null) {
409 jButtonRemove
= new JButton();
410 jButtonRemove
.setText("Delete");
411 jButtonRemove
.setSize(new java
.awt
.Dimension(buttonWidth
,20));
412 jButtonRemove
.setBounds(new java
.awt
.Rectangle(removeButtonCol
,rowSeven
,buttonWidth
,20));
413 jButtonRemove
.addActionListener(this);
415 return jButtonRemove
;
419 This method initializes jButtonRemoveAll
421 @return javax.swing.JButton
423 private JButton
getJButtonRemoveAll() {
424 if (jButtonRemoveAll
== null) {
425 jButtonRemoveAll
= new JButton();
426 jButtonRemoveAll
.setText("Clear All");
427 jButtonRemoveAll
.setLocation(removeAllButtonCol
,rowSeven
);
428 FontMetrics fm
= jButtonRemoveAll
.getFontMetrics(jButtonRemoveAll
.getFont());
429 jButtonRemoveAll
.setSize(fm
.stringWidth(jButtonRemoveAll
.getText()) + 50, 20);
430 jButtonRemoveAll
.addActionListener(this);
432 return jButtonRemoveAll
;
436 This is the default constructor
438 public SpdLibClassDecls(JFrame frame
) {
446 public SpdLibClassDecls(PackageSurfaceAreaDocument
.PackageSurfaceArea inPsa
, JFrame frame
){
448 sfc
= new SpdFileContents(inPsa
);
452 public SpdLibClassDecls(OpeningPackageType opt
, JFrame frame
) {
453 this(opt
.getXmlSpd(), frame
);
457 This method initializes this
461 private void init() {
463 this.setContentPane(getJContentPane());
464 this.setTitle("Library Class Declarations");
465 this.setBounds(new java
.awt
.Rectangle(0, 0, 500, 370));
466 this.setVisible(true);
467 this.addInternalFrameListener(new InternalFrameAdapter(){
468 public void internalFrameDeactivated(InternalFrameEvent e
){
469 if (jTable
.isEditing()) {
470 jTable
.getCellEditor().stopCellEditing();
476 private void init(SpdFileContents sfc
) {
478 if (sfc
.getSpdPkgDefsRdOnly().equals("true")) {
479 JOptionPane
.showMessageDialog(topFrame
, "This is a read-only package. You will not be able to edit contents in table.");
483 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
487 // initialize table using SpdFileContents object
489 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][7];
490 sfc
.getSpdLibClassDeclarations(saa
);
492 while (i
< saa
.length
) {
493 // if (saa[i][3] != null && saa[i][3].length() > 0) {
494 // getLibInstances(saa[i][0]);
495 // saa[i][3] = guidToName(saa[i][3]);
498 model
.addRow(saa
[i
]);
504 private void initFrame() {
505 boolean editable
= true;
506 if (sfc
.getSpdPkgDefsRdOnly().equals("true")) {
510 jButtonAdd
.setEnabled(editable
);
511 jButtonRemove
.setEnabled(editable
);
512 jButtonRemoveAll
.setEnabled(editable
);
513 jTable
.setEnabled(editable
);
516 private JScrollPane
getJContentPane(){
517 if (topScrollPane
== null){
518 topScrollPane
= new JScrollPane();
519 topScrollPane
.setViewportView(getJContentPane1());
521 return topScrollPane
;
524 This method initializes jContentPane
526 @return javax.swing.JPanel
528 private JPanel
getJContentPane1() {
529 if (jContentPane
== null) {
531 starLabel1
= new StarLabel();
532 starLabel1
.setLocation(new java
.awt
.Point(1,rowOne
));
533 jLabel1ClassName
= new JLabel();
534 jLabel1ClassName
.setBounds(new java
.awt
.Rectangle(labelCol
,rowOne
,shortLabel
,20));
535 jLabel1ClassName
.setText("Library Class");
538 starLabel2
= new StarLabel();
539 starLabel2
.setBounds(new java
.awt
.Rectangle(1,rowTwo
,10,20));
540 jLabel2HelpText
= new JLabel();
541 jLabel2HelpText
.setBounds(new java
.awt
.Rectangle(labelCol
,rowTwo
,shortLabel
,20));
542 jLabel2HelpText
.setText("Help Text");
545 starLabel3
= new StarLabel();
546 starLabel3
.setLocation(new java
.awt
.Point(1,rowThree
));
547 jLabelHdr
= new JLabel();
548 jLabelHdr
.setBounds(new java
.awt
.Rectangle(labelCol
,rowThree
,longLabel
,20));
549 jLabelHdr
.setText("Include Header for Specified Class");
551 jLabel6SupModList
= new JLabel();
552 jLabel6SupModList
.setBounds(new java
.awt
.Rectangle(labelCol
,rowFive
,longLabel
,20));
553 jLabel6SupModList
.setText("Supported Module Types");
554 jLabel6SupModList
.setEnabled(true);
556 jLabel5SupArchList
= new JLabel();
557 jLabel5SupArchList
.setBounds(new java
.awt
.Rectangle(labelCol
,rowFour
,longLabel
,20));
558 jLabel5SupArchList
.setText("Supported Architectures");
559 jLabel5SupArchList
.setEnabled(true);
561 jContentPane
= new JPanel();
562 jContentPane
.setPreferredSize(new Dimension(680, 600));
563 jContentPane
.setLayout(null);
564 jContentPane
.add(jLabelHdr
, null);
565 jContentPane
.add(starLabel1
, null);
566 jContentPane
.add(starLabel3
, null);
567 jContentPane
.add(getJTextFieldAddClass(), null);
568 jContentPane
.add(getJComboBoxSelect(), null);
569 jContentPane
.add(getJScrollPaneTable(), null);
570 jContentPane
.add(getJButtonAdd(), null);
571 jContentPane
.add(getJButtonRemove(), null);
572 jContentPane
.add(getJButtonRemoveAll(), null);
574 jContentPane
.add(getJTextFieldHdr(), null);
575 jContentPane
.add(getJButtonBrowse(), null);
576 jContentPane
.add(jLabel1ClassName
, null);
577 jContentPane
.add(starLabel2
, null);
578 jContentPane
.add(jLabel2HelpText
, null);
579 jContentPane
.add(getJHelpTextScrollPane(), null);
581 jContentPane
.add(jLabel5SupArchList
, null);
582 jContentPane
.add(jLabel6SupModList
, null);
584 jContentPane
.add(getJScrollPaneModules(), null);
585 jContentPane
.add(getJScrollPane1Arch(), null);
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
] = jTextFieldAddClass
.getText();
604 row
[cnHdrFile
] = jTextFieldHdr
.getText().replace('\\', '/');
605 row
[cnHelpText
] = jTextAreaHelp
.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
], null, row
[cnHdrFile
], row
[cnHelpText
], row
[cnSupArch
], null, null, null, 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(this, "Library Class name entered does not match KeyWord datatype.");
669 if (!DataValidation
.isPathAndFilename(row
[cnHdrFile
])) {
670 JOptionPane
.showMessageDialog(this, "Include Header does not match the PathAndFilename datatype.");
673 if (row
[cnHelpText
].length() == 0) {
674 JOptionPane
.showMessageDialog(this, "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
.setPreferredSize(new java
.awt
.Dimension(shortWidth
,20));
706 jTextFieldHdr
.setLocation(new java
.awt
.Point(longValueCol
,rowThree
));
707 jTextFieldHdr
.setSize(new java
.awt
.Dimension(shortWidth
,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(longValueCol
+ shortWidth
+ 7,rowThree
,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(topFrame
);
742 if (retval
== JFileChooser
.APPROVE_OPTION
) {
744 theFile
= chooser
.getSelectedFile();
745 String file
= theFile
.getPath();
746 if (!file
.startsWith(dirPrefix
)) {
747 JOptionPane
.showMessageDialog(topFrame
, "You can only select files in current package directory structure!");
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 Tools
.resizeComponentWidth(this.jTextFieldAddClass
, this.getWidth(), intPreferredWidth
-28);
772 Tools
.resizeComponentWidth(this.jHelpTextScrollPane
, this.getWidth(), intPreferredWidth
-28);
773 Tools
.resizeComponentWidth(this.jScrollPaneTable
, this.getWidth(), intPreferredWidth
-10);
774 Tools
.resizeComponentWidth(this.jTextFieldHdr
, this.getWidth(), intPreferredWidth
- 7);
775 Tools
.relocateComponentX(this.jButtonBrowse
, this.getWidth(), intPreferredWidth
,
776 DataType
.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON
);
780 * This method initializes jHelpTextScrollPane
782 * @return javax.swing.JScrollPane jHelpTextScrollPane
784 private JScrollPane
getJHelpTextScrollPane() {
785 if (jHelpTextScrollPane
== null) {
786 jHelpTextScrollPane
= new JScrollPane();
787 jHelpTextScrollPane
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
788 jHelpTextScrollPane
.setPreferredSize(new java
.awt
.Dimension(longValueWidth
, 80));
789 jHelpTextScrollPane
.setSize(new java
.awt
.Dimension(longValueWidth
, 80));
790 jHelpTextScrollPane
.setLocation(new java
.awt
.Point(shortValueCol
,rowTwo
));
791 jHelpTextScrollPane
.setViewportView(getJTextAreaHelp());
793 return jHelpTextScrollPane
;
797 * This method initializes jTextAreaHelp
799 * @return javax.swing.JTextArea
801 private JTextArea
getJTextAreaHelp() {
802 if (jTextAreaHelp
== null) {
803 jTextAreaHelp
= new JTextArea();
804 jTextAreaHelp
.setLineWrap(true);
805 jTextAreaHelp
.setWrapStyleWord(true);
807 return jTextAreaHelp
;
810 private JScrollPane
getJScrollPaneModules() {
811 if (jScrollPaneModules
== null) {
812 jScrollPaneModules
= new JScrollPane();
813 jScrollPaneModules
.setBounds(new java
.awt
.Rectangle(longValueCol
,rowFive
,medWidth
,60));
814 jScrollPaneModules
.setPreferredSize(new java
.awt
.Dimension(medWidth
, 60));
815 jScrollPaneModules
.setViewportView(getICheckBoxListSupportedModules());
817 return jScrollPaneModules
;
820 private ICheckBoxList
getICheckBoxListSupportedModules() {
821 if (iCheckBoxListModules
== null) {
822 iCheckBoxListModules
= new ICheckBoxList();
823 iCheckBoxListModules
.setBounds(new java
.awt
.Rectangle(longValueCol
,rowFour
,medWidth
,60));
824 Vector
<String
> v
= new Vector
<String
>();
831 v
.add("DXE_RUNTIME_DRIVER");
832 v
.add("DXE_SAL_DRIVER");
833 v
.add("DXE_SMM_DRIVER");
834 v
.add("UEFI_DRIVER");
835 v
.add("UEFI_APPLICATION");
836 v
.add("USER_DEFINED");
837 iCheckBoxListModules
.setAllItems(v
);
839 return iCheckBoxListModules
;
842 private String
vectorToString(Vector
<String
> v
) {
844 for (int i
= 0; i
< v
.size(); ++i
) {
851 private JScrollPane
getJScrollPane1Arch() {
852 if (jScrollPane1Arch
== null) {
853 jScrollPane1Arch
= new JScrollPane();
854 jScrollPane1Arch
.setBounds(new java
.awt
.Rectangle(longValueCol
,rowFour
,medWidth
,60));
855 jScrollPane1Arch
.setPreferredSize(new java
.awt
.Dimension(medWidth
, 60));
856 jScrollPane1Arch
.setViewportView(getICheckBoxListArch());
858 return jScrollPane1Arch
;
861 * This method initializes iCheckBoxList
863 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
865 private ICheckBoxList
getICheckBoxListArch() {
866 if (iCheckBoxListArch
== null) {
867 iCheckBoxListArch
= new ICheckBoxList();
868 iCheckBoxListArch
.setBounds(new java
.awt
.Rectangle(longValueCol
,rowFour
,medWidth
,60));
869 Vector
<String
> v
= new Vector
<String
>();
876 iCheckBoxListArch
.setAllItems(v
);
878 return iCheckBoxListArch
;
881 // private void getLibInstances(String libClass){
882 // libNameGuidMap.clear();
884 // Iterator ismi = GlobalData.vModuleList.iterator();
885 // while (ismi.hasNext()) {
886 // ModuleIdentification mi = (ModuleIdentification) ismi.next();
888 // Vector<String> classProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
889 // for (int i = 0; i < classProduced.size(); ++i) {
890 // if (classProduced.get(i).equals(libClass)) {
891 // libNameGuidMap.put(mi.getName(), mi.getGuid());
897 // catch(Exception e){
898 // JOptionPane.showMessageDialog(frame, "Search Instances Failed.");
903 // private String nameToGuid(String name) {
905 // if (!libNameGuidMap.containsKey(name)) {
909 // s = libNameGuidMap.get(name);
913 // private String guidToName(String guid){
915 // if (!libNameGuidMap.containsValue(guid)) {
918 // Set<String> key = libNameGuidMap.keySet();
919 // Iterator<String> is = key.iterator();
920 // while(is.hasNext()) {
922 // if (libNameGuidMap.get(s).equals(guid)) {