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