]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdLibClassDecls.java
Use unified global data to get module informations.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / packaging / ui / SpdLibClassDecls.java
1 /** @file
2 Java class SpdLibClassDecls is GUI for create library definition elements of spd file.
3
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
9
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.
12 **/
13 package org.tianocore.frameworkwizard.packaging.ui;
14
15 import java.awt.Dimension;
16 import java.awt.event.ActionEvent;
17 import java.awt.event.ComponentEvent;
18 import java.io.File;
19 import java.util.HashMap;
20 import java.util.Iterator;
21 import java.util.Set;
22 import java.util.Vector;
23
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.JComboBox;
31 import javax.swing.JLabel;
32 import javax.swing.JScrollPane;
33 import javax.swing.JButton;
34 import javax.swing.JFrame;
35 import javax.swing.ListSelectionModel;
36 import javax.swing.event.InternalFrameAdapter;
37 import javax.swing.event.InternalFrameEvent;
38 import javax.swing.event.ListSelectionEvent;
39 import javax.swing.event.ListSelectionListener;
40 import javax.swing.event.TableModelEvent;
41 import javax.swing.event.TableModelListener;
42 import javax.swing.table.DefaultTableModel;
43 import javax.swing.table.TableModel;
44 import org.tianocore.PackageSurfaceAreaDocument;
45 import org.tianocore.frameworkwizard.common.DataValidation;
46 import org.tianocore.frameworkwizard.common.GlobalData;
47 import org.tianocore.frameworkwizard.common.Tools;
48 import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;
49 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
50 import org.tianocore.frameworkwizard.common.ui.StarLabel;
51 import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
52 import org.tianocore.frameworkwizard.platform.ui.ListEditor;
53 import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
54 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
55
56
57 /**
58 GUI for create library definition elements of spd file.
59
60 @since PackageEditor 1.0
61 **/
62 public class SpdLibClassDecls extends IInternalFrame implements TableModelListener{
63 /**
64 *
65 */
66 private static final long serialVersionUID = 1L;
67
68 static JFrame frame;
69
70 private JTable jTable = null;
71
72 private DefaultTableModel model = null;
73
74 private JPanel jContentPane = null;
75
76 private JTextField jTextFieldClass = null;
77
78 private JComboBox jComboBoxSelect = null;
79
80 private JScrollPane jScrollPane = null;
81
82 private JButton jButtonAdd = null;
83
84 private JButton jButtonRemove = null;
85
86 private JButton jButtonRemoveAll = null;
87
88 private JLabel jLabelHdr = null;
89
90 private JTextField jTextFieldHdr = null;
91
92 private JButton jButtonBrowse = null;
93
94 private StarLabel jStarLabel1 = null;
95
96 private StarLabel jStarLabel2 = null;
97
98 private SpdFileContents sfc = null;
99
100 private OpeningPackageType docConsole = null;
101
102 private JLabel jLabel1ClassName = null;
103
104 private JScrollPane topScrollPane = null; // @jve:decl-index=0:visual-constraint="10,53"
105
106 private int selectedRow = -1;
107
108 private StarLabel starLabel = null;
109
110 private JLabel jLabel2HelpText = null;
111
112 private JTextField jTextFieldHelp = null;
113
114 private JLabel jLabel3RecInstName = null;
115
116 private JTextField jTextField1RecInstName = null;
117
118 private JLabel jLabel4RecInstVer = null;
119
120 private JTextField jTextField2RecInstVer = null;
121
122 private JLabel jLabel5SupArchList = null;
123
124 private JLabel jLabel6SupModList = null;
125
126 private JScrollPane jScrollPaneModules = null;
127
128 private JScrollPane jScrollPane1Arch = null;
129
130 private ICheckBoxList iCheckBoxListModules = null;
131
132 private ICheckBoxList iCheckBoxListArch = null;
133
134 private JComboBox jComboBox = null;
135
136 private int cnClassName = 0;
137 private int cnHdrFile = 1;
138 private int cnHelpText = 2;
139 private int cnRecInstName = 3;
140 private int cnRecInstVer = 4;
141 private int cnSupArch = 5;
142 private int cnSupMod = 6;
143
144 HashMap<String, String> libNameGuidMap = new HashMap<String, String>();
145
146
147 /**
148 This method initializes this
149
150 **/
151 private void initialize() {
152
153 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
154
155 }
156
157 /**
158 This method initializes jTextFieldAdd
159
160 @return javax.swing.JTextField
161 **/
162 private JTextField getJTextFieldClass() {
163 if (jTextFieldClass == null) {
164 jTextFieldClass = new JTextField();
165 jTextFieldClass.setBounds(new java.awt.Rectangle(122,6,390,20));
166 jTextFieldClass.setPreferredSize(new java.awt.Dimension(260,20));
167 jTextFieldClass.setEnabled(true);
168 }
169 return jTextFieldClass;
170 }
171
172 /**
173 This method initializes jComboBoxSelect
174
175 @return javax.swing.JComboBox
176 **/
177 private JComboBox getJComboBoxSelect() {
178 if (jComboBoxSelect == null) {
179 jComboBoxSelect = new JComboBox();
180 jComboBoxSelect.setBounds(new java.awt.Rectangle(220, 10, 260, 20));
181 jComboBoxSelect.setPreferredSize(new java.awt.Dimension(260,22));
182 jComboBoxSelect.setEnabled(true);
183 jComboBoxSelect.setVisible(false);
184 }
185 return jComboBoxSelect;
186 }
187
188 /**
189 This method initializes jScrollPane
190
191 @return javax.swing.JScrollPane
192
193 Used for the Table of Library Classes that are provided by this package
194
195 **/
196 private JScrollPane getJScrollPane() {
197 if (jScrollPane == null) {
198 jScrollPane = new JScrollPane();
199 jScrollPane.setBounds(new java.awt.Rectangle(12,351,400,253));
200 jScrollPane.setViewportView(getJTable());
201 }
202 return jScrollPane;
203 }
204
205 /**
206 This method initializes jTable
207
208 @return javax.swing.JTable
209 **/
210 private JTable getJTable() {
211 if (jTable == null) {
212 model = new DefaultTableModel();
213 jTable = new JTable(model);
214 jTable.setRowHeight(20);
215 jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
216 jTable.setColumnSelectionAllowed(false);
217 model.addColumn("Class Name");
218 model.addColumn("Header");
219 model.addColumn("Help Text");
220 model.addColumn("Recommended Instance");
221 model.addColumn("Version");
222 model.addColumn("Supported Architectures");
223 model.addColumn("Supported Module Types");
224
225 Vector<String> vArch = new Vector<String>();
226 vArch.add("IA32");
227 vArch.add("X64");
228 vArch.add("IPF");
229 vArch.add("EBC");
230 vArch.add("ARM");
231 vArch.add("PPC");
232 jTable.getColumnModel().getColumn(cnSupArch).setCellEditor(new ListEditor(vArch));
233
234 Vector<String> vModule = new Vector<String>();
235 vModule.add("BASE");
236 vModule.add("SEC");
237 vModule.add("PEI_CORE");
238 vModule.add("PEIM");
239 vModule.add("DXE_CORE");
240 vModule.add("DXE_DRIVER");
241 vModule.add("DXE_RUNTIME_DRIVER");
242 vModule.add("DXE_SAL_DRIVER");
243 vModule.add("DXE_SMM_DRIVER");
244 vModule.add("UEFI_DRIVER");
245 vModule.add("UEFI_APPLICATION");
246 vModule.add("USER_DEFINED");
247
248 jTable.getColumnModel().getColumn(cnSupMod).setCellEditor(new ListEditor(vModule));
249
250 jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
251 jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
252 public void valueChanged(ListSelectionEvent e) {
253 if (e.getValueIsAdjusting()){
254 return;
255 }
256 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
257 if (lsm.isSelectionEmpty()) {
258 return;
259 }
260 else{
261 selectedRow = lsm.getMinSelectionIndex();
262 }
263 }
264 });
265
266 jTable.getModel().addTableModelListener(this);
267
268 }
269 return jTable;
270 }
271
272
273 public void tableChanged(TableModelEvent arg0) {
274 // TODO Auto-generated method stub
275 int row = arg0.getFirstRow();
276 int column = arg0.getColumn();
277 TableModel m = (TableModel)arg0.getSource();
278 if (arg0.getType() == TableModelEvent.UPDATE){
279
280 String lib = m.getValueAt(row, cnClassName) + "";
281 String hdr = m.getValueAt(row, cnHdrFile) + "";
282 String hlp = m.getValueAt(row, cnHelpText) + "";
283 String name = null;
284 if (m.getValueAt(row, cnRecInstName) != null) {
285 name = m.getValueAt(row, cnRecInstName).toString();
286 }
287 String ver = null;
288 if (m.getValueAt(row, cnRecInstVer) != null){
289 ver = m.getValueAt(row, cnRecInstVer).toString();
290 }
291 String arch = null;
292 if (m.getValueAt(row, cnSupArch) != null) {
293 arch = m.getValueAt(row, cnSupArch).toString();
294 }
295 String module = null;
296 if (m.getValueAt(row, cnSupMod) != null) {
297 module = m.getValueAt(row, cnSupMod).toString();
298 }
299 String[] rowData = {lib, hdr, hlp, name, ver};
300 if (!dataValidation(rowData)) {
301 return;
302 }
303
304 String guid = null;
305 if (name != null && name.length() > 0) {
306 getLibInstances(lib);
307 guid = nameToGuid(name);
308 if (guid == null){
309 JOptionPane.showMessageDialog(frame, "Recommended Instance does not exist.");
310 return;
311 }
312 }
313
314 String[] sa = new String[7];
315 sfc.getSpdLibClassDeclaration(sa, row);
316 Object cellData = m.getValueAt(row, column);
317 if (cellData == null) {
318 cellData = "";
319 }
320 if (column == cnRecInstName) {
321 if (guid == null) {
322 if (sa[cnRecInstName] == null) {
323 return;
324 }
325 }
326 else {
327 if (guid.equals(sa[cnRecInstName])) {
328 return;
329 }
330 }
331 }
332 else {
333 if (cellData.equals(sa[column])) {
334 return;
335 }
336 if (cellData.toString().length() == 0 && sa[column] == null) {
337 return;
338 }
339 }
340 docConsole.setSaved(false);
341 sfc.updateSpdLibClass(row, lib, hdr, hlp, guid, ver, arch, module);
342 }
343 }
344
345 /**
346 This method initializes jButtonAdd
347
348 @return javax.swing.JButton
349 **/
350 private JButton getJButtonAdd() {
351 if (jButtonAdd == null) {
352 jButtonAdd = new JButton();
353 jButtonAdd.setText("Add");
354 jButtonAdd.setSize(new java.awt.Dimension(99,20));
355 jButtonAdd.setBounds(new java.awt.Rectangle(321,326,99,20));
356 jButtonAdd.addActionListener(this);
357 }
358 return jButtonAdd;
359 }
360
361 /**
362 This method initializes jButtonRemove
363
364 @return javax.swing.JButton
365 **/
366 private JButton getJButtonRemove() {
367 if (jButtonRemove == null) {
368 jButtonRemove = new JButton();
369 jButtonRemove.setText("Remove");
370 jButtonRemove.setSize(new java.awt.Dimension(99,20));
371 jButtonRemove.setBounds(new java.awt.Rectangle(424,326,99,20));
372 jButtonRemove.addActionListener(this);
373 }
374 return jButtonRemove;
375 }
376
377 /**
378 This method initializes jButtonRemoveAll
379
380 @return javax.swing.JButton
381 **/
382 private JButton getJButtonRemoveAll() {
383 if (jButtonRemoveAll == null) {
384 jButtonRemoveAll = new JButton();
385 jButtonRemoveAll.setText("Remove All");
386 jButtonRemoveAll.setSize(new java.awt.Dimension(99,20));
387 jButtonRemoveAll.setBounds(new java.awt.Rectangle(527,326,99,20));
388 jButtonRemoveAll.addActionListener(this);
389 }
390 return jButtonRemoveAll;
391 }
392
393 /**
394 This is the default constructor
395 **/
396 public SpdLibClassDecls() {
397 super();
398 initialize();
399 init();
400
401 }
402
403 public SpdLibClassDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){
404 this();
405 sfc = new SpdFileContents(inPsa);
406 init(sfc);
407 }
408
409 public SpdLibClassDecls(OpeningPackageType opt) {
410 this(opt.getXmlSpd());
411 docConsole = opt;
412 }
413 /**
414 This method initializes this
415
416 @return void
417 **/
418 private void init() {
419
420 this.setContentPane(getJContentPane());
421 this.setTitle("Library Class Declarations");
422 this.setBounds(new java.awt.Rectangle(0, 0, 500, 370));
423 this.setVisible(true);
424 this.addInternalFrameListener(new InternalFrameAdapter(){
425 public void internalFrameDeactivated(InternalFrameEvent e){
426 if (jTable.isEditing()) {
427 jTable.getCellEditor().stopCellEditing();
428 }
429 }
430 });
431 initFrame();
432 }
433
434 private void init(SpdFileContents sfc) {
435 if (sfc.getSpdLibClassDeclarationCount() == 0) {
436 return ;
437 }
438 //
439 // initialize table using SpdFileContents object
440 //
441 String[][] saa = new String[sfc.getSpdLibClassDeclarationCount()][7];
442 sfc.getSpdLibClassDeclarations(saa);
443 int i = 0;
444 while (i < saa.length) {
445 if (saa[i][3] != null && saa[i][3].length() > 0) {
446 getLibInstances(saa[i][0]);
447 saa[i][3] = guidToName(saa[i][3]);
448 }
449
450 model.addRow(saa[i]);
451 i++;
452 }
453 }
454 private JScrollPane getJContentPane(){
455 if (topScrollPane == null){
456 topScrollPane = new JScrollPane();
457 // topScrollPane.setSize(new java.awt.Dimension(634,590));
458 topScrollPane.setViewportView(getJContentPane1());
459 }
460 return topScrollPane;
461 }
462 /**
463 This method initializes jContentPane
464
465 @return javax.swing.JPanel
466 **/
467 private JPanel getJContentPane1() {
468 if (jContentPane == null) {
469 // Library Class
470 jStarLabel1 = new StarLabel();
471 jStarLabel1.setLocation(new java.awt.Point(1,7));
472 jLabel1ClassName = new JLabel();
473 jLabel1ClassName.setBounds(new java.awt.Rectangle(16,6,82,20));
474 jLabel1ClassName.setText("Library Class");
475
476 // Help Text
477 starLabel = new StarLabel();
478 starLabel.setBounds(new java.awt.Rectangle(1,33,10,20));
479 jLabel2HelpText = new JLabel();
480 jLabel2HelpText.setBounds(new java.awt.Rectangle(16,33,82,20));
481 jLabel2HelpText.setText("Help Text");
482
483 // Header File
484 jStarLabel2 = new StarLabel();
485 jStarLabel2.setLocation(new java.awt.Point(1,74));
486 jLabelHdr = new JLabel();
487 jLabelHdr.setBounds(new java.awt.Rectangle(14,74,199,22));
488 jLabelHdr.setText("Include Header for Specified Class");
489
490 jLabel6SupModList = new JLabel();
491 jLabel6SupModList.setBounds(new java.awt.Rectangle(16,252,108,16));
492 jLabel6SupModList.setText("Supported Module");
493 jLabel6SupModList.setEnabled(true);
494
495 jLabel5SupArchList = new JLabel();
496 jLabel5SupArchList.setBounds(new java.awt.Rectangle(15,169,93,16));
497 jLabel5SupArchList.setText("Supported Arch");
498 jLabel5SupArchList.setEnabled(true);
499 jLabel4RecInstVer = new JLabel();
500 jLabel4RecInstVer.setBounds(new java.awt.Rectangle(16,138,196,16));
501 jLabel4RecInstVer.setEnabled(true);
502 jLabel4RecInstVer.setText("Recommended Instance Version");
503 jLabel3RecInstName = new JLabel();
504 jLabel3RecInstName.setBounds(new java.awt.Rectangle(17,112,195,16));
505 jLabel3RecInstName.setEnabled(true);
506 jLabel3RecInstName.setText("Recommended Instance Name");
507
508 jContentPane = new JPanel();
509 jContentPane.setPreferredSize(new Dimension(680, 600));
510 jContentPane.setLayout(null);
511 jContentPane.add(jLabelHdr, null);
512 jContentPane.add(jStarLabel1, null);
513 jContentPane.add(jStarLabel2, null);
514 jContentPane.add(getJTextFieldClass(), null);
515 jContentPane.add(getJComboBoxSelect(), null);
516 jContentPane.add(getJScrollPane(), null);
517 jContentPane.add(getJButtonAdd(), null);
518 jContentPane.add(getJButtonRemove(), null);
519 jContentPane.add(getJButtonRemoveAll(), null);
520
521 jContentPane.add(getJTextFieldHdr(), null);
522 jContentPane.add(getJButtonBrowse(), null);
523 jContentPane.add(jLabel1ClassName, null);
524 jContentPane.add(starLabel, null);
525 jContentPane.add(jLabel2HelpText, null);
526 jContentPane.add(getJTextFieldHelp(), null);
527
528 jContentPane.add(jLabel3RecInstName, null);
529 jContentPane.add(getJTextField1RecInstName(), null);
530 jContentPane.add(jLabel4RecInstVer, null);
531 jContentPane.add(getJTextField2RecInstVer(), null);
532 jContentPane.add(jLabel5SupArchList, null);
533 jContentPane.add(jLabel6SupModList, null);
534
535 jContentPane.add(getJScrollPaneModules(), null);
536 jContentPane.add(getJScrollPane1Arch(), null);
537 jContentPane.add(getJComboBox(), null);
538
539 }
540
541 return jContentPane;
542 }
543
544 /**
545 fill ComboBoxes with pre-defined contents
546 **/
547 private void initFrame() {
548 jComboBoxSelect.addItem("BaseCpuICacheFlush");
549 jComboBoxSelect.addItem("BaseDebugLibNull");
550 jComboBoxSelect.addItem("BaseDebugLibReportStatusCode");
551 jComboBoxSelect.addItem("BaseIoLibIntrinsic");
552 jComboBoxSelect.addItem("BaseLib");
553 jComboBoxSelect.addItem("BaseMemoryLib");
554 jComboBoxSelect.addItem("BaseMemoryLibMmx");
555 jComboBoxSelect.addItem("BaseMemoryLibSse2");
556 jComboBoxSelect.addItem("BasePeCoffGetEntryPointLib");
557 jComboBoxSelect.addItem("BasePeCoffLib");
558 jComboBoxSelect.addItem("BasePrintLib");
559 jComboBoxSelect.addItem("BaseReportStatusCodeLibNull");
560 jComboBoxSelect.addItem("CommonPciCf8Lib");
561 jComboBoxSelect.addItem("CommonPciExpressLib");
562 jComboBoxSelect.addItem("CommonPciLibCf8");
563 jComboBoxSelect.addItem("CommonPciLibPciExpress");
564 jComboBoxSelect.addItem("DxeCoreEntryPoint");
565 jComboBoxSelect.addItem("DxeHobLib");
566 jComboBoxSelect.addItem("DxeIoLibCpuIo");
567 jComboBoxSelect.addItem("DxeLib");
568 jComboBoxSelect.addItem("DxePcdLib");
569 jComboBoxSelect.addItem("DxeReportStatusCodeLib");
570 jComboBoxSelect.addItem("DxeServicesTableLib");
571 jComboBoxSelect.addItem("PeiCoreEntryPoint");
572 jComboBoxSelect.addItem("PeiMemoryLib");
573 jComboBoxSelect.addItem("PeimEntryPoint");
574 jComboBoxSelect.addItem("PeiReportStatusCodeLib");
575 jComboBoxSelect.addItem("PeiServicesTablePointerLib");
576 jComboBoxSelect.addItem("PeiServicesTablePointerLibMm7");
577 jComboBoxSelect.addItem("UefiDebugLibConOut");
578 jComboBoxSelect.addItem("UefiDebugLibStdErr");
579 jComboBoxSelect.addItem("UefiDriverEntryPointMultiple");
580 jComboBoxSelect.addItem("UefiDriverEntryPointSingle");
581 jComboBoxSelect.addItem("UefiDriverEntryPointSingleUnload");
582 jComboBoxSelect.addItem("UefiDriverModelLib");
583 jComboBoxSelect.addItem("UefiDriverModelLibNoConfigNoDiag");
584 jComboBoxSelect.addItem("UefiLib");
585 jComboBoxSelect.addItem("UefiMemoryLib");
586
587 }
588
589 /* (non-Javadoc)
590 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
591 */
592 public void actionPerformed(ActionEvent arg0) {
593
594 if (arg0.getSource() == jButtonAdd) {
595
596 //ToDo: check before add
597 // LAH WAS String[] row = {null, null, null, jComboBox.getSelectedItem()+"", jTextField2RecInstVer.getText(), null, null};
598 String[] row = {null, null, null, null, null, null, null};
599 row[cnClassName] = jTextFieldClass.getText();
600 row[cnHdrFile] = jTextFieldHdr.getText().replace('\\', '/');
601 row[cnHelpText] = jTextFieldHelp.getText();
602 row[cnRecInstName] = jComboBox.getSelectedItem()+"";
603 row[cnRecInstVer] = jTextField2RecInstVer.getText();
604 row[cnSupArch] = vectorToString(iCheckBoxListArch.getAllCheckedItemsString());
605 if (row[cnSupArch].length() == 0) {
606 row[cnSupArch] = null;
607 }
608 row[cnSupMod] = vectorToString(iCheckBoxListModules.getAllCheckedItemsString());
609 if (row[cnSupMod].length() == 0){
610 row[cnSupMod] = null;
611 }
612 if (!dataValidation(row)) {
613 return;
614 }
615 //
616 //convert to GUID before storing recommended lib instance.
617 //
618 getLibInstances(row[cnClassName]);
619 String recommendGuid = nameToGuid(row[cnRecInstName]);
620 if (row[cnRecInstName].equals("null")) {
621 row[cnRecInstName] = null;
622 }
623 else{
624 if (recommendGuid == null) {
625 JOptionPane.showMessageDialog(frame, "Recommended Instance does not exist.");
626 return;
627 }
628 }
629
630 sfc.genSpdLibClassDeclarations(row[cnClassName], recommendGuid, row[cnHdrFile], row[cnHelpText], row[cnSupArch], null, null, row[cnRecInstVer], null, row[cnSupMod]);
631 model.addRow(row);
632 jTable.changeSelection(model.getRowCount()-1, 0, false, false);
633 docConsole.setSaved(false);
634 }
635 //
636 // remove selected line
637 //
638 if (arg0.getSource() == jButtonRemove) {
639 if (jTable.isEditing()){
640 jTable.getCellEditor().stopCellEditing();
641 }
642 int rowSelected = selectedRow;
643 if (rowSelected >= 0) {
644 model.removeRow(rowSelected);
645 docConsole.setSaved(false);
646 sfc.removeSpdLibClass(rowSelected);
647 }
648 }
649
650 if (arg0.getSource() == jButtonRemoveAll) {
651 if (model.getRowCount() == 0) {
652 return;
653 }
654 docConsole.setSaved(false);
655 model.setRowCount(0);
656 sfc.removeSpdLibClass();
657 }
658 }
659
660 private boolean dataValidation(String[] row) {
661 if (!DataValidation.isKeywordType(row[cnClassName])) {
662 JOptionPane.showMessageDialog(frame, "Library Class name entered does not match KeyWord datatype.");
663 return false;
664 }
665 if (!DataValidation.isPathAndFilename(row[cnHdrFile])) {
666 JOptionPane.showMessageDialog(frame, "Include Header does not match the PathAndFilename datatype.");
667 return false;
668 }
669 if (row[cnHelpText].length() == 0) {
670 JOptionPane.showMessageDialog(frame, "Help Text must be entered!");
671 return false;
672 }
673 if (row[cnRecInstVer] != null && row[cnRecInstVer].length() > 0) {
674 if (row[cnRecInstName] == null || row[cnRecInstName].length() == 0) {
675 JOptionPane.showMessageDialog(frame, "Recommended Instance Version must associate with the Instance Name.");
676 return false;
677 }
678
679 if (!DataValidation.isVersionDataType(row[cnRecInstVer])) {
680 JOptionPane.showMessageDialog(frame, "Recommended Instance Version does not match Version datatype.");
681 return false;
682 }
683 }
684 return true;
685 }
686 /**
687 Add contents in list to sfc
688 **/
689 protected void save() {
690
691 }
692
693 /**
694 This method initializes jTextField
695
696 @return javax.swing.JTextField
697 **/
698 private JTextField getJTextFieldHdr() {
699 if (jTextFieldHdr == null) {
700 jTextFieldHdr = new JTextField();
701 jTextFieldHdr.setBounds(new java.awt.Rectangle(218,75,305,21));
702 jTextFieldHdr.setPreferredSize(new java.awt.Dimension(260,20));
703 }
704 return jTextFieldHdr;
705 }
706
707 /**
708 This method initializes jButtonBrowse
709
710 @return javax.swing.JButton
711 **/
712 private JButton getJButtonBrowse() {
713 if (jButtonBrowse == null) {
714 jButtonBrowse = new JButton();
715 jButtonBrowse.setBounds(new java.awt.Rectangle(527,75,90,20));
716 jButtonBrowse.setText("Browse");
717 jButtonBrowse.setPreferredSize(new java.awt.Dimension(99,20));
718 jButtonBrowse.addActionListener(new AbstractAction() {
719
720 /**
721 *
722 */
723 private static final long serialVersionUID = 1L;
724
725 public void actionPerformed(ActionEvent arg0) {
726 //
727 // Select files from current pkg
728 //
729 String dirPrefix = Tools.dirForNewSpd.substring(0, Tools.dirForNewSpd.lastIndexOf(File.separator));
730 JFileChooser chooser = new JFileChooser(dirPrefix);
731 File theFile = null;
732 String headerDest = null;
733
734 chooser.setMultiSelectionEnabled(false);
735 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
736 int retval = chooser.showOpenDialog(frame);
737 if (retval == JFileChooser.APPROVE_OPTION) {
738
739 theFile = chooser.getSelectedFile();
740 String file = theFile.getPath();
741 if (!file.startsWith(dirPrefix)) {
742 JOptionPane.showMessageDialog(frame, "You can only select files in current package directory structure!");
743 return;
744 }
745
746
747 }
748 else {
749 return;
750 }
751
752 headerDest = theFile.getPath();
753 int fileIndex = headerDest.indexOf(System.getProperty("file.separator"), dirPrefix.length());
754 jTextFieldHdr.setText(headerDest.substring(fileIndex + 1).replace('\\', '/'));
755
756 }
757
758 });
759 }
760 return jButtonBrowse;
761 }
762
763 public void componentResized(ComponentEvent arg0) {
764 int intPreferredWidth = 500;
765
766 Tools.resizeComponentWidth(this.jTextFieldClass, this.getWidth(), intPreferredWidth);
767 Tools.resizeComponentWidth(this.jTextFieldHelp, this.getWidth(), intPreferredWidth);
768 Tools.resizeComponentWidth(this.jScrollPane, this.getWidth(), intPreferredWidth-10);
769
770 }
771 /**
772 * This method initializes jTextFieldHelp
773 *
774 * @return javax.swing.JTextField
775 */
776 private JTextField getJTextFieldHelp() {
777 if (jTextFieldHelp == null) {
778 jTextFieldHelp = new JTextField();
779 jTextFieldHelp.setBounds(new java.awt.Rectangle(122,33,390,20));
780 jTextFieldHelp.setPreferredSize(new java.awt.Dimension(260,20));
781 }
782 return jTextFieldHelp;
783 }
784
785 /**
786 * This method initializes jTextField1RecInstName
787 *
788 * @return javax.swing.JTextField
789 */
790 private JTextField getJTextField1RecInstName() {
791 if (jTextField1RecInstName == null) {
792 jTextField1RecInstName = new JTextField();
793 jTextField1RecInstName.setBounds(new java.awt.Rectangle(218,110,291,20));
794 jTextField1RecInstName.setEnabled(true);
795 jTextField1RecInstName.setVisible(false);
796 }
797 return jTextField1RecInstName;
798 }
799
800 /**
801 * This method initializes jTextField2RecInstVer
802 *
803 * @return javax.swing.JTextField
804 */
805 private JTextField getJTextField2RecInstVer() {
806 if (jTextField2RecInstVer == null) {
807 jTextField2RecInstVer = new JTextField();
808 jTextField2RecInstVer.setBounds(new java.awt.Rectangle(218,135,292,20));
809 jTextField2RecInstVer.setEnabled(true);
810 }
811 return jTextField2RecInstVer;
812 }
813
814 private JScrollPane getJScrollPaneModules() {
815 if (jScrollPaneModules == null) {
816 jScrollPaneModules = new JScrollPane();
817 jScrollPaneModules.setBounds(new java.awt.Rectangle(218,245,293,73));
818 jScrollPaneModules.setPreferredSize(new java.awt.Dimension(320, 80));
819 jScrollPaneModules.setViewportView(getICheckBoxListSupportedModules());
820 }
821 return jScrollPaneModules;
822 }
823
824 private ICheckBoxList getICheckBoxListSupportedModules() {
825 if (iCheckBoxListModules == null) {
826 iCheckBoxListModules = new ICheckBoxList();
827 iCheckBoxListModules.setBounds(new java.awt.Rectangle(218,246,292,73));
828 Vector<String> v = new Vector<String>();
829 v.add("BASE");
830 v.add("SEC");
831 v.add("PEI_CORE");
832 v.add("PEIM");
833 v.add("DXE_CORE");
834 v.add("DXE_DRIVER");
835 v.add("DXE_RUNTIME_DRIVER");
836 v.add("DXE_SAL_DRIVER");
837 v.add("DXE_SMM_DRIVER");
838 v.add("UEFI_DRIVER");
839 v.add("UEFI_APPLICATION");
840 v.add("USER_DEFINED");
841 iCheckBoxListModules.setAllItems(v);
842 }
843 return iCheckBoxListModules;
844 }
845
846 private String vectorToString(Vector<String> v) {
847 String s = " ";
848 for (int i = 0; i < v.size(); ++i) {
849 s += v.get(i);
850 s += " ";
851 }
852 return s.trim();
853 }
854
855 private JScrollPane getJScrollPane1Arch() {
856 if (jScrollPane1Arch == null) {
857 jScrollPane1Arch = new JScrollPane();
858 jScrollPane1Arch.setBounds(new java.awt.Rectangle(218,170,293,73));
859 jScrollPane1Arch.setPreferredSize(new java.awt.Dimension(320, 80));
860 jScrollPane1Arch.setViewportView(getICheckBoxListArch());
861 }
862 return jScrollPane1Arch;
863 }
864 /**
865 * This method initializes iCheckBoxList
866 *
867 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
868 */
869 private ICheckBoxList getICheckBoxListArch() {
870 if (iCheckBoxListArch == null) {
871 iCheckBoxListArch = new ICheckBoxList();
872 iCheckBoxListArch.setBounds(new java.awt.Rectangle(218,171,292,66));
873 Vector<String> v = new Vector<String>();
874 v.add("IA32");
875 v.add("X64");
876 v.add("IPF");
877 v.add("EBC");
878 v.add("ARM");
879 v.add("PPC");
880 iCheckBoxListArch.setAllItems(v);
881 }
882 return iCheckBoxListArch;
883 }
884
885 /**
886 * This method initializes jComboBox
887 *
888 * @return javax.swing.JComboBox
889 */
890 private JComboBox getJComboBox() {
891 if (jComboBox == null) {
892 jComboBox = new JComboBox();
893 jComboBox.setPreferredSize(new java.awt.Dimension(31,20));
894 jComboBox.setSize(new java.awt.Dimension(290,20));
895 jComboBox.setLocation(new java.awt.Point(218,111));
896 jComboBox.addFocusListener(new java.awt.event.FocusAdapter() {
897 public void focusGained(java.awt.event.FocusEvent e) {
898 if (jTextFieldClass.getText().length() == 0) {
899 return;
900 }
901 jComboBox.removeAllItems();
902 getLibInstances(jTextFieldClass.getText());
903 Set<String> libNames = libNameGuidMap.keySet();
904 Iterator<String> si = libNames.iterator();
905 while(si.hasNext()) {
906 jComboBox.addItem(si.next());
907 }
908 }
909 });
910
911 }
912 return jComboBox;
913 }
914
915 private void getLibInstances(String libClass){
916 libNameGuidMap.clear();
917 try {
918 Iterator ismi = GlobalData.vModuleList.iterator();
919 while (ismi.hasNext()) {
920 ModuleIdentification mi = (ModuleIdentification) ismi.next();
921
922 Vector<String> classProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
923 for (int i = 0; i < classProduced.size(); ++i) {
924 if (classProduced.get(i).equals(libClass)) {
925 libNameGuidMap.put(mi.getName(), mi.getGuid());
926 }
927 }
928 }
929
930 }
931 catch(Exception e){
932 JOptionPane.showMessageDialog(frame, "Search Instances Failed.");
933 }
934
935 }
936
937 private String nameToGuid(String name) {
938 String s = null;
939 if (!libNameGuidMap.containsKey(name)) {
940 return s;
941 }
942
943 s = libNameGuidMap.get(name);
944 return s;
945 }
946
947 private String guidToName(String guid){
948 String s = "";
949 if (!libNameGuidMap.containsValue(guid)) {
950 return s;
951 }
952 Set<String> key = libNameGuidMap.keySet();
953 Iterator<String> is = key.iterator();
954 while(is.hasNext()) {
955 s = is.next();
956 if (libNameGuidMap.get(s).equals(guid)) {
957 break;
958 }
959 }
960 return s;
961 }
962
963 }
964
965