]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdGuidDecls.java
2357df2b09af997f4694deca97d22a4744ba8fb3
[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.JOptionPane;
23 import javax.swing.JPanel;
24 import javax.swing.JTable;
25 import javax.swing.JTextField;
26 import javax.swing.JLabel;
27 import javax.swing.JScrollPane;
28 import javax.swing.JButton;
29 import javax.swing.JFrame;
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 static JFrame frame;
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());
223 jTable.getColumnModel().getColumn(3).setCellEditor(new LongTextEditor());
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));
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));
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);
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("Remove");
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() {
420 super();
421 initialize();
422 init();
423
424 }
425
426 public SpdGuidDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){
427 this();
428 sfc = new SpdFileContents(inPsa);
429 init(sfc);
430 }
431
432 public SpdGuidDecls(OpeningPackageType opt) {
433 this(opt.getXmlSpd());
434 docConsole = opt;
435 }
436 /**
437 This method initializes this
438
439 @return void
440 **/
441 protected void init() {
442 this.setContentPane(getJContentPane());
443 this.addInternalFrameListener(new InternalFrameAdapter(){
444 public void internalFrameDeactivated(InternalFrameEvent e){
445 if (jTable.isEditing()) {
446 jTable.getCellEditor().stopCellEditing();
447 }
448 }
449 });
450 this.setBounds(new java.awt.Rectangle(0, 0, 500, 370));
451 this.setVisible(true);
452 initFrame();
453 }
454
455 protected void init(SpdFileContents sfc){
456 if (sfc.getSpdGuidDeclarationCount() == 0) {
457 return ;
458 }
459 //
460 // initialize table using SpdFileContents object
461 //
462 saa = new String[sfc.getSpdGuidDeclarationCount()][7];
463 sfc.getSpdGuidDeclarations(saa);
464 int i = 0;
465 while (i < saa.length) {
466 model.addRow(saa[i]);
467 i++;
468 }
469 }
470
471 protected JScrollPane getJContentPane(){
472 if (topScrollPane == null){
473 topScrollPane = new JScrollPane();
474 topScrollPane.setSize(new java.awt.Dimension(617,500));
475 topScrollPane.setPreferredSize(new java.awt.Dimension(498,500));
476 topScrollPane.setViewportView(getJContentPane1());
477 }
478 return topScrollPane;
479 }
480
481 /**
482 This method initializes jContentPane
483
484 @return javax.swing.JPanel
485 **/
486 protected JPanel getJContentPane1() {
487 if (jContentPane == null) {
488
489 jLabelGuidType = new JLabel();
490 jLabelGuidType.setBounds(new java.awt.Rectangle(420,122,103,16));
491 jLabelGuidType.setText("GUID Type List");
492 jLabelGuidType.setEnabled(true);
493 starLabel = new StarLabel();
494 starLabel.setLocation(new Point(jLabelGuidType.getX() - 10, jLabelGuidType.getY()));
495 starLabel.setVisible(true);
496 jLabelSupArch = new JLabel();
497 jLabelSupArch.setBounds(new java.awt.Rectangle(197,122,108,16));
498 jLabelSupArch.setText("Supported Architectures");
499 jLabelSupArch.setEnabled(true);
500 FontMetrics fm = jLabelSupArch.getFontMetrics(jLabelSupArch.getFont());
501 jLabelSupArch.setSize(fm.stringWidth(jLabelSupArch.getText()) + 10, 20);
502 jLabelSupMod = new JLabel();
503 jLabelSupMod.setBounds(new java.awt.Rectangle(14,120,110,16));
504 jLabelSupMod.setText("Supported Module Types");
505 jLabelSupMod.setEnabled(true);
506 fm = jLabelSupMod.getFontMetrics(jLabelSupMod.getFont());
507 jLabelSupMod.setSize(fm.stringWidth(jLabelSupMod.getText()) + 10, 20);
508 jLabelHelp = new JLabel();
509 jLabelHelp.setText("HelpText");
510 jLabelHelp.setSize(new java.awt.Dimension(109,20));
511 jLabelHelp.setLocation(new java.awt.Point(14,85));
512 jLabelCName = new JLabel();
513 jLabelCName.setBounds(new java.awt.Rectangle(14,35,111,20));
514 jLabelCName.setText("C Name");
515 jLabelGuid = new JLabel();
516 jLabelGuid.setBounds(new java.awt.Rectangle(15,60,112,20));
517 jLabelGuid.setText("Guid Value");
518 jLabelName = new JLabel();
519 jLabelName.setBounds(new java.awt.Rectangle(15,10,113,20));
520 jLabelName.setText("Name");
521 jStarLabel1 = new StarLabel();
522 jStarLabel1.setLocation(new java.awt.Point(0, 10));
523 jStarLabel3 = new StarLabel();
524 jStarLabel3.setLocation(new java.awt.Point(0, 35));
525 jStarLabel4 = new StarLabel();
526 jStarLabel4.setLocation(new java.awt.Point(0, 60));
527 jStarLabel2 = new StarLabel();
528 jStarLabel2.setLocation(new java.awt.Point(0, 85));
529 jStarLabel2.setVisible(true);
530 jContentPane = new JPanel();
531 jContentPane.setLayout(null);
532 jContentPane.setPreferredSize(new Dimension(480, 375));
533 jContentPane.add(jStarLabel1, null);
534 jContentPane.add(jStarLabel2, null);
535 jContentPane.add(jStarLabel3, null);
536 jContentPane.add(jStarLabel4, null);
537 jContentPane.add(jLabelCName, null);
538 jContentPane.add(getJTextFieldCName(), null);
539 jContentPane.add(getJTextFieldGuid(), null);
540 jContentPane.add(getJScrollPane(), null);
541 jContentPane.add(getJButtonAdd(), null);
542 jContentPane.add(getJButtonRemove(), null);
543 jContentPane.add(getJButtonClearAll(), null);
544 jContentPane.add(getJButtonCancel(), null);
545 jContentPane.add(getJButtonOk(), null);
546
547 jContentPane.add(getJButtonGen(), null);
548 jContentPane.add(jLabelName, null);
549 jContentPane.add(getJTextFieldName(), null);
550 jContentPane.add(jLabelGuid, null);
551 jContentPane.add(jLabelHelp, null);
552 jContentPane.add(getJTextFieldHelp(), null);
553 jContentPane.add(jLabelSupMod, null);
554 jContentPane.add(jLabelSupArch, null);
555 jContentPane.add(getJScrollPaneArch(), null);
556 jContentPane.add(getJScrollPaneGuid(), null);
557 jContentPane.add(getJScrollPaneModule(), null);
558 jContentPane.add(jLabelGuidType, null);
559 jContentPane.add(starLabel, null);
560 }
561 return jContentPane;
562 }
563
564 /**
565 fill ComboBoxes with pre-defined contents
566 **/
567 protected void initFrame() {
568
569 this.setTitle("GUID Declarations");
570
571 }
572
573 /* (non-Javadoc)
574 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
575 */
576 public void actionPerformed(ActionEvent arg0) {
577
578 if (arg0.getSource() == jButtonOk) {
579 this.save();
580 this.dispose();
581
582 }
583 if (arg0.getSource() == jButtonCancel) {
584 this.dispose();
585 }
586
587 if (arg0.getSource() == jButtonAdd) {
588
589 //ToDo: check before add
590 String[] row = {"", "", "", "", "", "", ""};
591 row[3] = jTextFieldHelp.getText();
592 row[2] = jTextFieldGuid.getText();
593 row[1] = jTextFieldCName.getText();
594 row[0] = jTextFieldName.getText();
595 row[4] = vectorToString(iCheckBoxListArch.getAllCheckedItemsString());
596 if (row[4].length() == 0) {
597 row[4] = null;
598 }
599 row[5] = vectorToString(iCheckBoxListMod.getAllCheckedItemsString());
600 if (row[5].length() == 0) {
601 row[5] = null;
602 }
603 row[6] = vectorToString(iCheckBoxListGuid.getAllCheckedItemsString());
604 if (row[6].length() == 0) {
605 row[6] = null;
606 }
607
608 if (!dataValidation(row)) {
609 return;
610 }
611
612 if (addRow(row) == -1) {
613 return;
614 }
615 model.addRow(row);
616 jTable.changeSelection(model.getRowCount()-1, 0, false, false);
617
618 }
619 //
620 // remove selected line
621 //
622 if (arg0.getSource() == jButtonRemove) {
623 if (jTable.isEditing()){
624 jTable.getCellEditor().stopCellEditing();
625 }
626 int rowSelected = selectedRow;
627 if (rowSelected >= 0) {
628 model.removeRow(rowSelected);
629 removeRow(rowSelected);
630 }
631 }
632
633 if (arg0.getSource() == jButtonClearAll) {
634 if (model.getRowCount() == 0) {
635 return;
636 }
637 model.setRowCount(0);
638 clearAllRow();
639 }
640
641 if (arg0.getSource() == jButtonGen) {
642 jTextFieldGuid.setText(Tools.generateUuidString());
643 }
644
645 if (arg0.getActionCommand().equals("GenGuidValue")) {
646 jTextFieldGuid.setText(guidDialog.getGuid());
647 }
648
649 }
650
651 protected boolean dataValidation(String[] row){
652 if (!DataValidation.isUiNameType(row[0])) {
653 JOptionPane.showMessageDialog(this, "Name must start with an alpha character.");
654 return false;
655 }
656 if (!DataValidation.isGuid(row[2])) {
657 JOptionPane.showMessageDialog(this, "Guid Value must be in registry format, 8-4-4-4-12.");
658 return false;
659 }
660 if (!DataValidation.isC_NameType(row[1])) {
661 JOptionPane.showMessageDialog(this, "C Name does not match C Name datatype.");
662 return false;
663 }
664 if (row[3].length() == 0) {
665 JOptionPane.showMessageDialog(this, "Help Text must be entered!");
666 return false;
667 }
668 return true;
669 }
670
671 protected int addRow(String[] row) {
672 Vector<String> vArch = iCheckBoxListArch.getAllCheckedItemsString();
673 if (vArch.size() == 0) {
674 vArch = null;
675 }
676 Vector<String> vModType = iCheckBoxListMod.getAllCheckedItemsString();
677 if (vModType.size() == 0) {
678 vModType = null;
679 }
680 Vector<String> vguidType = iCheckBoxListGuid.getAllCheckedItemsString();
681 if (vguidType.size() == 0) {
682 vguidType = null;
683 }
684 if (vguidType == null) {
685 JOptionPane.showMessageDialog(this, "You must select at least one GUID type.");
686 return -1;
687 }
688 if (docConsole != null) {
689 docConsole.setSaved(false);
690 }
691 sfc.genSpdGuidDeclarations(row[0], row[1], row[2], row[3], vArch, vModType, vguidType);
692 return 0;
693 }
694
695 protected void removeRow(int i){
696 sfc.removeSpdGuidDeclaration(i);
697 if (docConsole != null) {
698 docConsole.setSaved(false);
699 }
700 }
701
702 protected void clearAllRow(){
703 sfc.removeSpdGuidDeclaration();
704 if (docConsole != null) {
705 docConsole.setSaved(false);
706 }
707 }
708
709 /**
710 Add contents in list to sfc
711 **/
712 protected void save() {
713
714 }
715
716 /**
717 This method initializes jButtonBrowse
718
719 @return javax.swing.JButton
720 **/
721 protected JButton getJButtonGen() {
722 if (jButtonGen == null) {
723 jButtonGen = new JButton();
724 jButtonGen.setBounds(new java.awt.Rectangle(485,58,92,21));
725 jButtonGen.setText("Gen GUID");
726 jButtonGen.setPreferredSize(new java.awt.Dimension(80,20));
727 jButtonGen.addActionListener(this);
728 }
729 return jButtonGen;
730 }
731
732 /**
733 * This method initializes jTextFieldName
734 *
735 * @return javax.swing.JTextField
736 */
737 protected JTextField getJTextFieldName() {
738 if (jTextFieldName == null) {
739 jTextFieldName = new JTextField();
740 jTextFieldName.setBounds(new java.awt.Rectangle(138,10,337,20));
741 jTextFieldName.setPreferredSize(new java.awt.Dimension(335,20));
742 }
743 return jTextFieldName;
744 }
745
746 /**
747 * This method initializes jTextFieldCName
748 *
749 * @return javax.swing.JTextField
750 */
751 protected JTextField getJTextFieldCName() {
752 if (jTextFieldCName == null) {
753 jTextFieldCName = new JTextField();
754 jTextFieldCName.setBounds(new java.awt.Rectangle(137,35,337,20));
755 jTextFieldCName.setPreferredSize(new java.awt.Dimension(335,20));
756 }
757 return jTextFieldCName;
758 }
759
760 public void componentResized(ComponentEvent arg0) {
761 int intPreferredWidth = 500;
762
763 Tools.resizeComponentWidth(this.jTextFieldName, this.getWidth(), intPreferredWidth);
764
765 Tools.resizeComponentWidth(this.jTextFieldCName, this.getWidth(), intPreferredWidth);
766 Tools.resizeComponentWidth(this.jTextFieldHelp, this.getWidth(), intPreferredWidth);
767 Tools.resizeComponentWidth(this.jScrollPane, this.getWidth(), intPreferredWidth);
768 Tools.relocateComponentX(this.jButtonGen, this.getWidth(), this.getPreferredSize().width, 40);
769
770 }
771
772 /**
773 * This method initializes jTextField
774 *
775 * @return javax.swing.JTextField
776 */
777 private JTextField getJTextFieldHelp() {
778 if (jTextFieldHelp == null) {
779 jTextFieldHelp = new JTextField();
780 jTextFieldHelp.setBounds(new java.awt.Rectangle(136,85,337,20));
781 jTextFieldHelp.setPreferredSize(new Dimension(335, 20));
782 }
783 return jTextFieldHelp;
784 }
785
786 private JScrollPane getJScrollPaneArch() {
787 if (jScrollPaneArch == null) {
788 jScrollPaneArch = new JScrollPane();
789 jScrollPaneArch.setBounds(new java.awt.Rectangle(197,142,188,74));
790 jScrollPaneArch.setPreferredSize(new java.awt.Dimension(188, 74));
791 jScrollPaneArch.setViewportView(getICheckBoxListArch());
792 }
793 return jScrollPaneArch;
794 }
795 /**
796 * This method initializes iCheckBoxList
797 *
798 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
799 */
800 private ICheckBoxList getICheckBoxListArch() {
801 if (iCheckBoxListArch == null) {
802 iCheckBoxListArch = new ICheckBoxList();
803 iCheckBoxListArch.setBounds(new java.awt.Rectangle(197,142,188,74));
804 Vector<String> v = new Vector<String>();
805 v.add("IA32");
806 v.add("X64");
807 v.add("IPF");
808 v.add("EBC");
809 v.add("ARM");
810 v.add("PPC");
811 iCheckBoxListArch.setAllItems(v);
812 }
813 return iCheckBoxListArch;
814 }
815
816 protected JScrollPane getJScrollPaneGuid() {
817 if (jScrollPaneGuid== null) {
818 jScrollPaneGuid = new JScrollPane();
819 jScrollPaneGuid.setPreferredSize(new java.awt.Dimension(190,74));
820 jScrollPaneGuid.setLocation(new java.awt.Point(400,142));
821 jScrollPaneGuid.setSize(new java.awt.Dimension(260,74));
822 jScrollPaneGuid.setViewportView(getICheckBoxListGuid());
823 }
824 return jScrollPaneGuid;
825 }
826 /**
827 * This method initializes iCheckBoxList1
828 *
829 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
830 */
831 private ICheckBoxList getICheckBoxListGuid() {
832 if (iCheckBoxListGuid == null) {
833 iCheckBoxListGuid = new ICheckBoxList();
834 iCheckBoxListGuid.setBounds(new java.awt.Rectangle(400,142,177,74));
835 Vector<String> v = new Vector<String>();
836 v.add("DATA_HUB_RECORD");
837 v.add("EFI_EVENT");
838 v.add("EFI_SYSTEM_CONFIGURATION_TABLE");
839 v.add("EFI_VARIABLE");
840 v.add("GUID");
841 v.add("HII_PACKAGE_LIST");
842 v.add("HOB");
843 v.add("TOKEN_SPACE_GUID");
844
845 iCheckBoxListGuid.setAllItems(v);
846 }
847 return iCheckBoxListGuid;
848 }
849
850 private JScrollPane getJScrollPaneModule() {
851 if (jScrollPaneModule == null) {
852 jScrollPaneModule = new JScrollPane();
853 jScrollPaneModule.setBounds(new java.awt.Rectangle(14,142,170,74));
854 jScrollPaneModule.setPreferredSize(new java.awt.Dimension(170, 74));
855 jScrollPaneModule.setViewportView(getICheckBoxListMod());
856 }
857 return jScrollPaneModule;
858 }
859 /**
860 * This method initializes iCheckBoxList2
861 *
862 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
863 */
864 private ICheckBoxList getICheckBoxListMod() {
865 if (iCheckBoxListMod == null) {
866 iCheckBoxListMod = new ICheckBoxList();
867 iCheckBoxListMod.setBounds(new java.awt.Rectangle(14,142,170,74));
868 Vector<String> v = new Vector<String>();
869 v.add("BASE");
870 v.add("SEC");
871 v.add("PEI_CORE");
872 v.add("PEIM");
873 v.add("DXE_CORE");
874 v.add("DXE_DRIVER");
875 v.add("DXE_RUNTIME_DRIVER");
876 v.add("DXE_SAL_DRIVER");
877 v.add("DXE_SMM_DRIVER");
878 v.add("UEFI_DRIVER");
879 v.add("UEFI_APPLICATION");
880 v.add("USER_DEFINED");
881 iCheckBoxListMod.setAllItems(v);
882 }
883 return iCheckBoxListMod;
884 }
885
886 public static void main(String[] args){
887 new SpdGuidDecls().setVisible(true);
888 }
889
890 protected DefaultTableModel getModel() {
891 return model;
892 }
893
894 protected void setModel(DefaultTableModel model) {
895 this.model = model;
896 }
897
898 protected String vectorToString(Vector<String> v) {
899 String s = " ";
900 for (int i = 0; i < v.size(); ++i) {
901 s += v.get(i);
902 s += " ";
903 }
904 return s.trim();
905 }
906
907 protected Vector<String> stringToVector(String s){
908 if (s == null) {
909 return null;
910 }
911 String[] sArray = s.split(" ");
912 Vector<String> v = new Vector<String>();
913 for (int i = 0; i < sArray.length; ++i) {
914 v.add(sArray[i]);
915 }
916 return v;
917 }
918
919 protected JLabel getJLabelGuidType() {
920 return jLabelGuidType;
921 }
922 }
923
924