0760a76786a16c8e76a481dd842ece2f91def169
[mirror_edk2.git] / Tools / Source / ModuleEditor / src / org / tianocore / packaging / module / ui / MsaLibHeader.java
1 /** @file
2
3 The file is used to create, update MsaLibHeader of a 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.MsaLibHeaderDocument;
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 MsaLibHeader of a MSA file
44 It extends IInternalFrame
45
46 @since ModuleEditor 1.0
47
48 **/
49 public class MsaLibHeader extends IInternalFrame {
50
51 ///
52 /// Define class Serial Version UID
53 ///
54 private static final long serialVersionUID = 5526729363068526262L;
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 MsaLibHeaderDocument.MsaLibHeader msaLibHeader = 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 MsaLibHeader() {
415 super();
416 init();
417 this.setVisible(true);
418 }
419
420 /**
421 This is the override edit constructor
422
423 @param inMsaLibHeader The input data of MsaLibHeaderDocument.MsaLibHeader
424
425 **/
426 public MsaLibHeader(MsaLibHeaderDocument.MsaLibHeader inMsaLibHeader) {
427 super();
428 init(inMsaLibHeader);
429 this.setVisible(true);
430 this.setViewMode(false);
431 }
432
433 /**
434 This method initializes this
435
436 **/
437 private void init() {
438 this.setSize(500, 515);
439 this.setContentPane(getJContentPane());
440 this.setTitle("Library Module");
441 initFrame();
442 }
443
444 /**
445 This method initializes this
446 Fill values to all fields if these values are not empty
447
448 @param inMsaLibHeader The input data of MsaLibHeaderDocument.MsaLibHeader
449
450 **/
451 private void init(MsaLibHeaderDocument.MsaLibHeader inMsaLibHeader) {
452 init();
453 this.setMsaLibHeader(inMsaLibHeader);
454 if (inMsaLibHeader != null) {
455 if (this.msaLibHeader.getBaseName() != null) {
456 this.jTextFieldBaseName.setText(this.msaLibHeader.getBaseName().getStringValue());
457 }
458 if (this.msaLibHeader.getGuid() != null) {
459 this.jTextFieldGuid.setText(this.msaLibHeader.getGuid().getStringValue());
460 }
461 if (this.msaLibHeader.getVersion() != null) {
462 this.jTextFieldVersion.setText(this.msaLibHeader.getVersion());
463 }
464 if (this.msaLibHeader.getLicense() != null) {
465 this.jTextAreaLicense.setText(this.msaLibHeader.getLicense().getStringValue());
466 }
467 if (this.msaLibHeader.getCopyright() != null) {
468 this.jTextAreaCopyright.setText(this.msaLibHeader.getCopyright());
469 }
470 if (this.msaLibHeader.getDescription() != null) {
471 this.jTextAreaDescription.setText(this.msaLibHeader.getDescription());
472 }
473 if (this.msaLibHeader.getSpecification() != null) {
474 this.jTextFieldSpecification.setText(this.msaLibHeader.getSpecification().getStringValue());
475 }
476 if (this.msaLibHeader.getSpecification() != null) {
477 this.jTextFieldSpecificationVersion.setText(this.msaLibHeader.getSpecification().getVersion());
478 }
479 if (this.msaLibHeader.getAbstract() != null) {
480 this.jTextFieldAbstract.setText(this.msaLibHeader.getAbstract().getStringValue());
481 this.jTextFieldAbstractURL.setText(this.msaLibHeader.getAbstract().getURL());
482 }
483 if (this.msaLibHeader.getModuleType() != null) {
484 this.jComboBoxModuleType.setSelectedItem(this.msaLibHeader.getModuleType().toString());
485 }
486 if (this.msaLibHeader.getComponentType() != null) {
487 this.jComboBoxCompontentType.setSelectedItem(this.msaLibHeader.getComponentType().toString());
488 }
489 }
490 }
491
492 /**
493 Disable all components when the mode is view
494
495 @param isView true - The view mode; false - The non-view mode
496
497 **/
498 public void setViewMode(boolean isView) {
499 this.jButtonOk.setVisible(false);
500 this.jButtonCancel.setVisible(false);
501 if (isView) {
502 this.jTextFieldBaseName.setEnabled(!isView);
503 this.jTextFieldGuid.setEnabled(!isView);
504 this.jTextFieldVersion.setEnabled(!isView);
505 this.jTextAreaLicense.setEnabled(!isView);
506 this.jTextAreaCopyright.setEnabled(!isView);
507 this.jTextAreaDescription.setEnabled(!isView);
508 this.jTextFieldSpecification.setEnabled(!isView);
509 this.jTextFieldSpecificationVersion.setEnabled(!isView);
510 this.jTextFieldAbstract.setEnabled(!isView);
511 this.jTextFieldAbstractURL.setEnabled(!isView);
512 this.jComboBoxModuleType.setEnabled(!isView);
513 this.jComboBoxCompontentType.setEnabled(!isView);
514 this.jButtonCancel.setEnabled(!isView);
515 this.jButtonGenerateGuid.setEnabled(!isView);
516 this.jButtonOk.setEnabled(!isView);
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.dispose();
639 this.save();
640 this.setEdited(true);
641 }
642 if (arg0.getSource() == jButtonCancel) {
643 this.dispose();
644 this.setEdited(false);
645 }
646 if (arg0.getSource() == jButtonGenerateGuid) {
647 jTextFieldGuid.setText(Tools.generateUuidString());
648 }
649 }
650
651 /**
652 Data validation for all fields
653
654 @retval true - All datas are valid
655 @retval false - At least one data is invalid
656
657 **/
658 public boolean check() {
659 //
660 // Check if all required fields are not empty
661 //
662 if (isEmpty(this.jTextFieldBaseName.getText())) {
663 Log.err("Base Name couldn't be empty");
664 return false;
665 }
666 if (isEmpty(this.jTextFieldGuid.getText())) {
667 Log.err("Guid couldn't be empty");
668 return false;
669 }
670 if (isEmpty(this.jTextFieldVersion.getText())) {
671 Log.err("Version couldn't be empty");
672 return false;
673 }
674 if (isEmpty(this.jTextAreaLicense.getText())) {
675 Log.err("License couldn't be empty");
676 return false;
677 }
678 if (isEmpty(this.jTextAreaCopyright.getText())) {
679 Log.err("Copyright couldn't be empty");
680 return false;
681 }
682 if (isEmpty(this.jTextAreaDescription.getText())) {
683 Log.err("Description couldn't be empty");
684 return false;
685 }
686 if (isEmpty(this.jTextFieldAbstract.getText())) {
687 Log.err("Abstract couldn't be empty");
688 return false;
689 }
690
691 //
692 // Check if all fields have correct data types
693 //
694 if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
695 Log.err("Incorrect data type for Base Name");
696 return false;
697 }
698 if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
699 Log.err("Incorrect data type for Guid");
700 return false;
701 }
702 if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {
703 Log.err("Incorrect data type for Abstract");
704 return false;
705 }
706 if (!DataValidation.isCopyright(this.jTextAreaCopyright.getText())) {
707 Log.err("Incorrect data type for Copyright");
708 return false;
709 }
710 return true;
711 }
712
713 /**
714 Save all components of Msa Lib Header
715 if exists msaLibHeader, set the value directly
716 if not exists msaLibHeader, new an instance first
717
718 **/
719 public void save() {
720 try {
721 if (this.msaLibHeader == null) {
722 msaLibHeader = MsaLibHeaderDocument.MsaLibHeader.Factory.newInstance();
723 }
724 if (this.msaLibHeader.getBaseName() != null) {
725 this.msaLibHeader.getBaseName().setStringValue(this.jTextFieldBaseName.getText());
726 } else {
727 BaseNameDocument.BaseName mBaseName = BaseNameDocument.BaseName.Factory.newInstance();
728 mBaseName.setStringValue(this.jTextFieldBaseName.getText());
729 this.msaLibHeader.setBaseName(mBaseName);
730 }
731
732 if (this.msaLibHeader.getGuid() != null) {
733 this.msaLibHeader.getGuid().setStringValue(this.jTextFieldGuid.getText());
734 } else {
735 GuidDocument.Guid mGuid = GuidDocument.Guid.Factory.newInstance();
736 mGuid.setStringValue(this.jTextFieldGuid.getText());
737 this.msaLibHeader.setGuid(mGuid);
738 }
739
740 this.msaLibHeader.setVersion(this.jTextFieldVersion.getText());
741
742 if (this.msaLibHeader.getLicense() != null) {
743 this.msaLibHeader.getLicense().setStringValue(this.jTextAreaLicense.getText());
744 } else {
745 LicenseDocument.License mLicense = LicenseDocument.License.Factory.newInstance();
746 mLicense.setStringValue(this.jTextAreaLicense.getText());
747 this.msaLibHeader.setLicense(mLicense);
748 }
749
750 this.msaLibHeader.setCopyright(this.jTextAreaCopyright.getText());
751 this.msaLibHeader.setDescription(this.jTextAreaDescription.getText());
752
753 if (this.msaLibHeader.getSpecification() != null) {
754 this.msaLibHeader.getSpecification().setStringValue(this.jTextFieldSpecification.getText());
755 this.msaLibHeader.getSpecification().setVersion(this.jTextFieldSpecificationVersion.getText());
756 } else {
757 SpecificationDocument.Specification mSpecification = SpecificationDocument.Specification.Factory
758 .newInstance();
759 mSpecification.setStringValue(this.jTextFieldSpecification.getText());
760 mSpecification.setVersion(this.jTextFieldSpecificationVersion.getText());
761 this.msaLibHeader.setSpecification(mSpecification);
762 }
763
764 if (this.msaLibHeader.getAbstract() != null) {
765 this.msaLibHeader.getAbstract().setStringValue(this.jTextFieldAbstract.getText());
766 this.msaLibHeader.getAbstract().setURL(this.jTextFieldAbstractURL.getText());
767 } else {
768 AbstractDocument.Abstract mAbstract = AbstractDocument.Abstract.Factory.newInstance();
769 mAbstract.setStringValue(this.jTextFieldAbstract.getText());
770 mAbstract.setURL(this.jTextFieldAbstractURL.getText());
771 this.msaLibHeader.setAbstract(mAbstract);
772 }
773
774 this.msaLibHeader.setModuleType(ModuleTypeDef.Enum.forString(this.jComboBoxModuleType.getSelectedItem()
775 .toString()));
776 this.msaLibHeader
777 .setComponentType(FrameworkComponentTypes.Enum
778 .forString(this.jComboBoxCompontentType
779 .getSelectedItem()
780 .toString()));
781
782 if (this.msaLibHeader.getCreated() == null) {
783 this.msaLibHeader.setCreated(Tools.getCurrentDateTime());
784 } else {
785 this.msaLibHeader.setUpdated(Tools.getCurrentDateTime());
786 }
787 } catch (Exception e) {
788 Log.err("Save Module", e.getMessage());
789 }
790 }
791
792 /**
793 This method initializes module type and compontent type
794
795 **/
796 private void initFrame() {
797 jComboBoxModuleType.addItem("BASE");
798 jComboBoxModuleType.addItem("SEC");
799 jComboBoxModuleType.addItem("PEI_CORE");
800 jComboBoxModuleType.addItem("PEIM");
801 jComboBoxModuleType.addItem("DXE_CORE");
802 jComboBoxModuleType.addItem("DXE_DRIVER");
803 jComboBoxModuleType.addItem("DXE_RUNTIME_DRIVER");
804 jComboBoxModuleType.addItem("DXE_SMM_DRIVER");
805 jComboBoxModuleType.addItem("DXE_SAL_DRIVER");
806 jComboBoxModuleType.addItem("UEFI_DRIVER");
807 jComboBoxModuleType.addItem("UEFI_APPLICATION");
808
809 jComboBoxCompontentType.addItem("APRIORI");
810 jComboBoxCompontentType.addItem("LIBRARY");
811 jComboBoxCompontentType.addItem("FV_IMAGE_FILE");
812 jComboBoxCompontentType.addItem("BS_DRIVER");
813 jComboBoxCompontentType.addItem("RT_DRIVER");
814 jComboBoxCompontentType.addItem("SAL_RT_DRIVER");
815 jComboBoxCompontentType.addItem("PE32_PEIM");
816 jComboBoxCompontentType.addItem("PIC_PEIM");
817 jComboBoxCompontentType.addItem("COMBINED_PEIM_DRIVER");
818 jComboBoxCompontentType.addItem("PEI_CORE");
819 jComboBoxCompontentType.addItem("DXE_CORE");
820 jComboBoxCompontentType.addItem("APPLICATION");
821 jComboBoxCompontentType.addItem("BS_DRIVER_EFI");
822 jComboBoxCompontentType.addItem("SHELLAPP");
823 }
824
825 /**
826 Get MsaLibHeaderDocument.MsaLibHeader
827
828 @return MsaLibHeaderDocument.MsaLibHeader
829
830 **/
831 public MsaLibHeaderDocument.MsaLibHeader getMsaLibHeader() {
832 return msaLibHeader;
833 }
834
835 /**
836 Set MsaLibHeaderDocument.MsaLibHeader
837
838 @param msaLibHeader The input data of MsaLibHeaderDocument.MsaLibHeader
839
840 **/
841 public void setMsaLibHeader(MsaLibHeaderDocument.MsaLibHeader msaLibHeader) {
842 this.msaLibHeader = msaLibHeader;
843 }
844
845 }