f3e7011b3dbe826a7fa442ae5295474260630754
[mirror_edk2.git] / Tools / Source / ModuleEditor / src / org / tianocore / packaging / module / ui / MsaHeader.java
1 /** @file
2
3 The file is used to create, update MsaHeader of MSA file
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 package org.tianocore.packaging.module.ui;
17
18 import java.awt.event.ActionEvent;
19
20 import javax.swing.JButton;
21 import javax.swing.JComboBox;
22 import javax.swing.JLabel;
23 import javax.swing.JPanel;
24 import javax.swing.JScrollPane;
25 import javax.swing.JTextArea;
26 import javax.swing.JTextField;
27
28 import org.tianocore.AbstractDocument;
29 import org.tianocore.BaseNameDocument;
30 import org.tianocore.FrameworkComponentTypes;
31 import org.tianocore.GuidDocument;
32 import org.tianocore.LicenseDocument;
33 import org.tianocore.ModuleTypeDef;
34 import org.tianocore.MsaHeaderDocument;
35 import org.tianocore.SpecificationDocument;
36 import org.tianocore.common.DataValidation;
37 import org.tianocore.common.Log;
38 import org.tianocore.common.Tools;
39 import org.tianocore.packaging.common.ui.IInternalFrame;
40 import org.tianocore.packaging.common.ui.StarLabel;
41
42 /**
43 The class is used to create, update MsaHeader of MSA file
44 It extends IInternalFrame
45
46 @since ModuleEditor 1.0
47
48 **/
49 public class MsaHeader extends IInternalFrame {
50
51 ///
52 /// Define class Serial Version UID
53 ///
54 private static final long serialVersionUID = -8152099582923006900L;
55
56 //
57 //Define class members
58 //
59 private JPanel jContentPane = null;
60
61 private JLabel jLabelBaseName = null;
62
63 private JTextField jTextFieldBaseName = null;
64
65 private JLabel jLabelGuid = null;
66
67 private JTextField jTextFieldGuid = null;
68
69 private JLabel jLabelVersion = null;
70
71 private JTextField jTextFieldVersion = null;
72
73 private JButton jButtonGenerateGuid = null;
74
75 private JLabel jLabelLicense = null;
76
77 private JTextArea jTextAreaLicense = null;
78
79 private JLabel jLabelCopyright = null;
80
81 private JTextArea jTextAreaCopyright = null;
82
83 private JLabel jLabelDescription = null;
84
85 private JTextArea jTextAreaDescription = null;
86
87 private JLabel jLabelSpecification = null;
88
89 private JTextField jTextFieldSpecification = null;
90
91 private JTextField jTextFieldSpecificationVersion = null;
92
93 private JButton jButtonOk = null;
94
95 private JButton jButtonCancel = null;
96
97 private JScrollPane jScrollPaneLicense = null;
98
99 private JScrollPane jScrollPaneCopyright = null;
100
101 private JScrollPane jScrollPaneDescription = null;
102
103 private JLabel jLabelSpecVersion = null;
104
105 private JLabel jLabelAbstract = null;
106
107 private JTextField jTextFieldAbstract = null;
108
109 private JLabel jLabelModuleType = null;
110
111 private JLabel jLabelCompontentType = null;
112
113 private JComboBox jComboBoxCompontentType = null;
114
115 private JComboBox jComboBoxModuleType = null;
116
117 private StarLabel jStarLabel1 = null;
118
119 private StarLabel jStarLabel2 = null;
120
121 private StarLabel jStarLabel3 = null;
122
123 private StarLabel jStarLabel4 = null;
124
125 private StarLabel jStarLabel5 = null;
126
127 private StarLabel jStarLabel6 = null;
128
129 private StarLabel jStarLabel7 = null;
130
131 private StarLabel jStarLabel8 = null;
132
133 private StarLabel jStarLabel9 = null;
134
135 private MsaHeaderDocument.MsaHeader msaHeader = null;
136
137 private JLabel jLabelURL = null;
138
139 private JTextField jTextFieldAbstractURL = null;
140
141 /**
142 This method initializes jTextFieldBaseName
143
144 @return javax.swing.JTextField jTextFieldBaseName
145
146 **/
147 private JTextField getJTextFieldBaseName() {
148 if (jTextFieldBaseName == null) {
149 jTextFieldBaseName = new JTextField();
150 jTextFieldBaseName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
151 }
152 return jTextFieldBaseName;
153 }
154
155 /**
156 This method initializes jTextFieldGuid
157
158 @return javax.swing.JTextField jTextFieldGuid
159
160 **/
161 private JTextField getJTextFieldGuid() {
162 if (jTextFieldGuid == null) {
163 jTextFieldGuid = new JTextField();
164 jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
165 }
166 return jTextFieldGuid;
167 }
168
169 /**
170 This method initializes jTextFieldVersion
171
172 @return javax.swing.JTextField jTextFieldVersion
173
174 **/
175 private JTextField getJTextFieldVersion() {
176 if (jTextFieldVersion == null) {
177 jTextFieldVersion = new JTextField();
178 jTextFieldVersion.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
179 }
180 return jTextFieldVersion;
181 }
182
183 /**
184 This method initializes jButtonGenerateGuid
185
186 @return javax.swing.JButton jButtonGenerateGuid
187
188 **/
189 private JButton getJButtonGenerateGuid() {
190 if (jButtonGenerateGuid == null) {
191 jButtonGenerateGuid = new JButton();
192 jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
193 jButtonGenerateGuid.setText("GEN");
194 jButtonGenerateGuid.addActionListener(this);
195 }
196 return jButtonGenerateGuid;
197 }
198
199 /**
200 This method initializes jTextAreaLicense
201
202 @return javax.swing.JTextArea jTextAreaLicense
203
204 **/
205 private JTextArea getJTextAreaLicense() {
206 if (jTextAreaLicense == null) {
207 jTextAreaLicense = new JTextArea();
208 jTextAreaLicense.setText("");
209 jTextAreaLicense.setLineWrap(true);
210 }
211 return jTextAreaLicense;
212 }
213
214 /**
215 This method initializes jTextAreaCopyright
216
217 @return javax.swing.JTextArea jTextAreaCopyright
218
219 **/
220 private JTextArea getJTextAreaCopyright() {
221 if (jTextAreaCopyright == null) {
222 jTextAreaCopyright = new JTextArea();
223 jTextAreaCopyright.setLineWrap(true);
224 }
225 return jTextAreaCopyright;
226 }
227
228 /**
229 This method initializes jTextAreaDescription
230
231 @return javax.swing.JTextArea jTextAreaDescription
232
233 **/
234 private JTextArea getJTextAreaDescription() {
235 if (jTextAreaDescription == null) {
236 jTextAreaDescription = new JTextArea();
237 jTextAreaDescription.setLineWrap(true);
238 }
239 return jTextAreaDescription;
240 }
241
242 /**
243 This method initializes jTextFieldSpecification
244
245 @return javax.swing.JTextField jTextFieldSpecification
246
247 **/
248 private JTextField getJTextFieldSpecification() {
249 if (jTextFieldSpecification == null) {
250 jTextFieldSpecification = new JTextField();
251 jTextFieldSpecification.setBounds(new java.awt.Rectangle(160, 340, 220, 20));
252 }
253 return jTextFieldSpecification;
254 }
255
256 /**
257 This method initializes jTextFieldSpecificationVersion
258
259 @return javax.swing.JTextField jTextFieldSpecificationVersion
260
261 **/
262 private JTextField getJTextFieldSpecificationVersion() {
263 if (jTextFieldSpecificationVersion == null) {
264 jTextFieldSpecificationVersion = new JTextField();
265 jTextFieldSpecificationVersion.setBounds(new java.awt.Rectangle(400, 340, 80, 20));
266 }
267 return jTextFieldSpecificationVersion;
268 }
269
270 /**
271 This method initializes jButtonOk
272
273 @return javax.swing.JButton jButtonOk
274
275 **/
276 private JButton getJButtonOk() {
277 if (jButtonOk == null) {
278 jButtonOk = new JButton();
279 jButtonOk.setText("OK");
280 jButtonOk.setBounds(new java.awt.Rectangle(290, 445, 90, 20));
281 jButtonOk.addActionListener(this);
282 }
283 return jButtonOk;
284 }
285
286 /**
287 This method initializes jButtonCancel
288
289 @return javax.swing.JButton jButtonCancel
290
291 **/
292 private JButton getJButtonCancel() {
293 if (jButtonCancel == null) {
294 jButtonCancel = new JButton();
295 jButtonCancel.setText("Cancel");
296 jButtonCancel.setBounds(new java.awt.Rectangle(390, 445, 90, 20));
297 jButtonCancel.addActionListener(this);
298 }
299 return jButtonCancel;
300 }
301
302 /**
303 This method initializes jScrollPaneLicense
304
305 @return javax.swing.JScrollPane jScrollPaneLicense
306
307 **/
308 private JScrollPane getJScrollPaneLicense() {
309 if (jScrollPaneLicense == null) {
310 jScrollPaneLicense = new JScrollPane();
311 jScrollPaneLicense.setBounds(new java.awt.Rectangle(160, 85, 320, 80));
312 jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
313 jScrollPaneLicense.setViewportView(getJTextAreaLicense());
314 }
315 return jScrollPaneLicense;
316 }
317
318 /**
319 This method initializes jScrollPaneCopyright
320
321 @return javax.swing.JScrollPane jScrollPaneCopyright
322
323 **/
324 private JScrollPane getJScrollPaneCopyright() {
325 if (jScrollPaneCopyright == null) {
326 jScrollPaneCopyright = new JScrollPane();
327 jScrollPaneCopyright.setBounds(new java.awt.Rectangle(160, 170, 320, 80));
328 jScrollPaneCopyright.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
329 jScrollPaneCopyright.setViewportView(getJTextAreaCopyright());
330 }
331 return jScrollPaneCopyright;
332 }
333
334 /**
335 This method initializes jScrollPaneDescription
336
337 @return javax.swing.JScrollPane jScrollPaneDescription
338
339 **/
340 private JScrollPane getJScrollPaneDescription() {
341 if (jScrollPaneDescription == null) {
342 jScrollPaneDescription = new JScrollPane();
343 jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 255, 320, 80));
344 jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
345 jScrollPaneDescription.setViewportView(getJTextAreaDescription());
346 }
347 return jScrollPaneDescription;
348 }
349
350 /**
351 This method initializes jTextFieldAbstract
352
353 @return javax.swing.JTextField jTextFieldAbstract
354
355 **/
356 private JTextField getJTextFieldAbstract() {
357 if (jTextFieldAbstract == null) {
358 jTextFieldAbstract = new JTextField();
359 jTextFieldAbstract.setBounds(new java.awt.Rectangle(160, 365, 200, 20));
360 }
361 return jTextFieldAbstract;
362 }
363
364 /**
365 This method initializes jComboBoxCompontentType
366
367 @return javax.swing.JComboBox jComboBoxCompontentType
368
369 **/
370 private JComboBox getJComboBoxCompontentType() {
371 if (jComboBoxCompontentType == null) {
372 jComboBoxCompontentType = new JComboBox();
373 jComboBoxCompontentType.setBounds(new java.awt.Rectangle(160, 415, 320, 20));
374 }
375 return jComboBoxCompontentType;
376 }
377
378 /**
379 This method initializes jComboBoxModuleType
380
381 @return javax.swing.JComboBox jComboBoxModuleType
382
383 **/
384 private JComboBox getJComboBoxModuleType() {
385 if (jComboBoxModuleType == null) {
386 jComboBoxModuleType = new JComboBox();
387 jComboBoxModuleType.setBounds(new java.awt.Rectangle(160, 390, 320, 20));
388 }
389 return jComboBoxModuleType;
390 }
391
392 /**
393 This method initializes jTextFieldAbstractURL
394
395 @return javax.swing.JTextField jTextFieldAbstractURL
396
397 **/
398 private JTextField getJTextFieldAbstractURL() {
399 if (jTextFieldAbstractURL == null) {
400 jTextFieldAbstractURL = new JTextField();
401 jTextFieldAbstractURL.setBounds(new java.awt.Rectangle(390, 365, 90, 20));
402 }
403 return jTextFieldAbstractURL;
404 }
405
406 public static void main(String[] args) {
407
408 }
409
410 /**
411 This is the default constructor
412
413 **/
414 public MsaHeader() {
415 super();
416 init();
417 this.setVisible(true);
418 }
419
420 /**
421 This is the override edit constructor
422
423 @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader
424
425 **/
426 public MsaHeader(MsaHeaderDocument.MsaHeader inMsaHeader) {
427 super();
428 init(inMsaHeader);
429 this.setVisible(true);
430 this.setViewMode(false);
431 }
432
433 /**
434 Disable all components when the mode is view
435
436 @param isView true - The view mode; false - The non-view mode
437
438 **/
439 public void setViewMode(boolean isView) {
440 this.jButtonOk.setVisible(false);
441 this.jButtonCancel.setVisible(false);
442 if (isView) {
443 this.jTextFieldBaseName.setEnabled(!isView);
444 this.jTextFieldGuid.setEnabled(!isView);
445 this.jTextFieldVersion.setEnabled(!isView);
446 this.jTextAreaLicense.setEnabled(!isView);
447 this.jTextAreaCopyright.setEnabled(!isView);
448 this.jTextAreaDescription.setEnabled(!isView);
449 this.jTextFieldSpecification.setEnabled(!isView);
450 this.jTextFieldSpecificationVersion.setEnabled(!isView);
451 this.jTextFieldAbstract.setEnabled(!isView);
452 this.jTextFieldAbstractURL.setEnabled(!isView);
453 this.jComboBoxModuleType.setEnabled(!isView);
454 this.jComboBoxCompontentType.setEnabled(!isView);
455 this.jButtonCancel.setEnabled(!isView);
456 this.jButtonGenerateGuid.setEnabled(!isView);
457 this.jButtonOk.setEnabled(!isView);
458 }
459 }
460
461 /**
462 This method initializes this
463
464 **/
465 private void init() {
466 this.setSize(500, 515);
467 this.setContentPane(getJContentPane());
468 this.setTitle("Module Surface Area Header");
469 initFrame();
470 }
471
472 /**
473 This method initializes this
474 Fill values to all fields if these values are not empty
475
476 @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader
477
478 **/
479 private void init(MsaHeaderDocument.MsaHeader inMsaHeader) {
480 init();
481 if (inMsaHeader != null) {
482 setMsaHeader(inMsaHeader);
483 if (this.msaHeader.getBaseName() != null) {
484 this.jTextFieldBaseName.setText(this.msaHeader.getBaseName().getStringValue());
485 }
486 if (this.msaHeader.getGuid() != null) {
487 this.jTextFieldGuid.setText(this.msaHeader.getGuid().getStringValue());
488 }
489 if (this.msaHeader.getVersion() != null) {
490 this.jTextFieldVersion.setText(this.msaHeader.getVersion());
491 }
492 if (this.msaHeader.getLicense() != null) {
493 this.jTextAreaLicense.setText(this.msaHeader.getLicense().getStringValue());
494 }
495 if (this.msaHeader.getCopyright() != null) {
496 this.jTextAreaCopyright.setText(this.msaHeader.getCopyright());
497 }
498 if (this.msaHeader.getDescription() != null) {
499 this.jTextAreaDescription.setText(this.msaHeader.getDescription());
500 }
501 if (this.msaHeader.getSpecification() != null) {
502 this.jTextFieldSpecification.setText(this.msaHeader.getSpecification().getStringValue());
503 }
504 if (this.msaHeader.getSpecification() != null) {
505 this.jTextFieldSpecificationVersion.setText(this.msaHeader.getSpecification().getVersion());
506 }
507 if (this.msaHeader.getAbstract() != null) {
508 this.jTextFieldAbstract.setText(this.msaHeader.getAbstract().getStringValue());
509 this.jTextFieldAbstractURL.setText(this.msaHeader.getAbstract().getURL());
510 }
511 if (this.msaHeader.getModuleType() != null) {
512 this.jComboBoxModuleType.setSelectedItem(this.msaHeader.getModuleType().toString());
513 }
514 if (this.msaHeader.getComponentType() != null) {
515 this.jComboBoxCompontentType.setSelectedItem(this.msaHeader.getComponentType().toString());
516 }
517 }
518 }
519
520 /**
521 This method initializes jContentPane
522
523 @return javax.swing.JPanel jContentPane
524
525 **/
526 private JPanel getJContentPane() {
527 if (jContentPane == null) {
528 jLabelURL = new JLabel();
529 jLabelURL.setBounds(new java.awt.Rectangle(365, 365, 25, 20));
530 jLabelURL.setText("URL");
531 jLabelCompontentType = new JLabel();
532 jLabelCompontentType.setBounds(new java.awt.Rectangle(15, 415, 140, 20));
533 jLabelCompontentType.setText("Compontent Type");
534 jLabelModuleType = new JLabel();
535 jLabelModuleType.setBounds(new java.awt.Rectangle(15, 390, 140, 20));
536 jLabelModuleType.setText("Module Type");
537 jLabelAbstract = new JLabel();
538 jLabelAbstract.setBounds(new java.awt.Rectangle(15, 365, 140, 20));
539 jLabelAbstract.setText("Abstract");
540 jLabelSpecVersion = new JLabel();
541 jLabelSpecVersion.setBounds(new java.awt.Rectangle(382, 340, 15, 20));
542 jLabelSpecVersion.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
543 jLabelSpecVersion.setText("V");
544 jLabelSpecification = new JLabel();
545 jLabelSpecification.setText("Specification");
546 jLabelSpecification.setBounds(new java.awt.Rectangle(15, 340, 140, 20));
547 jLabelDescription = new JLabel();
548 jLabelDescription.setText("Description");
549 jLabelDescription.setBounds(new java.awt.Rectangle(15, 255, 140, 20));
550 jLabelCopyright = new JLabel();
551 jLabelCopyright.setText("Copyright");
552 jLabelCopyright.setBounds(new java.awt.Rectangle(15, 170, 140, 20));
553 jLabelLicense = new JLabel();
554 jLabelLicense.setText("License");
555 jLabelLicense.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
556 jLabelVersion = new JLabel();
557 jLabelVersion.setText("Version");
558 jLabelVersion.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
559 jLabelGuid = new JLabel();
560 jLabelGuid.setPreferredSize(new java.awt.Dimension(25, 15));
561 jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
562 jLabelGuid.setText("Guid");
563 jLabelBaseName = new JLabel();
564 jLabelBaseName.setText("Base Name");
565 jLabelBaseName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
566 jContentPane = new JPanel();
567 jContentPane.setLayout(null);
568 jContentPane.setLocation(new java.awt.Point(0, 0));
569 jContentPane.setSize(new java.awt.Dimension(500, 524));
570 jContentPane.add(jLabelBaseName, null);
571 jContentPane.add(getJTextFieldBaseName(), null);
572 jContentPane.add(jLabelGuid, null);
573 jContentPane.add(getJTextFieldGuid(), null);
574 jContentPane.add(jLabelVersion, null);
575 jContentPane.add(getJTextFieldVersion(), null);
576 jContentPane.add(getJButtonGenerateGuid(), null);
577 jContentPane.add(jLabelLicense, null);
578 jContentPane.add(jLabelCopyright, null);
579 jContentPane.add(jLabelDescription, null);
580 jContentPane.add(jLabelSpecification, null);
581 jContentPane.add(getJTextFieldSpecification(), null);
582 jContentPane.add(getJTextFieldSpecificationVersion(), null);
583 jContentPane.add(getJButtonOk(), null);
584 jContentPane.add(getJButtonCancel(), null);
585 jContentPane.add(getJScrollPaneLicense(), null);
586 jContentPane.add(getJScrollPaneCopyright(), null);
587 jContentPane.add(getJScrollPaneDescription(), null);
588 jContentPane.add(jLabelAbstract, null);
589 jContentPane.add(getJTextFieldAbstract(), null);
590 jContentPane.add(jLabelSpecVersion, null);
591 jContentPane.add(jLabelModuleType, null);
592 jContentPane.add(jLabelCompontentType, null);
593 jContentPane.add(getJComboBoxCompontentType(), null);
594 jContentPane.add(getJComboBoxModuleType(), null);
595
596 jStarLabel1 = new StarLabel();
597 jStarLabel1.setLocation(new java.awt.Point(0, 10));
598 jStarLabel2 = new StarLabel();
599 jStarLabel2.setLocation(new java.awt.Point(0, 35));
600 jStarLabel3 = new StarLabel();
601 jStarLabel3.setLocation(new java.awt.Point(0, 60));
602 jStarLabel4 = new StarLabel();
603 jStarLabel4.setLocation(new java.awt.Point(0, 85));
604 jStarLabel5 = new StarLabel();
605 jStarLabel5.setLocation(new java.awt.Point(0, 170));
606 jStarLabel6 = new StarLabel();
607 jStarLabel6.setLocation(new java.awt.Point(0, 255));
608 jStarLabel7 = new StarLabel();
609 jStarLabel7.setLocation(new java.awt.Point(0, 365));
610 jStarLabel8 = new StarLabel();
611 jStarLabel8.setLocation(new java.awt.Point(0, 390));
612 jStarLabel9 = new StarLabel();
613 jStarLabel9.setLocation(new java.awt.Point(0, 415));
614
615 jContentPane.add(jStarLabel1, null);
616 jContentPane.add(jStarLabel2, null);
617 jContentPane.add(jStarLabel3, null);
618 jContentPane.add(jStarLabel4, null);
619 jContentPane.add(jStarLabel5, null);
620 jContentPane.add(jStarLabel6, null);
621 jContentPane.add(jStarLabel7, null);
622 jContentPane.add(jStarLabel8, null);
623 jContentPane.add(jStarLabel9, null);
624 jContentPane.add(jLabelURL, null);
625 jContentPane.add(getJTextFieldAbstractURL(), null);
626 }
627 return jContentPane;
628 }
629
630 /* (non-Javadoc)
631 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
632 *
633 * Override actionPerformed to listen all actions
634 *
635 */
636 public void actionPerformed(ActionEvent arg0) {
637 if (arg0.getSource() == jButtonOk) {
638 this.save();
639 this.setEdited(true);
640 }
641 if (arg0.getSource() == jButtonCancel) {
642 this.setEdited(false);
643 }
644 if (arg0.getSource() == jButtonGenerateGuid) {
645 jTextFieldGuid.setText(Tools.generateUuidString());
646 }
647 }
648
649 /**
650 Data validation for all fields
651
652 @retval true - All datas are valid
653 @retval false - At least one data is invalid
654
655 **/
656 public boolean check() {
657 //
658 // Check if all required fields are not empty
659 //
660 if (isEmpty(this.jTextFieldBaseName.getText())) {
661 Log.err("Base Name couldn't be empty");
662 return false;
663 }
664 if (isEmpty(this.jTextFieldGuid.getText())) {
665 Log.err("Guid couldn't be empty");
666 return false;
667 }
668 if (isEmpty(this.jTextFieldVersion.getText())) {
669 Log.err("Version couldn't be empty");
670 return false;
671 }
672 if (isEmpty(this.jTextAreaLicense.getText())) {
673 Log.err("License couldn't be empty");
674 return false;
675 }
676 if (isEmpty(this.jTextAreaCopyright.getText())) {
677 Log.err("Copyright couldn't be empty");
678 return false;
679 }
680 if (isEmpty(this.jTextAreaDescription.getText())) {
681 Log.err("Description couldn't be empty");
682 return false;
683 }
684 if (isEmpty(this.jTextFieldAbstract.getText())) {
685 Log.err("Abstract couldn't be empty");
686 return false;
687 }
688
689 //
690 // Check if all fields have correct data types
691 //
692 if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
693 Log.err("Incorrect data type for Base Name");
694 return false;
695 }
696 if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
697 Log.err("Incorrect data type for Guid");
698 return false;
699 }
700 if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {
701 Log.err("Incorrect data type for Abstract");
702 return false;
703 }
704 if (!DataValidation.isCopyright(this.jTextAreaCopyright.getText())) {
705 Log.err("Incorrect data type for Copyright");
706 return false;
707 }
708 return true;
709 }
710
711 /**
712 Save all components of Msa Header
713 if exists msaHeader, set the value directly
714 if not exists msaHeader, new an instance first
715
716 **/
717 public void save() {
718 try {
719 if (this.msaHeader == null) {
720 msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance();
721 }
722 if (this.msaHeader.getBaseName() != null) {
723 this.msaHeader.getBaseName().setStringValue(this.jTextFieldBaseName.getText());
724 } else {
725 BaseNameDocument.BaseName mBaseName = BaseNameDocument.BaseName.Factory.newInstance();
726 mBaseName.setStringValue(this.jTextFieldBaseName.getText());
727 this.msaHeader.setBaseName(mBaseName);
728 }
729
730 if (this.msaHeader.getGuid() != null) {
731 this.msaHeader.getGuid().setStringValue(this.jTextFieldGuid.getText());
732 } else {
733 GuidDocument.Guid mGuid = GuidDocument.Guid.Factory.newInstance();
734 mGuid.setStringValue(this.jTextFieldGuid.getText());
735 this.msaHeader.setGuid(mGuid);
736 }
737
738 this.msaHeader.setVersion(this.jTextFieldVersion.getText());
739
740 if (this.msaHeader.getLicense() != null) {
741 this.msaHeader.getLicense().setStringValue(this.jTextAreaLicense.getText());
742 } else {
743 LicenseDocument.License mLicense = LicenseDocument.License.Factory.newInstance();
744 mLicense.setStringValue(this.jTextAreaLicense.getText());
745 this.msaHeader.setLicense(mLicense);
746 }
747
748 this.msaHeader.setCopyright(this.jTextAreaCopyright.getText());
749 this.msaHeader.setDescription(this.jTextAreaDescription.getText());
750
751 if (this.msaHeader.getSpecification() != null) {
752 this.msaHeader.getSpecification().setStringValue(this.jTextFieldSpecification.getText());
753 this.msaHeader.getSpecification().setVersion(this.jTextFieldSpecificationVersion.getText());
754 } else {
755 SpecificationDocument.Specification mSpecification = SpecificationDocument.Specification.Factory
756 .newInstance();
757 mSpecification.setStringValue(this.jTextFieldSpecification.getText());
758 mSpecification.setVersion(this.jTextFieldSpecificationVersion.getText());
759 this.msaHeader.setSpecification(mSpecification);
760 }
761
762 if (this.msaHeader.getAbstract() != null) {
763 this.msaHeader.getAbstract().setStringValue(this.jTextFieldAbstract.getText());
764 this.msaHeader.getAbstract().setURL(this.jTextFieldAbstractURL.getText());
765 } else {
766 AbstractDocument.Abstract mAbstract = AbstractDocument.Abstract.Factory.newInstance();
767 mAbstract.setStringValue(this.jTextFieldAbstract.getText());
768 mAbstract.setURL(this.jTextFieldAbstractURL.getText());
769 this.msaHeader.setAbstract(mAbstract);
770 }
771 this.msaHeader.setModuleType(ModuleTypeDef.Enum.forString(this.jComboBoxModuleType.getSelectedItem()
772 .toString()));
773 this.msaHeader
774 .setComponentType(FrameworkComponentTypes.Enum
775 .forString(this.jComboBoxCompontentType
776 .getSelectedItem()
777 .toString()));
778 if (this.msaHeader.getCreated() == null) {
779 this.msaHeader.setCreated(Tools.getCurrentDateTime());
780 } else {
781 this.msaHeader.setUpdated(Tools.getCurrentDateTime());
782 }
783
784 } catch (Exception e) {
785 Log.err("Save Module", e.getMessage());
786 }
787 }
788
789 /**
790 This method initializes Module type and Compontent type
791
792 **/
793 private void initFrame() {
794 jComboBoxModuleType.addItem("BASE");
795 jComboBoxModuleType.addItem("SEC");
796 jComboBoxModuleType.addItem("PEI_CORE");
797 jComboBoxModuleType.addItem("PEIM");
798 jComboBoxModuleType.addItem("DXE_CORE");
799 jComboBoxModuleType.addItem("DXE_DRIVER");
800 jComboBoxModuleType.addItem("DXE_RUNTIME_DRIVER");
801 jComboBoxModuleType.addItem("DXE_SAL_DRIVER");
802 jComboBoxModuleType.addItem("DXE_SMM_DRIVER");
803 jComboBoxModuleType.addItem("TOOLS");
804 jComboBoxModuleType.addItem("UEFI_DRIVER");
805 jComboBoxModuleType.addItem("UEFI_APPLICATION");
806 jComboBoxModuleType.addItem("USER_DEFINED");
807
808 jComboBoxCompontentType.addItem("APRIORI");
809 jComboBoxCompontentType.addItem("LIBRARY");
810 jComboBoxCompontentType.addItem("FV_IMAGE_FILE");
811 jComboBoxCompontentType.addItem("BS_DRIVER");
812 jComboBoxCompontentType.addItem("RT_DRIVER");
813 jComboBoxCompontentType.addItem("SAL_RT_DRIVER");
814 jComboBoxCompontentType.addItem("PE32_PEIM");
815 jComboBoxCompontentType.addItem("PIC_PEIM");
816 jComboBoxCompontentType.addItem("COMBINED_PEIM_DRIVER");
817 jComboBoxCompontentType.addItem("PEI_CORE");
818 jComboBoxCompontentType.addItem("DXE_CORE");
819 jComboBoxCompontentType.addItem("APPLICATION");
820 jComboBoxCompontentType.addItem("BS_DRIVER_EFI");
821 jComboBoxCompontentType.addItem("SHELLAPP");
822 }
823
824 /**
825 Get MsaHeaderDocument.MsaHeader
826
827 @return MsaHeaderDocument.MsaHeader
828
829 **/
830 public MsaHeaderDocument.MsaHeader getMsaHeader() {
831 return msaHeader;
832 }
833
834 /**
835 Set MsaHeaderDocument.MsaHeader
836
837 @param msaHeader The input data of MsaHeaderDocument.MsaHeader
838
839 **/
840 public void setMsaHeader(MsaHeaderDocument.MsaHeader msaHeader) {
841 this.msaHeader = msaHeader;
842 }
843 }