]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdGuidDecls.java
Make opening dialogs re-gain focus when user switch back to main UI from other window...
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / packaging / ui / SpdGuidDecls.java
1 /** @file
2 Java class SpdGuidDecls 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.Point;
18 import java.awt.event.ActionEvent;
19 import java.awt.event.ComponentEvent;
20 import java.util.Vector;
21
22 import javax.swing.JFrame;
23 import javax.swing.JOptionPane;
24 import javax.swing.JPanel;
25 import javax.swing.JTable;
26 import javax.swing.JTextField;
27 import javax.swing.JLabel;
28 import javax.swing.JScrollPane;
29 import javax.swing.JButton;
30 import javax.swing.ListSelectionModel;
31 import javax.swing.event.InternalFrameAdapter;
32 import javax.swing.event.InternalFrameEvent;
33 import javax.swing.event.ListSelectionEvent;
34 import javax.swing.event.ListSelectionListener;
35 import javax.swing.event.TableModelEvent;
36 import javax.swing.event.TableModelListener;
37 import javax.swing.table.DefaultTableModel;
38 import javax.swing.table.TableColumn;
39 import javax.swing.table.TableModel;
40
41 import org.tianocore.PackageSurfaceAreaDocument;
42 import org.tianocore.frameworkwizard.common.DataValidation;
43 import org.tianocore.frameworkwizard.common.Tools;
44 import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;
45 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
46 import org.tianocore.frameworkwizard.common.ui.StarLabel;
47 import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
48 import org.tianocore.frameworkwizard.platform.ui.ListEditor;
49 import org.tianocore.frameworkwizard.platform.ui.LongTextEditor;
50
51 /**
52 GUI for create library definition elements of spd file.
53
54 @since PackageEditor 1.0
55 **/
56 public class SpdGuidDecls extends IInternalFrame implements TableModelListener{
57 /**
58 *
59 */
60 private static final long serialVersionUID = 1L;
61
62 private JFrame topFrame = null;
63
64 private SpdFileContents sfc = null;
65
66 private OpeningPackageType docConsole = null;
67
68 private JTable jTable = null;
69
70 private DefaultTableModel model = null;
71
72 private JPanel jContentPane = null;
73
74 private JTextField jTextFieldGuid = null;
75
76 private JScrollPane jScrollPane = null;
77
78 private JButton jButtonAdd = null;
79
80 private JButton jButtonRemove = null;
81
82 private JButton jButtonClearAll = null;
83
84 private JButton jButtonCancel = null;
85
86 private JButton jButtonOk = null;
87
88 private JButton jButtonGen = null;
89
90 private StarLabel jStarLabel1 = null;
91
92 private StarLabel jStarLabel2 = null;
93
94 private StarLabel jStarLabel3 = null;
95
96 private StarLabel jStarLabel4 = null;
97
98 protected int selectedRow = -1;
99
100 private JLabel jLabelName = null;
101
102 private JScrollPane jScrollPaneModule = null;
103
104 private JTextField jTextFieldName = null;
105
106 private JScrollPane jScrollPaneArch = null;
107
108 private JScrollPane jScrollPaneGuid = null;
109
110 private JLabel jLabelGuid = null;
111
112 private JScrollPane topScrollPane = null; // @jve:decl-index=0:visual-constraint="10,213"
113
114 private JLabel jLabelCName = null;
115
116 private GenGuidDialog guidDialog = null;
117
118 private JTextField jTextFieldCName = null;
119
120 private JLabel jLabelHelp = null;
121
122 private JTextField jTextFieldHelp = null;
123
124 private JLabel jLabelSupMod = null;
125
126 private JLabel jLabelSupArch = null;
127
128 private ICheckBoxList iCheckBoxListArch = null;
129
130 private ICheckBoxList iCheckBoxListGuid = null;
131
132 private ICheckBoxList iCheckBoxListMod = null;
133
134 private JLabel jLabelGuidType = null;
135
136 protected String[][] saa = null;
137
138 protected StarLabel starLabel = null;
139
140 private final int guidNameMinWidth = 200;
141 private final int guidCNameMinWidth = 200;
142 private final int guidValueMinWidth = 300;
143 private final int helpTextMinWidth = 300;
144 private final int supArchMinWidth = 200;
145 private final int supModMinWidth = 200;
146 private final int guidTypeMinWidth = 200;
147
148
149 /**
150 This method initializes this
151
152 **/
153 protected void initialize() {
154
155 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
156
157 }
158
159 /**
160 This method initializes jTextFieldGuid
161
162 @return javax.swing.JTextField
163 **/
164 protected JTextField getJTextFieldGuid() {
165 if (jTextFieldGuid == null) {
166 jTextFieldGuid = new JTextField();
167 jTextFieldGuid.setBounds(new java.awt.Rectangle(137,60,336,20));
168 jTextFieldGuid.setPreferredSize(new java.awt.Dimension(200,20));
169
170 }
171 return jTextFieldGuid;
172 }
173
174 /**
175 This method initializes jScrollPane
176
177 @return javax.swing.JScrollPane
178 **/
179 protected JScrollPane getJScrollPane() {
180 if (jScrollPane == null) {
181 jScrollPane = new JScrollPane();
182 jScrollPane.setBounds(new java.awt.Rectangle(5,256,472,292));
183 jScrollPane.setViewportView(getJTable());
184 }
185 return jScrollPane;
186 }
187
188 /**
189 This method initializes jTable
190
191 @return javax.swing.JTable
192 **/
193 protected JTable getJTable() {
194 if (jTable == null) {
195 model = new DefaultTableModel();
196 jTable = new JTable(model);
197 jTable.setRowHeight(20);
198 jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
199 model.addColumn("Name");
200 model.addColumn("The C Name");
201 model.addColumn("GUID Value");
202 model.addColumn("Help Text");
203 model.addColumn("Supported Architectures");
204 model.addColumn("Supported Module Types");
205 model.addColumn("GuidTypes");
206
207 TableColumn column = jTable.getColumnModel().getColumn(0);
208 column.setMinWidth(this.guidNameMinWidth);
209 column = jTable.getColumnModel().getColumn(1);
210 column.setMinWidth(this.guidCNameMinWidth);
211 column = jTable.getColumnModel().getColumn(2);
212 column.setMinWidth(this.guidValueMinWidth);
213 column = jTable.getColumnModel().getColumn(3);
214 column.setMinWidth(this.helpTextMinWidth);
215 column = jTable.getColumnModel().getColumn(4);
216 column.setMinWidth(this.supArchMinWidth);
217 column = jTable.getColumnModel().getColumn(5);
218 column.setMinWidth(this.supModMinWidth);
219 column = jTable.getColumnModel().getColumn(6);
220 column.setMinWidth(this.guidTypeMinWidth);
221
222 jTable.getColumnModel().getColumn(2).setCellEditor(new GuidEditor(topFrame));
223 jTable.getColumnModel().getColumn(3).setCellEditor(new LongTextEditor(topFrame));
224
225 Vector<String> vArch = new Vector<String>();
226 vArch.add("IA32");
227 vArch.add("X64");
228 vArch.add("IPF");
229 vArch.add("EBC");
230 vArch.add("ARM");
231 vArch.add("PPC");
232 jTable.getColumnModel().getColumn(4).setCellEditor(new ListEditor(vArch, topFrame));
233
234 Vector<String> vModule = new Vector<String>();
235 vModule.add("BASE");
236 vModule.add("SEC");
237 vModule.add("PEI_CORE");
238 vModule.add("PEIM");
239 vModule.add("DXE_CORE");
240 vModule.add("DXE_DRIVER");
241 vModule.add("DXE_RUNTIME_DRIVER");
242 vModule.add("DXE_SAL_DRIVER");
243 vModule.add("DXE_SMM_DRIVER");
244 vModule.add("UEFI_DRIVER");
245 vModule.add("UEFI_APPLICATION");
246 vModule.add("USER_DEFINED");
247 jTable.getColumnModel().getColumn(5).setCellEditor(new ListEditor(vModule, topFrame));
248
249 Vector<String> vGuid = new Vector<String>();
250 vGuid.add("DATA_HUB_RECORD");
251 vGuid.add("EFI_EVENT");
252 vGuid.add("EFI_SYSTEM_CONFIGURATION_TABLE");
253 vGuid.add("EFI_VARIABLE");
254 vGuid.add("GUID");
255 vGuid.add("HII_PACKAGE_LIST");
256 vGuid.add("HOB");
257 vGuid.add("TOKEN_SPACE_GUID");
258 ListEditor le = new ListEditor(vGuid, topFrame);
259 le.setCanNotBeEmpty(true);
260 jTable.getColumnModel().getColumn(6).setCellEditor(le);
261
262 jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
263 jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
264 public void valueChanged(ListSelectionEvent e) {
265 if (e.getValueIsAdjusting()){
266 return;
267 }
268 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
269 if (lsm.isSelectionEmpty()) {
270 return;
271 }
272 else{
273 selectedRow = lsm.getMinSelectionIndex();
274
275 }
276 }
277 });
278
279 jTable.getModel().addTableModelListener(this);
280 }
281 return jTable;
282 }
283
284
285 public void tableChanged(TableModelEvent arg0) {
286 // TODO Auto-generated method stub
287 int row = arg0.getFirstRow();
288 int column = arg0.getColumn();
289 TableModel m = (TableModel)arg0.getSource();
290 if (arg0.getType() == TableModelEvent.UPDATE){
291
292 updateRow(row, column, m);
293 }
294 }
295
296 protected void updateRow(int row, int column, TableModel m){
297 String[] sa = new String[7];
298 sfc.getSpdGuidDeclaration(sa, row);
299 Object cellData = m.getValueAt(row, column);
300 if (cellData == null) {
301 cellData = "";
302 }
303 if (cellData.equals(sa[column])) {
304 return;
305 }
306
307 if (cellData.toString().length() == 0 && sa[column] == null) {
308 return;
309 }
310
311 String name = m.getValueAt(row, 0) + "";
312 String cName = m.getValueAt(row, 1) + "";
313 String guid = m.getValueAt(row, 2) + "";
314 String help = m.getValueAt(row, 3) + "";
315 String archList = null;
316 if (m.getValueAt(row, 4) != null){
317 archList = m.getValueAt(row, 4).toString();
318 }
319 String modTypeList = null;
320 if (m.getValueAt(row, 5) != null) {
321 modTypeList = m.getValueAt(row, 5).toString();
322 }
323 String guidTypeList = null;
324 if (m.getValueAt(row, 6) != null){
325 guidTypeList = m.getValueAt(row, 6).toString();
326 }
327 String[] rowData = {name, cName, guid, help};
328 if (!dataValidation(rowData)){
329 return;
330 }
331 if (docConsole != null) {
332 docConsole.setSaved(false);
333 }
334 sfc.updateSpdGuidDecl(row, name, cName, guid, help, archList, modTypeList, guidTypeList);
335 }
336 /**
337 This method initializes jButtonAdd
338
339 @return javax.swing.JButton
340 **/
341 protected JButton getJButtonAdd() {
342 if (jButtonAdd == null) {
343 jButtonAdd = new JButton();
344 jButtonAdd.setBounds(new java.awt.Rectangle(167,227,90,20));
345 jButtonAdd.setText("Add");
346 jButtonAdd.addActionListener(this);
347 }
348 return jButtonAdd;
349 }
350
351 /**
352 This method initializes jButtonRemove
353
354 @return javax.swing.JButton
355 **/
356 protected JButton getJButtonRemove() {
357 if (jButtonRemove == null) {
358 jButtonRemove = new JButton();
359 jButtonRemove.setBounds(new java.awt.Rectangle(270,227,90,20));
360 jButtonRemove.setText("Delete");
361 jButtonRemove.addActionListener(this);
362 }
363 return jButtonRemove;
364 }
365
366 /**
367 This method initializes jButtonRemoveAll
368
369 @return javax.swing.JButton
370 **/
371 protected JButton getJButtonClearAll() {
372 if (jButtonClearAll == null) {
373 jButtonClearAll = new JButton();
374 jButtonClearAll.setBounds(new java.awt.Rectangle(380,227,90,20));
375 jButtonClearAll.setText("Clear All");
376 jButtonClearAll.addActionListener(this);
377 }
378 return jButtonClearAll;
379 }
380
381 /**
382 This method initializes jButtonCancel
383
384 @return javax.swing.JButton
385 **/
386 protected JButton getJButtonCancel() {
387 if (jButtonCancel == null) {
388 jButtonCancel = new JButton();
389 jButtonCancel.setPreferredSize(new java.awt.Dimension(90, 20));
390 jButtonCancel.setLocation(new java.awt.Point(390, 305));
391 jButtonCancel.setText("Cancel");
392 jButtonCancel.setSize(new java.awt.Dimension(90, 20));
393 jButtonCancel.setVisible(false);
394 jButtonCancel.addActionListener(this);
395 }
396 return jButtonCancel;
397 }
398
399 /**
400 This method initializes jButton
401
402 @return javax.swing.JButton
403 **/
404 protected JButton getJButtonOk() {
405 if (jButtonOk == null) {
406 jButtonOk = new JButton();
407 jButtonOk.setSize(new java.awt.Dimension(90, 20));
408 jButtonOk.setText("OK");
409 jButtonOk.setLocation(new java.awt.Point(290, 305));
410 jButtonOk.setVisible(false);
411 jButtonOk.addActionListener(this);
412 }
413 return jButtonOk;
414 }
415
416 /**
417 This is the default constructor
418 **/
419 public SpdGuidDecls(JFrame frame) {
420 super();
421 topFrame = frame;
422 initialize();
423 init();
424
425 }
426
427 public SpdGuidDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa, JFrame frame){
428 this(frame);
429 sfc = new SpdFileContents(inPsa);
430 init(sfc);
431 }
432
433 public SpdGuidDecls(OpeningPackageType opt, JFrame frame) {
434 this(opt.getXmlSpd(), frame);
435 docConsole = opt;
436 if (sfc.getSpdPkgDefsRdOnly().equals("true")) {
437 JOptionPane.showMessageDialog(this, "This is a read-only package. You will not be able to edit contents in table.");
438 }
439 initFrame();
440 }
441 /**
442 This method initializes this
443
444 @return void
445 **/
446 protected void init() {
447 this.setContentPane(getJContentPane());
448 this.addInternalFrameListener(new InternalFrameAdapter(){
449 public void internalFrameDeactivated(InternalFrameEvent e){
450 if (jTable.isEditing()) {
451 jTable.getCellEditor().stopCellEditing();
452 }
453 }
454 });
455 this.setBounds(new java.awt.Rectangle(0, 0, 500, 370));
456 this.setVisible(true);
457 }
458
459 protected void init(SpdFileContents sfc){
460 if (sfc.getSpdGuidDeclarationCount() == 0) {
461 return ;
462 }
463 //
464 // initialize table using SpdFileContents object
465 //
466 saa = new String[sfc.getSpdGuidDeclarationCount()][7];
467 sfc.getSpdGuidDeclarations(saa);
468 int i = 0;
469 while (i < saa.length) {
470 model.addRow(saa[i]);
471 i++;
472 }
473
474 }
475
476 protected JScrollPane getJContentPane(){
477 if (topScrollPane == null){
478 topScrollPane = new JScrollPane();
479 topScrollPane.setSize(new java.awt.Dimension(617,500));
480 topScrollPane.setPreferredSize(new java.awt.Dimension(498,500));
481 topScrollPane.setViewportView(getJContentPane1());
482 }
483 return topScrollPane;
484 }
485
486 /**
487 This method initializes jContentPane
488
489 @return javax.swing.JPanel
490 **/
491 protected JPanel getJContentPane1() {
492 if (jContentPane == null) {
493
494 jLabelGuidType = new JLabel();
495 jLabelGuidType.setBounds(new java.awt.Rectangle(420,122,103,16));
496 jLabelGuidType.setText("GUID Type List");
497 jLabelGuidType.setEnabled(true);
498 starLabel = new StarLabel();
499 starLabel.setLocation(new Point(jLabelGuidType.getX() - 10, jLabelGuidType.getY()));
500 starLabel.setVisible(true);
501 jLabelSupArch = new JLabel();
502 jLabelSupArch.setBounds(new java.awt.Rectangle(197,122,108,16));
503 jLabelSupArch.setText("Supported Architectures");
504 jLabelSupArch.setEnabled(true);
505 FontMetrics fm = jLabelSupArch.getFontMetrics(jLabelSupArch.getFont());
506 jLabelSupArch.setSize(fm.stringWidth(jLabelSupArch.getText()) + 10, 20);
507 jLabelSupMod = new JLabel();
508 jLabelSupMod.setBounds(new java.awt.Rectangle(14,120,110,16));
509 jLabelSupMod.setText("Supported Module Types");
510 jLabelSupMod.setEnabled(true);
511 fm = jLabelSupMod.getFontMetrics(jLabelSupMod.getFont());
512 jLabelSupMod.setSize(fm.stringWidth(jLabelSupMod.getText()) + 10, 20);
513 jLabelHelp = new JLabel();
514 jLabelHelp.setText("HelpText");
515 jLabelHelp.setSize(new java.awt.Dimension(109,20));
516 jLabelHelp.setLocation(new java.awt.Point(14,85));
517 jLabelCName = new JLabel();
518 jLabelCName.setBounds(new java.awt.Rectangle(14,35,111,20));
519 jLabelCName.setText("C Name");
520 jLabelGuid = new JLabel();
521 jLabelGuid.setBounds(new java.awt.Rectangle(15,60,112,20));
522 jLabelGuid.setText("Guid Value");
523 jLabelName = new JLabel();
524 jLabelName.setBounds(new java.awt.Rectangle(15,10,113,20));
525 jLabelName.setText("Name");
526 jStarLabel1 = new StarLabel();
527 jStarLabel1.setLocation(new java.awt.Point(0, 10));
528 jStarLabel3 = new StarLabel();
529 jStarLabel3.setLocation(new java.awt.Point(0, 35));
530 jStarLabel4 = new StarLabel();
531 jStarLabel4.setLocation(new java.awt.Point(0, 60));
532 jStarLabel2 = new StarLabel();
533 jStarLabel2.setLocation(new java.awt.Point(0, 85));
534 jStarLabel2.setVisible(true);
535 jContentPane = new JPanel();
536 jContentPane.setLayout(null);
537 jContentPane.setPreferredSize(new Dimension(480, 375));
538 jContentPane.add(jStarLabel1, null);
539 jContentPane.add(jStarLabel2, null);
540 jContentPane.add(jStarLabel3, null);
541 jContentPane.add(jStarLabel4, null);
542 jContentPane.add(jLabelCName, null);
543 jContentPane.add(getJTextFieldCName(), null);
544 jContentPane.add(getJTextFieldGuid(), null);
545 jContentPane.add(getJScrollPane(), null);
546 jContentPane.add(getJButtonAdd(), null);
547 jContentPane.add(getJButtonRemove(), null);
548 jContentPane.add(getJButtonClearAll(), null);
549 jContentPane.add(getJButtonCancel(), null);
550 jContentPane.add(getJButtonOk(), null);
551
552 jContentPane.add(getJButtonGen(), null);
553 jContentPane.add(jLabelName, null);
554 jContentPane.add(getJTextFieldName(), null);
555 jContentPane.add(jLabelGuid, null);
556 jContentPane.add(jLabelHelp, null);
557 jContentPane.add(getJTextFieldHelp(), null);
558 jContentPane.add(jLabelSupMod, null);
559 jContentPane.add(jLabelSupArch, null);
560 jContentPane.add(getJScrollPaneArch(), null);
561 jContentPane.add(getJScrollPaneGuid(), null);
562 jContentPane.add(getJScrollPaneModule(), null);
563 jContentPane.add(jLabelGuidType, null);
564 jContentPane.add(starLabel, null);
565 }
566 return jContentPane;
567 }
568
569 /**
570 fill ComboBoxes with pre-defined contents
571 **/
572 protected void initFrame() {
573
574 this.setTitle("GUID Declarations");
575
576 boolean editable = true;
577 if (getSfc().getSpdPkgDefsRdOnly().equals("true")) {
578 editable = false;
579 }
580
581 jButtonAdd.setEnabled(editable);
582 jButtonRemove.setEnabled(editable);
583 jButtonClearAll.setEnabled(editable);
584 jTable.setEnabled(editable);
585 }
586
587 /* (non-Javadoc)
588 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
589 */
590 public void actionPerformed(ActionEvent arg0) {
591
592 if (arg0.getSource() == jButtonOk) {
593 this.save();
594 this.dispose();
595
596 }
597 if (arg0.getSource() == jButtonCancel) {
598 this.dispose();
599 }
600
601 if (arg0.getSource() == jButtonAdd) {
602
603 //ToDo: check before add
604 String[] row = {"", "", "", "", "", "", ""};
605 row[3] = jTextFieldHelp.getText();
606 row[2] = jTextFieldGuid.getText();
607 row[1] = jTextFieldCName.getText();
608 row[0] = jTextFieldName.getText();
609 row[4] = vectorToString(iCheckBoxListArch.getAllCheckedItemsString());
610 if (row[4].length() == 0) {
611 row[4] = null;
612 }
613 row[5] = vectorToString(iCheckBoxListMod.getAllCheckedItemsString());
614 if (row[5].length() == 0) {
615 row[5] = null;
616 }
617 row[6] = vectorToString(iCheckBoxListGuid.getAllCheckedItemsString());
618 if (row[6].length() == 0) {
619 row[6] = null;
620 }
621
622 if (!dataValidation(row)) {
623 return;
624 }
625
626 if (addRow(row) == -1) {
627 return;
628 }
629 model.addRow(row);
630 jTable.changeSelection(model.getRowCount()-1, 0, false, false);
631
632 }
633 //
634 // remove selected line
635 //
636 if (arg0.getSource() == jButtonRemove) {
637 if (jTable.isEditing()){
638 jTable.getCellEditor().stopCellEditing();
639 }
640 int rowSelected = selectedRow;
641 if (rowSelected >= 0) {
642 model.removeRow(rowSelected);
643 removeRow(rowSelected);
644 }
645 }
646
647 if (arg0.getSource() == jButtonClearAll) {
648 if (model.getRowCount() == 0) {
649 return;
650 }
651 model.setRowCount(0);
652 clearAllRow();
653 }
654
655 if (arg0.getSource() == jButtonGen) {
656 jTextFieldGuid.setText(Tools.generateUuidString());
657 }
658
659 if (arg0.getActionCommand().equals("GenGuidValue")) {
660 jTextFieldGuid.setText(guidDialog.getGuid());
661 }
662
663 }
664
665 protected boolean dataValidation(String[] row){
666 if (!DataValidation.isUiNameType(row[0])) {
667 JOptionPane.showMessageDialog(this, "Name must start with an alpha character.");
668 return false;
669 }
670 if (!DataValidation.isGuid(row[2])) {
671 JOptionPane.showMessageDialog(this, "Guid Value must be in registry format, 8-4-4-4-12.");
672 return false;
673 }
674 if (!DataValidation.isC_NameType(row[1])) {
675 JOptionPane.showMessageDialog(this, "C Name does not match C Name datatype.");
676 return false;
677 }
678 if (row[3].length() == 0) {
679 JOptionPane.showMessageDialog(this, "Help Text must be entered!");
680 return false;
681 }
682 return true;
683 }
684
685 protected int addRow(String[] row) {
686 Vector<String> vArch = iCheckBoxListArch.getAllCheckedItemsString();
687 if (vArch.size() == 0) {
688 vArch = null;
689 }
690 Vector<String> vModType = iCheckBoxListMod.getAllCheckedItemsString();
691 if (vModType.size() == 0) {
692 vModType = null;
693 }
694 Vector<String> vguidType = iCheckBoxListGuid.getAllCheckedItemsString();
695 if (vguidType.size() == 0) {
696 vguidType = null;
697 }
698 if (vguidType == null) {
699 JOptionPane.showMessageDialog(this, "You must select at least one GUID type.");
700 return -1;
701 }
702 if (docConsole != null) {
703 docConsole.setSaved(false);
704 }
705 sfc.genSpdGuidDeclarations(row[0], row[1], row[2], row[3], vArch, vModType, vguidType);
706 return 0;
707 }
708
709 protected void removeRow(int i){
710 sfc.removeSpdGuidDeclaration(i);
711 if (docConsole != null) {
712 docConsole.setSaved(false);
713 }
714 }
715
716 protected void clearAllRow(){
717 sfc.removeSpdGuidDeclaration();
718 if (docConsole != null) {
719 docConsole.setSaved(false);
720 }
721 }
722
723 /**
724 Add contents in list to sfc
725 **/
726 protected void save() {
727
728 }
729
730 /**
731 This method initializes jButtonBrowse
732
733 @return javax.swing.JButton
734 **/
735 protected JButton getJButtonGen() {
736 if (jButtonGen == null) {
737 jButtonGen = new JButton();
738 jButtonGen.setBounds(new java.awt.Rectangle(485,58,92,21));
739 jButtonGen.setText("Gen");
740 jButtonGen.setPreferredSize(new java.awt.Dimension(80,20));
741 jButtonGen.addActionListener(this);
742 }
743 return jButtonGen;
744 }
745
746 /**
747 * This method initializes jTextFieldName
748 *
749 * @return javax.swing.JTextField
750 */
751 protected JTextField getJTextFieldName() {
752 if (jTextFieldName == null) {
753 jTextFieldName = new JTextField();
754 jTextFieldName.setBounds(new java.awt.Rectangle(138,10,337,20));
755 jTextFieldName.setPreferredSize(new java.awt.Dimension(335,20));
756 }
757 return jTextFieldName;
758 }
759
760 /**
761 * This method initializes jTextFieldCName
762 *
763 * @return javax.swing.JTextField
764 */
765 protected JTextField getJTextFieldCName() {
766 if (jTextFieldCName == null) {
767 jTextFieldCName = new JTextField();
768 jTextFieldCName.setBounds(new java.awt.Rectangle(137,35,337,20));
769 jTextFieldCName.setPreferredSize(new java.awt.Dimension(335,20));
770 }
771 return jTextFieldCName;
772 }
773
774 public void componentResized(ComponentEvent arg0) {
775 int intPreferredWidth = 500;
776
777 Tools.resizeComponentWidth(this.jTextFieldName, this.getWidth(), intPreferredWidth);
778
779 Tools.resizeComponentWidth(this.jTextFieldCName, this.getWidth(), intPreferredWidth);
780 Tools.resizeComponentWidth(this.jTextFieldHelp, this.getWidth(), intPreferredWidth);
781 Tools.resizeComponentWidth(this.jScrollPane, this.getWidth(), intPreferredWidth);
782 Tools.relocateComponentX(this.jButtonGen, this.getWidth(), this.getPreferredSize().width, 40);
783
784 }
785
786 /**
787 * This method initializes jTextField
788 *
789 * @return javax.swing.JTextField
790 */
791 private JTextField getJTextFieldHelp() {
792 if (jTextFieldHelp == null) {
793 jTextFieldHelp = new JTextField();
794 jTextFieldHelp.setBounds(new java.awt.Rectangle(136,85,337,20));
795 jTextFieldHelp.setPreferredSize(new Dimension(335, 20));
796 }
797 return jTextFieldHelp;
798 }
799
800 private JScrollPane getJScrollPaneArch() {
801 if (jScrollPaneArch == null) {
802 jScrollPaneArch = new JScrollPane();
803 jScrollPaneArch.setBounds(new java.awt.Rectangle(197,142,188,74));
804 jScrollPaneArch.setPreferredSize(new java.awt.Dimension(188, 74));
805 jScrollPaneArch.setViewportView(getICheckBoxListArch());
806 }
807 return jScrollPaneArch;
808 }
809 /**
810 * This method initializes iCheckBoxList
811 *
812 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
813 */
814 private ICheckBoxList getICheckBoxListArch() {
815 if (iCheckBoxListArch == null) {
816 iCheckBoxListArch = new ICheckBoxList();
817 iCheckBoxListArch.setBounds(new java.awt.Rectangle(197,142,188,74));
818 Vector<String> v = new Vector<String>();
819 v.add("IA32");
820 v.add("X64");
821 v.add("IPF");
822 v.add("EBC");
823 v.add("ARM");
824 v.add("PPC");
825 iCheckBoxListArch.setAllItems(v);
826 }
827 return iCheckBoxListArch;
828 }
829
830 protected JScrollPane getJScrollPaneGuid() {
831 if (jScrollPaneGuid== null) {
832 jScrollPaneGuid = new JScrollPane();
833 jScrollPaneGuid.setPreferredSize(new java.awt.Dimension(190,74));
834 jScrollPaneGuid.setLocation(new java.awt.Point(400,142));
835 jScrollPaneGuid.setSize(new java.awt.Dimension(260,74));
836 jScrollPaneGuid.setViewportView(getICheckBoxListGuid());
837 }
838 return jScrollPaneGuid;
839 }
840 /**
841 * This method initializes iCheckBoxList1
842 *
843 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
844 */
845 private ICheckBoxList getICheckBoxListGuid() {
846 if (iCheckBoxListGuid == null) {
847 iCheckBoxListGuid = new ICheckBoxList();
848 iCheckBoxListGuid.setBounds(new java.awt.Rectangle(400,142,177,74));
849 Vector<String> v = new Vector<String>();
850 v.add("DATA_HUB_RECORD");
851 v.add("EFI_EVENT");
852 v.add("EFI_SYSTEM_CONFIGURATION_TABLE");
853 v.add("EFI_VARIABLE");
854 v.add("GUID");
855 v.add("HII_PACKAGE_LIST");
856 v.add("HOB");
857 v.add("TOKEN_SPACE_GUID");
858
859 iCheckBoxListGuid.setAllItems(v);
860 }
861 return iCheckBoxListGuid;
862 }
863
864 private JScrollPane getJScrollPaneModule() {
865 if (jScrollPaneModule == null) {
866 jScrollPaneModule = new JScrollPane();
867 jScrollPaneModule.setBounds(new java.awt.Rectangle(14,142,170,74));
868 jScrollPaneModule.setPreferredSize(new java.awt.Dimension(170, 74));
869 jScrollPaneModule.setViewportView(getICheckBoxListMod());
870 }
871 return jScrollPaneModule;
872 }
873 /**
874 * This method initializes iCheckBoxList2
875 *
876 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
877 */
878 private ICheckBoxList getICheckBoxListMod() {
879 if (iCheckBoxListMod == null) {
880 iCheckBoxListMod = new ICheckBoxList();
881 iCheckBoxListMod.setBounds(new java.awt.Rectangle(14,142,170,74));
882 Vector<String> v = new Vector<String>();
883 v.add("BASE");
884 v.add("SEC");
885 v.add("PEI_CORE");
886 v.add("PEIM");
887 v.add("DXE_CORE");
888 v.add("DXE_DRIVER");
889 v.add("DXE_RUNTIME_DRIVER");
890 v.add("DXE_SAL_DRIVER");
891 v.add("DXE_SMM_DRIVER");
892 v.add("UEFI_DRIVER");
893 v.add("UEFI_APPLICATION");
894 v.add("USER_DEFINED");
895 iCheckBoxListMod.setAllItems(v);
896 }
897 return iCheckBoxListMod;
898 }
899
900 protected DefaultTableModel getModel() {
901 return model;
902 }
903
904 protected void setModel(DefaultTableModel model) {
905 this.model = model;
906 }
907
908 protected String vectorToString(Vector<String> v) {
909 String s = " ";
910 for (int i = 0; i < v.size(); ++i) {
911 s += v.get(i);
912 s += " ";
913 }
914 return s.trim();
915 }
916
917 protected Vector<String> stringToVector(String s){
918 if (s == null) {
919 return null;
920 }
921 String[] sArray = s.split(" ");
922 Vector<String> v = new Vector<String>();
923 for (int i = 0; i < sArray.length; ++i) {
924 v.add(sArray[i]);
925 }
926 return v;
927 }
928
929 protected JLabel getJLabelGuidType() {
930 return jLabelGuidType;
931 }
932
933 /**
934 * @return Returns the sfc.
935 */
936 protected SpdFileContents getSfc() {
937 return sfc;
938 }
939 }
940
941