]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdLibClassDecls.java
Delete useless file SpdPackageDefinitions.java;
[mirror_edk2.git] / Tools / Java / 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.FontMetrics;
17 import java.awt.event.ActionEvent;
18 import java.awt.event.ComponentEvent;
19 import java.io.File;
20 import java.util.HashMap;
21 //import java.util.Iterator;
22 //import java.util.Set;
23 import java.util.Vector;
24
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;
60
61
62 /**
63 GUI for create library definition elements of spd file.
64
65 @since PackageEditor 1.0
66 **/
67 public class SpdLibClassDecls extends IInternalFrame implements TableModelListener{
68 /**
69 *
70 */
71 private static final long serialVersionUID = 1L;
72
73 static JFrame frame;
74
75 private JTable jTable = null;
76
77 private DefaultTableModel model = null;
78
79 private JPanel jContentPane = null;
80
81 private JTextField jTextFieldAddClass = null;
82
83 private JComboBox jComboBoxSelect = null;
84
85 private JScrollPane jScrollPaneTable = null;
86
87 private JButton jButtonAdd = null;
88
89 private JButton jButtonRemove = null;
90
91 private JButton jButtonRemoveAll = null;
92
93 private JLabel jLabelHdr = null;
94
95 private JTextField jTextFieldHdr = null;
96
97 private JButton jButtonBrowse = null;
98
99 private StarLabel starLabel1 = null;
100
101 private StarLabel starLabel3 = null;
102
103 private SpdFileContents sfc = null;
104
105 private OpeningPackageType docConsole = null;
106
107 private JLabel jLabel1ClassName = null;
108
109 private JScrollPane topScrollPane = null; // @jve:decl-index=0:visual-constraint="10,53"
110
111 private int selectedRow = -1;
112
113 private StarLabel starLabel2 = null;
114
115 private JLabel jLabel2HelpText = null;
116
117 private JTextArea jTextAreaHelp = null;
118
119 private JScrollPane jHelpTextScrollPane = null;
120
121 private JLabel jLabel5SupArchList = null;
122
123 private JLabel jLabel6SupModList = null;
124
125 private JScrollPane jScrollPaneModules = null;
126
127 private JScrollPane jScrollPane1Arch = null;
128
129 private ICheckBoxList iCheckBoxListModules = null;
130
131 private ICheckBoxList iCheckBoxListArch = null;
132
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;
140
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;
146
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;
155
156 private final int buttonWidth = 99;
157
158 private final int addButtonCol = shortValueCol + 10;
159 private final int removeButtonCol = addButtonCol + buttonWidth + 10;
160 private final int removeAllButtonCol = removeButtonCol + buttonWidth + 10;
161
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;
170
171 HashMap<String, String> libNameGuidMap = new HashMap<String, String>();
172
173
174 /**
175 This method initializes this
176
177 **/
178 private void initialize() {
179
180 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
181
182 }
183
184 /**
185 This method initializes jTextFieldAddClass
186
187 @return javax.swing.JTextField
188 **/
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);
195 }
196 return jTextFieldAddClass;
197 }
198
199 /**
200 This method initializes jComboBoxSelect
201
202 @return javax.swing.JComboBox
203 **/
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);
211 }
212 return jComboBoxSelect;
213 }
214
215 /**
216 This method initializes jScrollPaneTable
217
218 @return javax.swing.JScrollPane
219
220 Used for the Table of Library Classes that are provided by this package
221
222 **/
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());
228 }
229 return jScrollPaneTable;
230 }
231
232 /**
233 This method initializes jTable
234
235 @return javax.swing.JTable
236 **/
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");
251
252 jTable.getColumnModel().getColumn(cnHelpText).setCellEditor(new LongTextEditor());
253
254 jTable.removeColumn(jTable.getColumnModel().getColumn(3));
255 jTable.removeColumn(jTable.getColumnModel().getColumn(3));
256
257 Vector<String> vArch = new Vector<String>();
258 vArch.add("IA32");
259 vArch.add("X64");
260 vArch.add("IPF");
261 vArch.add("EBC");
262 vArch.add("ARM");
263 vArch.add("PPC");
264 jTable.getColumnModel().getColumn(cnSupArch - 2).setCellEditor(new ListEditor(vArch));
265
266 Vector<String> vModule = new Vector<String>();
267 vModule.add("BASE");
268 vModule.add("SEC");
269 vModule.add("PEI_CORE");
270 vModule.add("PEIM");
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");
279
280 jTable.getColumnModel().getColumn(cnSupMod - 2).setCellEditor(new ListEditor(vModule));
281
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);
292
293 jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
294 jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
295 public void valueChanged(ListSelectionEvent e) {
296 if (e.getValueIsAdjusting()){
297 return;
298 }
299 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
300 if (lsm.isSelectionEmpty()) {
301 return;
302 }
303 else{
304 selectedRow = lsm.getMinSelectionIndex();
305 }
306 }
307 });
308
309 jTable.getModel().addTableModelListener(this);
310
311 }
312 return jTable;
313 }
314
315
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){
322
323 String lib = m.getValueAt(row, cnClassName) + "";
324 String hdr = m.getValueAt(row, cnHdrFile) + "";
325 String hlp = m.getValueAt(row, cnHelpText) + "";
326 String name = null;
327 // if (m.getValueAt(row, cnRecInstName) != null) {
328 // name = m.getValueAt(row, cnRecInstName).toString();
329 // }
330 // String ver = null;
331 // if (m.getValueAt(row, cnRecInstVer) != null){
332 // ver = m.getValueAt(row, cnRecInstVer).toString();
333 // }
334 String arch = null;
335 if (m.getValueAt(row, cnSupArch) != null) {
336 arch = m.getValueAt(row, cnSupArch).toString();
337 }
338 String module = null;
339 if (m.getValueAt(row, cnSupMod) != null) {
340 module = m.getValueAt(row, cnSupMod).toString();
341 }
342 String[] rowData = {lib, hdr, hlp, name};
343 if (!dataValidation(rowData)) {
344 return;
345 }
346
347 String guid = null;
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.");
353 // return;
354 // }
355 // }
356
357 String[] sa = new String[7];
358 sfc.getSpdLibClassDeclaration(sa, row);
359 Object cellData = m.getValueAt(row, column);
360 if (cellData == null) {
361 cellData = "";
362 }
363 // if (column == cnRecInstName) {
364 // if (guid == null) {
365 // if (sa[cnRecInstName] == null) {
366 // return;
367 // }
368 // }
369 // else {
370 // if (guid.equals(sa[cnRecInstName])) {
371 // return;
372 // }
373 // }
374 // }
375 if (cellData.equals(sa[column])) {
376 return;
377 }
378 if (cellData.toString().length() == 0 && sa[column] == null) {
379 return;
380 }
381 docConsole.setSaved(false);
382 sfc.updateSpdLibClass(row, lib, hdr, hlp, guid, null, arch, module);
383 }
384 }
385
386 /**
387 This method initializes jButtonAdd
388
389 @return javax.swing.JButton
390 **/
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);
398 }
399 return jButtonAdd;
400 }
401
402 /**
403 This method initializes jButtonRemove
404
405 @return javax.swing.JButton
406 **/
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);
414 }
415 return jButtonRemove;
416 }
417
418 /**
419 This method initializes jButtonRemoveAll
420
421 @return javax.swing.JButton
422 **/
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);
431 }
432 return jButtonRemoveAll;
433 }
434
435 /**
436 This is the default constructor
437 **/
438 public SpdLibClassDecls() {
439 super();
440 initialize();
441 init();
442
443 }
444
445 public SpdLibClassDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){
446 this();
447 sfc = new SpdFileContents(inPsa);
448 init(sfc);
449 }
450
451 public SpdLibClassDecls(OpeningPackageType opt) {
452 this(opt.getXmlSpd());
453 docConsole = opt;
454 }
455 /**
456 This method initializes this
457
458 @return void
459 **/
460 private void init() {
461
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();
470 }
471 }
472 });
473 }
474
475 private void init(SpdFileContents sfc) {
476
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.");
479 }
480 initFrame();
481
482 if (sfc.getSpdLibClassDeclarationCount() == 0) {
483 return ;
484 }
485 //
486 // initialize table using SpdFileContents object
487 //
488 String[][] saa = new String[sfc.getSpdLibClassDeclarationCount()][7];
489 sfc.getSpdLibClassDeclarations(saa);
490 int i = 0;
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]);
495 // }
496
497 model.addRow(saa[i]);
498 i++;
499 }
500
501 }
502
503 private void initFrame() {
504 boolean editable = true;
505 if (sfc.getSpdPkgDefsRdOnly().equals("true")) {
506 editable = false;
507 }
508
509 jButtonAdd.setEnabled(editable);
510 jButtonRemove.setEnabled(editable);
511 jButtonRemoveAll.setEnabled(editable);
512 jTable.setEnabled(editable);
513 }
514
515 private JScrollPane getJContentPane(){
516 if (topScrollPane == null){
517 topScrollPane = new JScrollPane();
518 topScrollPane.setViewportView(getJContentPane1());
519 }
520 return topScrollPane;
521 }
522 /**
523 This method initializes jContentPane
524
525 @return javax.swing.JPanel
526 **/
527 private JPanel getJContentPane1() {
528 if (jContentPane == null) {
529 // Library Class
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");
535
536 // Help Text
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");
542
543 // Header File
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");
549
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);
554
555 jLabel5SupArchList = new JLabel();
556 jLabel5SupArchList.setBounds(new java.awt.Rectangle(labelCol,rowFour,longLabel,20));
557 jLabel5SupArchList.setText("Supported Architectures");
558 jLabel5SupArchList.setEnabled(true);
559
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);
572
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);
579
580 jContentPane.add(jLabel5SupArchList, null);
581 jContentPane.add(jLabel6SupModList, null);
582
583 jContentPane.add(getJScrollPaneModules(), null);
584 jContentPane.add(getJScrollPane1Arch(), null);
585
586 }
587
588 return jContentPane;
589 }
590
591
592 /* (non-Javadoc)
593 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
594 */
595 public void actionPerformed(ActionEvent arg0) {
596
597 if (arg0.getSource() == jButtonAdd) {
598
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;
610 }
611 row[cnSupMod] = vectorToString(iCheckBoxListModules.getAllCheckedItemsString());
612 if (row[cnSupMod].length() == 0){
613 row[cnSupMod] = null;
614 }
615 if (!dataValidation(row)) {
616 return;
617 }
618 //
619 //convert to GUID before storing recommended lib instance.
620 //
621 // getLibInstances(row[cnClassName]);
622 // String recommendGuid = nameToGuid(row[cnRecInstName]);
623 // if (row[cnRecInstName].equals("null")) {
624 // row[cnRecInstName] = null;
625 // }
626 // else{
627 // if (recommendGuid == null) {
628 // JOptionPane.showMessageDialog(frame, "Recommended Instance does not exist.");
629 // return;
630 // }
631 // }
632
633 sfc.genSpdLibClassDeclarations(row[cnClassName], null, row[cnHdrFile], row[cnHelpText], row[cnSupArch], null, null, null, null, row[cnSupMod]);
634 model.addRow(row);
635 jTable.changeSelection(model.getRowCount()-1, 0, false, false);
636 docConsole.setSaved(false);
637 }
638 //
639 // remove selected line
640 //
641 if (arg0.getSource() == jButtonRemove) {
642 if (jTable.isEditing()){
643 jTable.getCellEditor().stopCellEditing();
644 }
645 int rowSelected = selectedRow;
646 if (rowSelected >= 0) {
647 model.removeRow(rowSelected);
648 docConsole.setSaved(false);
649 sfc.removeSpdLibClass(rowSelected);
650 }
651 }
652
653 if (arg0.getSource() == jButtonRemoveAll) {
654 if (model.getRowCount() == 0) {
655 return;
656 }
657 docConsole.setSaved(false);
658 model.setRowCount(0);
659 sfc.removeSpdLibClass();
660 }
661 }
662
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.");
666 return false;
667 }
668 if (!DataValidation.isPathAndFilename(row[cnHdrFile])) {
669 JOptionPane.showMessageDialog(frame, "Include Header does not match the PathAndFilename datatype.");
670 return false;
671 }
672 if (row[cnHelpText].length() == 0) {
673 JOptionPane.showMessageDialog(frame, "Help Text must be entered!");
674 return false;
675 }
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.");
679 // return false;
680 // }
681 //
682 // if (!DataValidation.isVersionDataType(row[cnRecInstVer])) {
683 // JOptionPane.showMessageDialog(frame, "Recommended Instance Version does not match Version datatype.");
684 // return false;
685 // }
686 // }
687 return true;
688 }
689 /**
690 Add contents in list to sfc
691 **/
692 protected void save() {
693
694 }
695
696 /**
697 This method initializes jTextField
698
699 @return javax.swing.JTextField
700 **/
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));
707 }
708 return jTextFieldHdr;
709 }
710
711 /**
712 This method initializes jButtonBrowse
713
714 @return javax.swing.JButton
715 **/
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() {
723
724 /**
725 *
726 */
727 private static final long serialVersionUID = 1L;
728
729 public void actionPerformed(ActionEvent arg0) {
730 //
731 // Select files from current pkg
732 //
733 String dirPrefix = Tools.dirForNewSpd.substring(0, Tools.dirForNewSpd.lastIndexOf(File.separator));
734 JFileChooser chooser = new JFileChooser(dirPrefix);
735 File theFile = null;
736 String headerDest = null;
737
738 chooser.setMultiSelectionEnabled(false);
739 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
740 int retval = chooser.showOpenDialog(frame);
741 if (retval == JFileChooser.APPROVE_OPTION) {
742
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!");
747 return;
748 }
749
750
751 }
752 else {
753 return;
754 }
755
756 headerDest = theFile.getPath();
757 int fileIndex = headerDest.indexOf(System.getProperty("file.separator"), dirPrefix.length());
758 jTextFieldHdr.setText(headerDest.substring(fileIndex + 1).replace('\\', '/'));
759
760 }
761
762 });
763 }
764 return jButtonBrowse;
765 }
766
767 public void componentResized(ComponentEvent arg0) {
768 int intPreferredWidth = 500;
769
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);
776 }
777
778 /**
779 * This method initializes jHelpTextScrollPane
780 *
781 * @return javax.swing.JScrollPane jHelpTextScrollPane
782 */
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());
791 }
792 return jHelpTextScrollPane;
793 }
794
795 /**
796 * This method initializes jTextAreaHelp
797 *
798 * @return javax.swing.JTextArea
799 */
800 private JTextArea getJTextAreaHelp() {
801 if (jTextAreaHelp == null) {
802 jTextAreaHelp = new JTextArea();
803 jTextAreaHelp.setLineWrap(true);
804 jTextAreaHelp.setWrapStyleWord(true);
805 }
806 return jTextAreaHelp;
807 }
808
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());
815 }
816 return jScrollPaneModules;
817 }
818
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>();
824 v.add("BASE");
825 v.add("SEC");
826 v.add("PEI_CORE");
827 v.add("PEIM");
828 v.add("DXE_CORE");
829 v.add("DXE_DRIVER");
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);
837 }
838 return iCheckBoxListModules;
839 }
840
841 private String vectorToString(Vector<String> v) {
842 String s = " ";
843 for (int i = 0; i < v.size(); ++i) {
844 s += v.get(i);
845 s += " ";
846 }
847 return s.trim();
848 }
849
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());
856 }
857 return jScrollPane1Arch;
858 }
859 /**
860 * This method initializes iCheckBoxList
861 *
862 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
863 */
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>();
869 v.add("IA32");
870 v.add("X64");
871 v.add("IPF");
872 v.add("EBC");
873 v.add("ARM");
874 v.add("PPC");
875 iCheckBoxListArch.setAllItems(v);
876 }
877 return iCheckBoxListArch;
878 }
879
880 // private void getLibInstances(String libClass){
881 // libNameGuidMap.clear();
882 // try {
883 // Iterator ismi = GlobalData.vModuleList.iterator();
884 // while (ismi.hasNext()) {
885 // ModuleIdentification mi = (ModuleIdentification) ismi.next();
886 //
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());
891 // }
892 // }
893 // }
894 //
895 // }
896 // catch(Exception e){
897 // JOptionPane.showMessageDialog(frame, "Search Instances Failed.");
898 // }
899 //
900 // }
901
902 // private String nameToGuid(String name) {
903 // String s = null;
904 // if (!libNameGuidMap.containsKey(name)) {
905 // return s;
906 // }
907 //
908 // s = libNameGuidMap.get(name);
909 // return s;
910 // }
911
912 // private String guidToName(String guid){
913 // String s = "";
914 // if (!libNameGuidMap.containsValue(guid)) {
915 // return s;
916 // }
917 // Set<String> key = libNameGuidMap.keySet();
918 // Iterator<String> is = key.iterator();
919 // while(is.hasNext()) {
920 // s = is.next();
921 // if (libNameGuidMap.get(s).equals(guid)) {
922 // break;
923 // }
924 // }
925 // return s;
926 // }
927
928 }
929
930