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