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;
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());
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
));
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
));
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() {
445 public SpdLibClassDecls(PackageSurfaceAreaDocument
.PackageSurfaceArea inPsa
){
447 sfc
= new SpdFileContents(inPsa
);
451 public SpdLibClassDecls(OpeningPackageType opt
) {
452 this(opt
.getXmlSpd());
456 This method initializes this
460 private void init() {
462 this.setContentPane(getJContentPane());
463 this.setTitle("Library Class Declarations");
464 this.setBounds(new java
.awt
.Rectangle(0, 0, 500, 370));
465 this.setVisible(true);
466 this.addInternalFrameListener(new InternalFrameAdapter(){
467 public void internalFrameDeactivated(InternalFrameEvent e
){
468 if (jTable
.isEditing()) {
469 jTable
.getCellEditor().stopCellEditing();
475 private void init(SpdFileContents sfc
) {
477 if (sfc
.getSpdPkgDefsRdOnly().equals("true")) {
478 JOptionPane
.showMessageDialog(frame
, "This is a read-only package. You will not be able to edit contents in table.");
482 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
486 // initialize table using SpdFileContents object
488 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][7];
489 sfc
.getSpdLibClassDeclarations(saa
);
491 while (i
< saa
.length
) {
492 // if (saa[i][3] != null && saa[i][3].length() > 0) {
493 // getLibInstances(saa[i][0]);
494 // saa[i][3] = guidToName(saa[i][3]);
497 model
.addRow(saa
[i
]);
503 private void initFrame() {
504 boolean editable
= true;
505 if (sfc
.getSpdPkgDefsRdOnly().equals("true")) {
509 jButtonAdd
.setEnabled(editable
);
510 jButtonRemove
.setEnabled(editable
);
511 jButtonRemoveAll
.setEnabled(editable
);
512 jTable
.setEnabled(editable
);
515 private JScrollPane
getJContentPane(){
516 if (topScrollPane
== null){
517 topScrollPane
= new JScrollPane();
518 topScrollPane
.setViewportView(getJContentPane1());
520 return topScrollPane
;
523 This method initializes jContentPane
525 @return javax.swing.JPanel
527 private JPanel
getJContentPane1() {
528 if (jContentPane
== null) {
530 starLabel1
= new StarLabel();
531 starLabel1
.setLocation(new java
.awt
.Point(1,rowOne
));
532 jLabel1ClassName
= new JLabel();
533 jLabel1ClassName
.setBounds(new java
.awt
.Rectangle(labelCol
,rowOne
,shortLabel
,20));
534 jLabel1ClassName
.setText("Library Class");
537 starLabel2
= new StarLabel();
538 starLabel2
.setBounds(new java
.awt
.Rectangle(1,rowTwo
,10,20));
539 jLabel2HelpText
= new JLabel();
540 jLabel2HelpText
.setBounds(new java
.awt
.Rectangle(labelCol
,rowTwo
,shortLabel
,20));
541 jLabel2HelpText
.setText("Help Text");
544 starLabel3
= new StarLabel();
545 starLabel3
.setLocation(new java
.awt
.Point(1,rowThree
));
546 jLabelHdr
= new JLabel();
547 jLabelHdr
.setBounds(new java
.awt
.Rectangle(labelCol
,rowThree
,longLabel
,20));
548 jLabelHdr
.setText("Include Header for Specified Class");
550 jLabel6SupModList
= new JLabel();
551 jLabel6SupModList
.setBounds(new java
.awt
.Rectangle(labelCol
,rowFive
,longLabel
,20));
552 jLabel6SupModList
.setText("Supported Module Types");
553 jLabel6SupModList
.setEnabled(true);
555 jLabel5SupArchList
= new JLabel();
556 jLabel5SupArchList
.setBounds(new java
.awt
.Rectangle(labelCol
,rowFour
,longLabel
,20));
557 jLabel5SupArchList
.setText("Supported Architectures");
558 jLabel5SupArchList
.setEnabled(true);
560 jContentPane
= new JPanel();
561 jContentPane
.setPreferredSize(new Dimension(680, 600));
562 jContentPane
.setLayout(null);
563 jContentPane
.add(jLabelHdr
, null);
564 jContentPane
.add(starLabel1
, null);
565 jContentPane
.add(starLabel3
, null);
566 jContentPane
.add(getJTextFieldAddClass(), null);
567 jContentPane
.add(getJComboBoxSelect(), null);
568 jContentPane
.add(getJScrollPaneTable(), null);
569 jContentPane
.add(getJButtonAdd(), null);
570 jContentPane
.add(getJButtonRemove(), null);
571 jContentPane
.add(getJButtonRemoveAll(), null);
573 jContentPane
.add(getJTextFieldHdr(), null);
574 jContentPane
.add(getJButtonBrowse(), null);
575 jContentPane
.add(jLabel1ClassName
, null);
576 jContentPane
.add(starLabel2
, null);
577 jContentPane
.add(jLabel2HelpText
, null);
578 jContentPane
.add(getJHelpTextScrollPane(), null);
580 jContentPane
.add(jLabel5SupArchList
, null);
581 jContentPane
.add(jLabel6SupModList
, null);
583 jContentPane
.add(getJScrollPaneModules(), null);
584 jContentPane
.add(getJScrollPane1Arch(), null);
593 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
595 public void actionPerformed(ActionEvent arg0
) {
597 if (arg0
.getSource() == jButtonAdd
) {
599 //ToDo: check before add
600 // LAH WAS String[] row = {null, null, null, jComboBox.getSelectedItem()+"", jTextField2RecInstVer.getText(), null, null};
601 String
[] row
= {null, null, null, null, null, null, null};
602 row
[cnClassName
] = jTextFieldAddClass
.getText();
603 row
[cnHdrFile
] = jTextFieldHdr
.getText().replace('\\', '/');
604 row
[cnHelpText
] = jTextAreaHelp
.getText();
605 // row[cnRecInstName] = jComboBox.getSelectedItem()+"";
606 // row[cnRecInstVer] = jTextField2RecInstVer.getText();
607 row
[cnSupArch
] = vectorToString(iCheckBoxListArch
.getAllCheckedItemsString());
608 if (row
[cnSupArch
].length() == 0) {
609 row
[cnSupArch
] = null;
611 row
[cnSupMod
] = vectorToString(iCheckBoxListModules
.getAllCheckedItemsString());
612 if (row
[cnSupMod
].length() == 0){
613 row
[cnSupMod
] = null;
615 if (!dataValidation(row
)) {
619 //convert to GUID before storing recommended lib instance.
621 // getLibInstances(row[cnClassName]);
622 // String recommendGuid = nameToGuid(row[cnRecInstName]);
623 // if (row[cnRecInstName].equals("null")) {
624 // row[cnRecInstName] = null;
627 // if (recommendGuid == null) {
628 // JOptionPane.showMessageDialog(frame, "Recommended Instance does not exist.");
633 sfc
.genSpdLibClassDeclarations(row
[cnClassName
], null, row
[cnHdrFile
], row
[cnHelpText
], row
[cnSupArch
], null, null, null, null, row
[cnSupMod
]);
635 jTable
.changeSelection(model
.getRowCount()-1, 0, false, false);
636 docConsole
.setSaved(false);
639 // remove selected line
641 if (arg0
.getSource() == jButtonRemove
) {
642 if (jTable
.isEditing()){
643 jTable
.getCellEditor().stopCellEditing();
645 int rowSelected
= selectedRow
;
646 if (rowSelected
>= 0) {
647 model
.removeRow(rowSelected
);
648 docConsole
.setSaved(false);
649 sfc
.removeSpdLibClass(rowSelected
);
653 if (arg0
.getSource() == jButtonRemoveAll
) {
654 if (model
.getRowCount() == 0) {
657 docConsole
.setSaved(false);
658 model
.setRowCount(0);
659 sfc
.removeSpdLibClass();
663 private boolean dataValidation(String
[] row
) {
664 if (!DataValidation
.isKeywordType(row
[cnClassName
])) {
665 JOptionPane
.showMessageDialog(frame
, "Library Class name entered does not match KeyWord datatype.");
668 if (!DataValidation
.isPathAndFilename(row
[cnHdrFile
])) {
669 JOptionPane
.showMessageDialog(frame
, "Include Header does not match the PathAndFilename datatype.");
672 if (row
[cnHelpText
].length() == 0) {
673 JOptionPane
.showMessageDialog(frame
, "Help Text must be entered!");
676 // if (row[cnRecInstVer] != null && row[cnRecInstVer].length() > 0) {
677 // if (row[cnRecInstName] == null || row[cnRecInstName].length() == 0) {
678 // JOptionPane.showMessageDialog(frame, "Recommended Instance Version must associate with the Instance Name.");
682 // if (!DataValidation.isVersionDataType(row[cnRecInstVer])) {
683 // JOptionPane.showMessageDialog(frame, "Recommended Instance Version does not match Version datatype.");
690 Add contents in list to sfc
692 protected void save() {
697 This method initializes jTextField
699 @return javax.swing.JTextField
701 private JTextField
getJTextFieldHdr() {
702 if (jTextFieldHdr
== null) {
703 jTextFieldHdr
= new JTextField();
704 jTextFieldHdr
.setPreferredSize(new java
.awt
.Dimension(shortWidth
,20));
705 jTextFieldHdr
.setLocation(new java
.awt
.Point(longValueCol
,rowThree
));
706 jTextFieldHdr
.setSize(new java
.awt
.Dimension(shortWidth
,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(longValueCol
+ shortWidth
+ 7,rowThree
,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.jTextFieldAddClass
, this.getWidth(), intPreferredWidth
-28);
771 Tools
.resizeComponentWidth(this.jHelpTextScrollPane
, this.getWidth(), intPreferredWidth
-28);
772 Tools
.resizeComponentWidth(this.jScrollPaneTable
, this.getWidth(), intPreferredWidth
-10);
773 Tools
.resizeComponentWidth(this.jTextFieldHdr
, this.getWidth(), intPreferredWidth
- 7);
774 Tools
.relocateComponentX(this.jButtonBrowse
, this.getWidth(), intPreferredWidth
,
775 DataType
.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON
);
779 * This method initializes jHelpTextScrollPane
781 * @return javax.swing.JScrollPane jHelpTextScrollPane
783 private JScrollPane
getJHelpTextScrollPane() {
784 if (jHelpTextScrollPane
== null) {
785 jHelpTextScrollPane
= new JScrollPane();
786 jHelpTextScrollPane
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
787 jHelpTextScrollPane
.setPreferredSize(new java
.awt
.Dimension(longValueWidth
, 80));
788 jHelpTextScrollPane
.setSize(new java
.awt
.Dimension(longValueWidth
, 80));
789 jHelpTextScrollPane
.setLocation(new java
.awt
.Point(shortValueCol
,rowTwo
));
790 jHelpTextScrollPane
.setViewportView(getJTextAreaHelp());
792 return jHelpTextScrollPane
;
796 * This method initializes jTextAreaHelp
798 * @return javax.swing.JTextArea
800 private JTextArea
getJTextAreaHelp() {
801 if (jTextAreaHelp
== null) {
802 jTextAreaHelp
= new JTextArea();
803 jTextAreaHelp
.setLineWrap(true);
804 jTextAreaHelp
.setWrapStyleWord(true);
806 return jTextAreaHelp
;
809 private JScrollPane
getJScrollPaneModules() {
810 if (jScrollPaneModules
== null) {
811 jScrollPaneModules
= new JScrollPane();
812 jScrollPaneModules
.setBounds(new java
.awt
.Rectangle(longValueCol
,rowFive
,medWidth
,60));
813 jScrollPaneModules
.setPreferredSize(new java
.awt
.Dimension(medWidth
, 60));
814 jScrollPaneModules
.setViewportView(getICheckBoxListSupportedModules());
816 return jScrollPaneModules
;
819 private ICheckBoxList
getICheckBoxListSupportedModules() {
820 if (iCheckBoxListModules
== null) {
821 iCheckBoxListModules
= new ICheckBoxList();
822 iCheckBoxListModules
.setBounds(new java
.awt
.Rectangle(longValueCol
,rowFour
,medWidth
,60));
823 Vector
<String
> v
= new Vector
<String
>();
830 v
.add("DXE_RUNTIME_DRIVER");
831 v
.add("DXE_SAL_DRIVER");
832 v
.add("DXE_SMM_DRIVER");
833 v
.add("UEFI_DRIVER");
834 v
.add("UEFI_APPLICATION");
835 v
.add("USER_DEFINED");
836 iCheckBoxListModules
.setAllItems(v
);
838 return iCheckBoxListModules
;
841 private String
vectorToString(Vector
<String
> v
) {
843 for (int i
= 0; i
< v
.size(); ++i
) {
850 private JScrollPane
getJScrollPane1Arch() {
851 if (jScrollPane1Arch
== null) {
852 jScrollPane1Arch
= new JScrollPane();
853 jScrollPane1Arch
.setBounds(new java
.awt
.Rectangle(longValueCol
,rowFour
,medWidth
,60));
854 jScrollPane1Arch
.setPreferredSize(new java
.awt
.Dimension(medWidth
, 60));
855 jScrollPane1Arch
.setViewportView(getICheckBoxListArch());
857 return jScrollPane1Arch
;
860 * This method initializes iCheckBoxList
862 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
864 private ICheckBoxList
getICheckBoxListArch() {
865 if (iCheckBoxListArch
== null) {
866 iCheckBoxListArch
= new ICheckBoxList();
867 iCheckBoxListArch
.setBounds(new java
.awt
.Rectangle(longValueCol
,rowFour
,medWidth
,60));
868 Vector
<String
> v
= new Vector
<String
>();
875 iCheckBoxListArch
.setAllItems(v
);
877 return iCheckBoxListArch
;
880 // private void getLibInstances(String libClass){
881 // libNameGuidMap.clear();
883 // Iterator ismi = GlobalData.vModuleList.iterator();
884 // while (ismi.hasNext()) {
885 // ModuleIdentification mi = (ModuleIdentification) ismi.next();
887 // Vector<String> classProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
888 // for (int i = 0; i < classProduced.size(); ++i) {
889 // if (classProduced.get(i).equals(libClass)) {
890 // libNameGuidMap.put(mi.getName(), mi.getGuid());
896 // catch(Exception e){
897 // JOptionPane.showMessageDialog(frame, "Search Instances Failed.");
902 // private String nameToGuid(String name) {
904 // if (!libNameGuidMap.containsKey(name)) {
908 // s = libNameGuidMap.get(name);
912 // private String guidToName(String guid){
914 // if (!libNameGuidMap.containsValue(guid)) {
917 // Set<String> key = libNameGuidMap.keySet();
918 // Iterator<String> is = key.iterator();
919 // while(is.hasNext()) {
921 // if (libNameGuidMap.get(s).equals(guid)) {