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