1. Fix EDKT273 "Externs are not being grouped together in MSA Files"
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / 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.frameworkwizard.module.ui;
17
18 import java.awt.event.ActionEvent;
19 import java.awt.event.ComponentEvent;
20 import java.awt.event.FocusEvent;
21 import java.util.Vector;
22
23 import javax.swing.JButton;
24 import javax.swing.JCheckBox;
25 import javax.swing.JComboBox;
26 import javax.swing.JLabel;
27 import javax.swing.JPanel;
28 import javax.swing.JScrollPane;
29 import javax.swing.JTextArea;
30 import javax.swing.JTextField;
31
32 import org.tianocore.ExternsDocument;
33 import org.tianocore.ModuleDefinitionsDocument;
34 import org.tianocore.ModuleSurfaceAreaDocument;
35 import org.tianocore.ModuleTypeDef;
36 import org.tianocore.MsaHeaderDocument;
37 import org.tianocore.PcdDriverTypes;
38 import org.tianocore.LicenseDocument.License;
39 import org.tianocore.frameworkwizard.common.DataType;
40 import org.tianocore.frameworkwizard.common.DataValidation;
41 import org.tianocore.frameworkwizard.common.EnumerationData;
42 import org.tianocore.frameworkwizard.common.Log;
43 import org.tianocore.frameworkwizard.common.Tools;
44 import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
45 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
46 import org.tianocore.frameworkwizard.common.ui.StarLabel;
47
48 /**
49 The class is used to create, update MsaHeader of MSA file
50 It extends IInternalFrame
51
52
53
54 **/
55 public class MsaHeader extends IInternalFrame {
56
57 ///
58 /// Define class Serial Version UID
59 ///
60 private static final long serialVersionUID = -8152099582923006900L;
61
62 private int dialogWidth = 500;
63
64 private int dialogHeight = 630;
65
66 //
67 //Define class members
68 //
69 private JPanel jContentPane = null;
70
71 private JLabel jLabelBaseName = null;
72
73 private JTextField jTextFieldBaseName = null;
74
75 private JLabel jLabelGuid = null;
76
77 private JTextField jTextFieldGuid = null;
78
79 private JLabel jLabelVersion = null;
80
81 private JTextField jTextFieldVersion = null;
82
83 private JButton jButtonGenerateGuid = null;
84
85 private JLabel jLabelLicense = null;
86
87 private JTextArea jTextAreaLicense = null;
88
89 private JLabel jLabelCopyright = null;
90
91 private JLabel jLabelDescription = null;
92
93 private JTextArea jTextAreaDescription = null;
94
95 private JLabel jLabelSpecification = null;
96
97 private JTextField jTextFieldSpecification = null;
98
99 private JButton jButtonOk = null;
100
101 private JButton jButtonCancel = null;
102
103 private JScrollPane jScrollPaneLicense = null;
104
105 private JScrollPane jScrollPaneDescription = null;
106
107 private JLabel jLabelAbstract = null;
108
109 private JTextField jTextFieldAbstract = null;
110
111 private JLabel jLabelModuleType = null;
112
113 private JComboBox jComboBoxModuleType = null;
114
115 private JLabel jLabelArch = null;
116
117 private JLabel jLabelBinaryModule = null;
118
119 private JComboBox jComboBoxBinaryModule = null;
120
121 private JLabel jLabelOutputFileBasename = null;
122
123 private JTextField jTextFieldOutputFileBasename = null;
124
125 private JScrollPane jScrollPaneCopyright = null;
126
127 private JTextArea jTextAreaCopyright = null;
128
129 private JLabel jLabelURL = null;
130
131 private JTextField jTextFieldURL = null;
132
133 private JScrollPane jScrollPane = null;
134
135 private StarLabel jStarLabel1 = null;
136
137 private StarLabel jStarLabel2 = null;
138
139 private StarLabel jStarLabel4 = null;
140
141 private StarLabel jStarLabel5 = null;
142
143 private StarLabel jStarLabel6 = null;
144
145 private StarLabel jStarLabel7 = null;
146
147 private StarLabel jStarLabel8 = null;
148
149 private StarLabel jStarLabel10 = null;
150
151 private StarLabel jStarLabel12 = null;
152
153 private StarLabel jStarLabel13 = null;
154
155 private StarLabel jStarLabel14 = null;
156
157 private JCheckBox jCheckBoxIa32 = null;
158
159 private JCheckBox jCheckBoxX64 = null;
160
161 private JCheckBox jCheckBoxIpf = null;
162
163 private JCheckBox jCheckBoxEbc = null;
164
165 private JCheckBox jCheckBoxArm = null;
166
167 private JCheckBox jCheckBoxPpc = null;
168
169 private JComboBox jComboBoxPcdIsDriver = null;
170
171 private JCheckBox jCheckBoxPcd = null;
172
173 private JCheckBox jCheckBoxFlashMap = null;
174
175 //
176 // Not used for UI
177 //
178 private MsaHeaderDocument.MsaHeader msaHeader = null;
179
180 private ModuleDefinitionsDocument.ModuleDefinitions md = null;
181
182 private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;
183
184 private ExternsDocument.Externs ex = null;
185
186 private OpeningModuleType omt = null;
187
188 private EnumerationData ed = new EnumerationData();
189
190 /**
191 * This method initializes jCheckBoxIa32
192 *
193 * @return javax.swing.JCheckBox
194 */
195 private JCheckBox getJCheckBoxIa32() {
196 if (jCheckBoxIa32 == null) {
197 jCheckBoxIa32 = new JCheckBox();
198 jCheckBoxIa32.setBounds(new java.awt.Rectangle(160, 505, 55, 20));
199 jCheckBoxIa32.setText("IA32");
200 jCheckBoxIa32.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
201 jCheckBoxIa32.addFocusListener(this);
202 }
203 return jCheckBoxIa32;
204 }
205
206 /**
207 * This method initializes jCheckBoxX64
208 *
209 * @return javax.swing.JCheckBox
210 */
211 private JCheckBox getJCheckBoxX64() {
212 if (jCheckBoxX64 == null) {
213 jCheckBoxX64 = new JCheckBox();
214 jCheckBoxX64.setBounds(new java.awt.Rectangle(215, 505, 53, 20));
215 jCheckBoxX64.setText("X64");
216 jCheckBoxX64.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
217 jCheckBoxX64.addFocusListener(this);
218 }
219 return jCheckBoxX64;
220 }
221
222 /**
223 * This method initializes jCheckBoxIpf
224 *
225 * @return javax.swing.JCheckBox
226 */
227 private JCheckBox getJCheckBoxIpf() {
228 if (jCheckBoxIpf == null) {
229 jCheckBoxIpf = new JCheckBox();
230 jCheckBoxIpf.setBounds(new java.awt.Rectangle(270, 505, 52, 20));
231 jCheckBoxIpf.setText("IPF");
232 jCheckBoxIpf.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
233 jCheckBoxIpf.addFocusListener(this);
234 }
235 return jCheckBoxIpf;
236 }
237
238 /**
239 * This method initializes jCheckBoxEbc
240 *
241 * @return javax.swing.JCheckBox
242 */
243 private JCheckBox getJCheckBoxEbc() {
244 if (jCheckBoxEbc == null) {
245 jCheckBoxEbc = new JCheckBox();
246 jCheckBoxEbc.setBounds(new java.awt.Rectangle(325, 505, 53, 20));
247 jCheckBoxEbc.setText("EBC");
248 jCheckBoxEbc.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
249 jCheckBoxEbc.addFocusListener(this);
250 }
251 return jCheckBoxEbc;
252 }
253
254 /**
255 * This method initializes jCheckBoxArm
256 *
257 * @return javax.swing.JCheckBox
258 */
259 private JCheckBox getJCheckBoxArm() {
260 if (jCheckBoxArm == null) {
261 jCheckBoxArm = new JCheckBox();
262 jCheckBoxArm.setBounds(new java.awt.Rectangle(380, 505, 54, 20));
263 jCheckBoxArm.setText("ARM");
264 jCheckBoxArm.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
265 jCheckBoxArm.addFocusListener(this);
266 }
267 return jCheckBoxArm;
268 }
269
270 /**
271 * This method initializes jCheckBoxPpc
272 *
273 * @return javax.swing.JCheckBox
274 */
275 private JCheckBox getJCheckBoxPpc() {
276 if (jCheckBoxPpc == null) {
277 jCheckBoxPpc = new JCheckBox();
278 jCheckBoxPpc.setBounds(new java.awt.Rectangle(435, 505, 53, 20));
279 jCheckBoxPpc.setText("PPC");
280 jCheckBoxPpc.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
281 jCheckBoxPpc.addFocusListener(this);
282 }
283 return jCheckBoxPpc;
284 }
285
286 /**
287 This method initializes jTextFieldBaseName
288
289 @return javax.swing.JTextField jTextFieldBaseName
290
291 **/
292 private JTextField getJTextFieldBaseName() {
293 if (jTextFieldBaseName == null) {
294 jTextFieldBaseName = new JTextField();
295 jTextFieldBaseName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
296 jTextFieldBaseName.setPreferredSize(new java.awt.Dimension(320, 20));
297 jTextFieldBaseName.addFocusListener(this);
298 jTextFieldBaseName.setToolTipText("A brief Identifier, such as USB I/O Library, of the module");
299 }
300 return jTextFieldBaseName;
301 }
302
303 /**
304 This method initializes jTextFieldGuid
305
306 @return javax.swing.JTextField jTextFieldGuid
307
308 **/
309 private JTextField getJTextFieldGuid() {
310 if (jTextFieldGuid == null) {
311 jTextFieldGuid = new JTextField();
312 jTextFieldGuid.setPreferredSize(new java.awt.Dimension(250, 20));
313 jTextFieldGuid.setLocation(new java.awt.Point(160, 60));
314 jTextFieldGuid.setSize(new java.awt.Dimension(250, 20));
315 jTextFieldGuid.addFocusListener(this);
316 jTextFieldGuid.setToolTipText("Guaranteed Unique Identification Number, Registry Format (8-4-4-4-12)");
317 }
318 return jTextFieldGuid;
319 }
320
321 /**
322 This method initializes jTextFieldVersion
323
324 @return javax.swing.JTextField jTextFieldVersion
325
326 **/
327 private JTextField getJTextFieldVersion() {
328 if (jTextFieldVersion == null) {
329 jTextFieldVersion = new JTextField();
330 jTextFieldVersion.setPreferredSize(new java.awt.Dimension(320, 20));
331 jTextFieldVersion.setLocation(new java.awt.Point(160, 85));
332 jTextFieldVersion.setSize(new java.awt.Dimension(320, 20));
333 jTextFieldVersion.addFocusListener(this);
334 jTextFieldVersion.setToolTipText("A Version Number, 1.0, 1, 1.01, 1.0.1");
335 }
336 return jTextFieldVersion;
337 }
338
339 /**
340 This method initializes jButtonGenerateGuid
341
342 @return javax.swing.JButton jButtonGenerateGuid
343
344 **/
345 private JButton getJButtonGenerateGuid() {
346 if (jButtonGenerateGuid == null) {
347 jButtonGenerateGuid = new JButton();
348 jButtonGenerateGuid.setPreferredSize(new java.awt.Dimension(65, 20));
349 jButtonGenerateGuid.setSize(new java.awt.Dimension(65, 20));
350 jButtonGenerateGuid.setLocation(new java.awt.Point(415, 60));
351 jButtonGenerateGuid.setText("GEN");
352 jButtonGenerateGuid.addActionListener(this);
353 }
354 return jButtonGenerateGuid;
355 }
356
357 /**
358 This method initializes jTextAreaLicense
359
360 @return javax.swing.JTextArea jTextAreaLicense
361
362 **/
363 private JTextArea getJTextAreaLicense() {
364 if (jTextAreaLicense == null) {
365 jTextAreaLicense = new JTextArea();
366 jTextAreaLicense.setText("");
367 jTextAreaLicense.setLineWrap(true);
368 jTextAreaLicense.addFocusListener(this);
369 jTextAreaLicense.setWrapStyleWord(true);
370 jTextAreaLicense.setSelectionStart(0);
371 jTextAreaLicense.setSelectionEnd(0);
372 jTextAreaLicense.setToolTipText("The License for this Module.");
373 }
374 return jTextAreaLicense;
375 }
376
377 /**
378 This method initializes jTextAreaDescription
379
380 @return javax.swing.JTextArea jTextAreaDescription
381
382 **/
383 private JTextArea getJTextAreaDescription() {
384 if (jTextAreaDescription == null) {
385 jTextAreaDescription = new JTextArea();
386 jTextAreaDescription.setLineWrap(true);
387 jTextAreaDescription.addFocusListener(this);
388 jTextAreaDescription.setToolTipText("A verbose description of the module.");
389 jTextAreaDescription.setWrapStyleWord(true);
390 jTextAreaDescription.setSelectionStart(0);
391 jTextAreaDescription.setSelectionEnd(0);
392 }
393 return jTextAreaDescription;
394 }
395
396 /**
397 This method initializes jTextFieldSpecification
398
399 @return javax.swing.JTextField jTextFieldSpecification
400
401 **/
402 private JTextField getJTextFieldSpecification() {
403 if (jTextFieldSpecification == null) {
404 jTextFieldSpecification = new JTextField();
405
406 jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(320, 20));
407 jTextFieldSpecification.setText("FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052");
408 jTextFieldSpecification.setBorder(null);
409
410 jTextFieldSpecification.setSize(new java.awt.Dimension(320, 20));
411 jTextFieldSpecification.setLocation(new java.awt.Point(2, dialogHeight - 30));
412 jTextFieldSpecification.setEditable(false);
413 jTextFieldSpecification.addFocusListener(this);
414 }
415 return jTextFieldSpecification;
416 }
417
418 /**
419 This method initializes jButtonOk
420
421 @return javax.swing.JButton jButtonOk
422
423 **/
424 private JButton getJButtonOk() {
425 if (jButtonOk == null) {
426 jButtonOk = new JButton();
427 jButtonOk.setText("OK");
428 jButtonOk.setPreferredSize(new java.awt.Dimension(90, 20));
429 jButtonOk.setBounds(new java.awt.Rectangle(390, 455, 90, 20));
430 jButtonOk.addActionListener(this);
431 jButtonOk.setVisible(false);
432 }
433 return jButtonOk;
434 }
435
436 /**
437 This method initializes jButtonCancel
438
439 @return javax.swing.JButton jButtonCancel
440
441 **/
442 private JButton getJButtonCancel() {
443 if (jButtonCancel == null) {
444 jButtonCancel = new JButton();
445 jButtonCancel.setText("Cancel");
446 jButtonCancel.setBounds(new java.awt.Rectangle(390, 445, 90, 20));
447 jButtonCancel.addActionListener(this);
448 jButtonCancel.setPreferredSize(new java.awt.Dimension(90, 20));
449 jButtonCancel.setVisible(false);
450 }
451 return jButtonCancel;
452 }
453
454 /**
455 This method initializes jScrollPaneLicense
456
457 @return javax.swing.JScrollPane jScrollPaneLicense
458
459 **/
460 private JScrollPane getJScrollPaneLicense() {
461 if (jScrollPaneLicense == null) {
462 jScrollPaneLicense = new JScrollPane();
463 jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
464 jScrollPaneLicense.setSize(new java.awt.Dimension(320, 120));
465 jScrollPaneLicense.setLocation(new java.awt.Point(160, 305));
466 jScrollPaneLicense.setViewportView(getJTextAreaLicense());
467 jScrollPaneLicense.setPreferredSize(new java.awt.Dimension(320, 120));
468 }
469 return jScrollPaneLicense;
470 }
471
472 /**
473 This method initializes jScrollPaneDescription
474
475 @return javax.swing.JScrollPane jScrollPaneDescription
476
477 **/
478 private JScrollPane getJScrollPaneDescription() {
479 if (jScrollPaneDescription == null) {
480 jScrollPaneDescription = new JScrollPane();
481 jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
482 jScrollPaneDescription.setSize(new java.awt.Dimension(320, 120));
483 jScrollPaneDescription.setLocation(new java.awt.Point(160, 135));
484 jScrollPaneDescription.setViewportView(getJTextAreaDescription());
485 jScrollPaneDescription.setPreferredSize(new java.awt.Dimension(320, 120));
486 }
487 return jScrollPaneDescription;
488 }
489
490 /**
491 This method initializes jTextFieldAbstract
492
493 @return javax.swing.JTextField jTextFieldAbstract
494
495 **/
496 private JTextField getJTextFieldAbstract() {
497 if (jTextFieldAbstract == null) {
498 jTextFieldAbstract = new JTextField();
499 jTextFieldAbstract.setPreferredSize(new java.awt.Dimension(320, 20));
500 jTextFieldAbstract.setLocation(new java.awt.Point(160, 110));
501 jTextFieldAbstract.setSize(new java.awt.Dimension(320, 20));
502 jTextFieldAbstract.addFocusListener(this);
503 jTextFieldAbstract.setToolTipText("A one sentence description of this module.");
504 }
505 return jTextFieldAbstract;
506 }
507
508 /**
509 This method initializes jComboBoxModuleType
510
511 @return javax.swing.JComboBox jComboBoxModuleType
512
513 **/
514 private JComboBox getJComboBoxModuleType() {
515 if (jComboBoxModuleType == null) {
516 jComboBoxModuleType = new JComboBox();
517 jComboBoxModuleType.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
518 jComboBoxModuleType.setPreferredSize(new java.awt.Dimension(320, 20));
519 jComboBoxModuleType.addFocusListener(this);
520 }
521 return jComboBoxModuleType;
522 }
523
524 /**
525 This method initializes jTextFieldURL
526
527 @return javax.swing.JTextField
528
529 **/
530 private JTextField getJTextFieldURL() {
531 if (jTextFieldURL == null) {
532 jTextFieldURL = new JTextField();
533 jTextFieldURL.setPreferredSize(new java.awt.Dimension(320, 20));
534 jTextFieldURL.setLocation(new java.awt.Point(160, 430));
535 jTextFieldURL.setSize(new java.awt.Dimension(320, 20));
536 jTextFieldURL.addFocusListener(this);
537 jTextFieldURL.setToolTipText("A URL for the latest version of the license.");
538 }
539 return jTextFieldURL;
540 }
541
542 /**
543 This method initializes jScrollPane
544
545 @return javax.swing.JScrollPane
546
547 **/
548 private JScrollPane getJScrollPane() {
549 if (jScrollPane == null) {
550 jScrollPane = new JScrollPane();
551 jScrollPane.setViewportView(getJContentPane());
552 }
553 return jScrollPane;
554 }
555
556 /**
557 This method initializes jScrollPaneCopyright
558
559 @return javax.swing.JScrollPane
560
561 **/
562 private JScrollPane getJScrollPaneCopyright() {
563 if (jScrollPaneCopyright == null) {
564 jScrollPaneCopyright = new JScrollPane();
565 jScrollPaneCopyright.setBounds(new java.awt.Rectangle(160, 260, 320, 40));
566 jScrollPaneCopyright.setPreferredSize(new java.awt.Dimension(320, 40));
567 jScrollPaneCopyright.setViewportView(getJTextAreaCopyright());
568 jScrollPaneCopyright.setSize(new java.awt.Dimension(320, 40));
569 }
570 return jScrollPaneCopyright;
571 }
572
573 /**
574 This method initializes jTextAreaCopyright
575
576 @return javax.swing.JTextArea
577
578 **/
579 private JTextArea getJTextAreaCopyright() {
580 if (jTextAreaCopyright == null) {
581 jTextAreaCopyright = new JTextArea();
582 jTextAreaCopyright.setLineWrap(true);
583 jTextAreaCopyright.addFocusListener(this);
584 jTextAreaCopyright.setWrapStyleWord(true);
585 jTextAreaCopyright.setSelectionStart(0);
586 jTextAreaCopyright.setSelectionEnd(0);
587 jTextAreaCopyright.setBounds(new java.awt.Rectangle(0, 0, 320, 40));
588 jTextAreaCopyright.setToolTipText("One or more copyright lines.");
589 }
590 return jTextAreaCopyright;
591 }
592
593 /**
594 * This method initializes jComboBoxBinaryModule
595 *
596 * @return javax.swing.JComboBox
597 */
598 private JComboBox getJComboBoxBinaryModule() {
599 if (jComboBoxBinaryModule == null) {
600 jComboBoxBinaryModule = new JComboBox();
601 jComboBoxBinaryModule.setBounds(new java.awt.Rectangle(160, 480, 320, 20));
602 jComboBoxBinaryModule.setPreferredSize(new java.awt.Dimension(320, 20));
603 jComboBoxBinaryModule.addFocusListener(this);
604 jComboBoxBinaryModule.setToolTipText("<html>Modules are either source modules <br>"
605 + "which can be compiled or binary <br>"
606 + "modules which are linked. <br>"
607 + "A module cannot contain both. <br>"
608 + "The GUID numbers should be identical <br>"
609 + "for a binary and source MSA, <br>"
610 + "however the BINARY MSA should have <br>"
611 + "a higher version number.</html>");
612 }
613 return jComboBoxBinaryModule;
614 }
615
616 /**
617 * This method initializes jTextFieldOutputFileBasename
618 *
619 * @return javax.swing.JTextField
620 */
621 private JTextField getJTextFieldOutputFileBasename() {
622 if (jTextFieldOutputFileBasename == null) {
623 jTextFieldOutputFileBasename = new JTextField();
624 jTextFieldOutputFileBasename.setBounds(new java.awt.Rectangle(160, 455, 320, 20));
625 jTextFieldOutputFileBasename.setPreferredSize(new java.awt.Dimension(320, 20));
626 jTextFieldOutputFileBasename.addFocusListener(this);
627 jTextFieldOutputFileBasename.setToolTipText("Enter a single word for generated output file names.");
628 }
629 return jTextFieldOutputFileBasename;
630 }
631
632 /**
633 * This method initializes jComboBoxPcdIsDriver
634 *
635 * @return javax.swing.JComboBox
636 */
637 private JComboBox getJComboBoxPcdIsDriver() {
638 if (jComboBoxPcdIsDriver == null) {
639 jComboBoxPcdIsDriver = new JComboBox();
640 jComboBoxPcdIsDriver.setPreferredSize(new java.awt.Dimension(320, 20));
641 jComboBoxPcdIsDriver.setBounds(new java.awt.Rectangle(160, 530, 320, 20));
642 jComboBoxPcdIsDriver.addItemListener(this);
643 jComboBoxPcdIsDriver.setEnabled(false);
644 Tools.generateComboBoxByVector(jComboBoxPcdIsDriver, ed.getVPcdDriverTypes());
645 }
646 return jComboBoxPcdIsDriver;
647 }
648
649 /**
650 This is the default constructor
651
652 **/
653 public MsaHeader() {
654 super();
655 init();
656 this.setVisible(true);
657 }
658
659 /**
660 This is the override edit constructor
661
662 @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader
663
664 **/
665 public MsaHeader(OpeningModuleType inMsa) {
666 super();
667 this.omt = inMsa;
668 this.msa = omt.getXmlMsa();
669
670 //
671 // Set module definitions default value
672 //
673 if (msa.getModuleDefinitions() == null) {
674 ModuleDefinitionsDocument.ModuleDefinitions md = ModuleDefinitionsDocument.ModuleDefinitions.Factory
675 .newInstance();
676 md.setOutputFileBasename(msa.getMsaHeader().getModuleName());
677 md.setBinaryModule(false);
678 md.setSupportedArchitectures(ed.getVSupportedArchitectures());
679 msa.setModuleDefinitions(md);
680 }
681
682 //
683 // Init items of Header, Definitions and Externs
684 //
685 init(msa.getMsaHeader());
686 init(msa.getModuleDefinitions());
687 init(msa.getExterns());
688
689 this.setVisible(true);
690 this.setViewMode(false);
691 }
692
693 /**
694 Disable all components when the mode is view
695
696 @param isView true - The view mode; false - The non-view mode
697
698 **/
699 public void setViewMode(boolean isView) {
700 if (isView) {
701 this.jTextFieldBaseName.setEnabled(!isView);
702 this.jTextFieldGuid.setEnabled(!isView);
703 this.jTextFieldVersion.setEnabled(!isView);
704 this.jTextAreaLicense.setEnabled(!isView);
705 this.jTextAreaCopyright.setEnabled(!isView);
706 this.jTextAreaDescription.setEnabled(!isView);
707 this.jTextFieldSpecification.setEnabled(!isView);
708 this.jTextFieldAbstract.setEnabled(!isView);
709 this.jComboBoxModuleType.setEnabled(!isView);
710 this.jButtonCancel.setEnabled(!isView);
711 this.jButtonGenerateGuid.setEnabled(!isView);
712 this.jButtonOk.setEnabled(!isView);
713 }
714 }
715
716 /**
717 This method initializes this
718
719 **/
720 private void init() {
721 this.setSize(dialogWidth, dialogHeight);
722 this.setPreferredSize(new java.awt.Dimension(dialogWidth, dialogHeight));
723 this.setContentPane(getJScrollPane());
724 this.setTitle("Module Surface Area Header");
725 initFrame();
726 }
727
728 /**
729 This method initializes this
730 Fill values to all fields if these values are not empty
731
732 @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader
733
734 **/
735 private void init(MsaHeaderDocument.MsaHeader inMsaHeader) {
736 init();
737 if (inMsaHeader != null) {
738 setMsaHeader(inMsaHeader);
739 if (this.msaHeader.getModuleName() != null) {
740 this.jTextFieldBaseName.setText(this.msaHeader.getModuleName());
741 }
742 if (this.msaHeader.getModuleType() != null) {
743 this.jComboBoxModuleType.setSelectedItem(this.msaHeader.getModuleType().toString());
744 }
745 if (this.msaHeader.getGuidValue() != null) {
746 this.jTextFieldGuid.setText(this.msaHeader.getGuidValue());
747 }
748 if (this.msaHeader.getVersion() != null) {
749 this.jTextFieldVersion.setText(this.msaHeader.getVersion());
750 }
751 if (this.msaHeader.getAbstract() != null) {
752 this.jTextFieldAbstract.setText(this.msaHeader.getAbstract());
753 }
754 if (this.msaHeader.getDescription() != null) {
755 this.jTextAreaDescription.setText(this.msaHeader.getDescription());
756 jTextAreaDescription.setSelectionStart(0);
757 jTextAreaDescription.setSelectionEnd(0);
758 }
759 if (this.msaHeader.getCopyright() != null) {
760 this.jTextAreaCopyright.setText(this.msaHeader.getCopyright());
761 }
762 if (this.msaHeader.getLicense() != null) {
763 this.jTextAreaLicense.setText(this.msaHeader.getLicense().getStringValue());
764 jTextAreaLicense.setSelectionStart(0);
765 jTextAreaLicense.setSelectionEnd(0);
766 }
767 if (this.msaHeader.getLicense() != null && this.msaHeader.getLicense().getURL() != null) {
768 this.jTextFieldURL.setText(this.msaHeader.getLicense().getURL());
769 }
770 if (this.msaHeader.getSpecification() != null) {
771 this.jTextFieldSpecification.setText(this.msaHeader.getSpecification());
772 }
773 }
774 }
775
776 /**
777 This method initializes this
778 Fill values to all fields if these values are not empty
779
780 @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader
781
782 **/
783 private void init(ModuleDefinitionsDocument.ModuleDefinitions inMd) {
784 if (inMd != null) {
785 this.md = inMd;
786 if (md.getSupportedArchitectures() != null) {
787 this.setSelectedItems(Tools.convertListToVector(md.getSupportedArchitectures()));
788 }
789 if (md.getBinaryModule()) {
790 this.jComboBoxBinaryModule.setSelectedIndex(1);
791 } else {
792 this.jComboBoxBinaryModule.setSelectedIndex(0);
793 }
794 if (md.getOutputFileBasename() != null) {
795 this.jTextFieldOutputFileBasename.setText(md.getOutputFileBasename());
796 }
797 }
798 }
799
800 /**
801 This method initializes this
802 Fill values to all fields if these values are not empty
803
804 @param inEx The input data of ExternsDocument.Externs
805
806 **/
807 private void init(ExternsDocument.Externs inEx) {
808 if (inEx != null) {
809 this.ex = inEx;
810 if (ex.getPcdIsDriver() != null) {
811 this.jCheckBoxPcd.setSelected(true);
812 this.jComboBoxPcdIsDriver.setEnabled(true);
813 this.jComboBoxPcdIsDriver.setSelectedItem(ex.getPcdIsDriver());
814 }
815 this.jCheckBoxFlashMap.setSelected(ex.getTianoR8FlashMapH());
816 }
817 }
818
819 /**
820 This method initializes jContentPane
821
822 @return javax.swing.JPanel jContentPane
823
824 **/
825 private JPanel getJContentPane() {
826 if (jContentPane == null) {
827
828 jLabelURL = new JLabel();
829 jLabelURL.setText("License URL");
830 jLabelURL.setLocation(new java.awt.Point(15, 430));
831 jLabelURL.setSize(new java.awt.Dimension(140, 20));
832 jLabelBaseName = new JLabel();
833 jLabelBaseName.setText("Module Name");
834 jLabelBaseName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
835 jLabelModuleType = new JLabel();
836 jLabelModuleType.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
837 jLabelModuleType.setText("Module Type");
838 jLabelGuid = new JLabel();
839 jLabelGuid.setText("Guid Value");
840 jLabelGuid.setLocation(new java.awt.Point(15, 60));
841 jLabelGuid.setSize(new java.awt.Dimension(140, 20));
842 jLabelVersion = new JLabel();
843 jLabelVersion.setText("Version");
844 jLabelVersion.setLocation(new java.awt.Point(15, 85));
845 jLabelVersion.setSize(new java.awt.Dimension(140, 20));
846 jLabelAbstract = new JLabel();
847 jLabelAbstract.setText("Abstract");
848 jLabelAbstract.setLocation(new java.awt.Point(15, 110));
849 jLabelAbstract.setSize(new java.awt.Dimension(140, 20));
850 jLabelDescription = new JLabel();
851 jLabelDescription.setText("Description");
852 jLabelDescription.setLocation(new java.awt.Point(15, 135));
853 jLabelDescription.setSize(new java.awt.Dimension(140, 20));
854 jLabelCopyright = new JLabel();
855 jLabelCopyright.setText("Copyright");
856 jLabelCopyright.setLocation(new java.awt.Point(15, 260));
857 jLabelCopyright.setSize(new java.awt.Dimension(140, 20));
858 jLabelLicense = new JLabel();
859 jLabelLicense.setText("License");
860 jLabelLicense.setLocation(new java.awt.Point(15, 305));
861 jLabelLicense.setSize(new java.awt.Dimension(140, 20));
862 jLabelOutputFileBasename = new JLabel();
863 jLabelOutputFileBasename.setBounds(new java.awt.Rectangle(15, 455, 140, 20));
864 jLabelOutputFileBasename.setText("Output File Basename");
865 jLabelBinaryModule = new JLabel();
866 jLabelBinaryModule.setBounds(new java.awt.Rectangle(15, 480, 140, 20));
867 jLabelBinaryModule.setText("Binary Module");
868 jLabelArch = new JLabel();
869 jLabelArch.setBounds(new java.awt.Rectangle(15, 505, 140, 20));
870 jLabelArch.setText("Supported Architectures");
871 jLabelSpecification = new JLabel();
872 jLabelSpecification.setText("Specification");
873 jLabelSpecification.setLocation(new java.awt.Point(14, 530));
874 jLabelSpecification.setSize(new java.awt.Dimension(140, 20));
875
876 jContentPane = new JPanel();
877 jContentPane.setLayout(null);
878 jContentPane.setPreferredSize(new java.awt.Dimension(dialogWidth - 10, dialogHeight - 10));
879
880 jContentPane.addFocusListener(this);
881
882 jContentPane.add(jLabelBaseName, null);
883 jContentPane.add(getJTextFieldBaseName(), null);
884 jContentPane.add(jLabelGuid, null);
885 jContentPane.add(getJTextFieldGuid(), null);
886 jContentPane.add(jLabelVersion, null);
887 jContentPane.add(getJTextFieldVersion(), null);
888 jContentPane.add(getJButtonGenerateGuid(), null);
889 jContentPane.add(jLabelLicense, null);
890 jContentPane.add(jLabelCopyright, null);
891 jContentPane.add(jLabelDescription, null);
892 // jContentPane.add(jLabelSpecification, null);
893 jContentPane.add(getJTextFieldSpecification(), null);
894 jContentPane.add(getJButtonOk(), null);
895 jContentPane.add(getJButtonCancel(), null);
896 jContentPane.add(getJScrollPaneLicense(), null);
897 jContentPane.add(getJScrollPaneDescription(), null);
898 jContentPane.add(jLabelAbstract, null);
899 jContentPane.add(getJTextFieldAbstract(), null);
900 jContentPane.add(jLabelModuleType, null);
901 jContentPane.add(getJComboBoxModuleType(), null);
902 jContentPane.add(jLabelURL, null);
903 jContentPane.add(getJTextFieldURL(), null);
904 jContentPane.add(jLabelOutputFileBasename, null);
905 jContentPane.add(getJTextFieldOutputFileBasename(), null);
906 jContentPane.add(jLabelBinaryModule, null);
907 jContentPane.add(getJComboBoxBinaryModule(), null);
908 jContentPane.add(jLabelArch, null);
909
910 jStarLabel1 = new StarLabel();
911 jStarLabel1.setLocation(new java.awt.Point(0, 10));
912 jStarLabel2 = new StarLabel();
913 jStarLabel2.setLocation(new java.awt.Point(0, 35));
914 jStarLabel4 = new StarLabel();
915 jStarLabel4.setLocation(new java.awt.Point(0, 60));
916 jStarLabel5 = new StarLabel();
917 jStarLabel5.setLocation(new java.awt.Point(0, 85));
918 jStarLabel6 = new StarLabel();
919 jStarLabel6.setLocation(new java.awt.Point(0, 135));
920 jStarLabel7 = new StarLabel();
921 jStarLabel7.setLocation(new java.awt.Point(0, 260));
922 jStarLabel8 = new StarLabel();
923 jStarLabel8.setLocation(new java.awt.Point(0, 305));
924 jStarLabel10 = new StarLabel();
925 jStarLabel10.setLocation(new java.awt.Point(0, 110));
926 jStarLabel12 = new StarLabel();
927 jStarLabel12.setLocation(new java.awt.Point(0, 455));
928 jStarLabel13 = new StarLabel();
929 jStarLabel13.setLocation(new java.awt.Point(0, 480));
930 jStarLabel14 = new StarLabel();
931 jStarLabel14.setLocation(new java.awt.Point(0, 505));
932 // jStarLabel15 = new StarLabel();
933 // jStarLabel15.setLocation(new java.awt.Point(0, 530));
934
935 jContentPane.add(jStarLabel1, null);
936 jContentPane.add(jStarLabel2, null);
937 jContentPane.add(jStarLabel4, null);
938 jContentPane.add(jStarLabel5, null);
939 jContentPane.add(jStarLabel6, null);
940 jContentPane.add(jStarLabel7, null);
941 jContentPane.add(jStarLabel8, null);
942 jContentPane.add(jStarLabel10, null);
943 jContentPane.add(jStarLabel12, null);
944 jContentPane.add(jStarLabel13, null);
945 jContentPane.add(jStarLabel14, null);
946 // jContentPane.add(jStarLabel15, null);
947 jContentPane.add(getJScrollPaneCopyright(), null);
948
949 jContentPane.add(getJCheckBoxIa32(), null);
950 jContentPane.add(getJCheckBoxX64(), null);
951 jContentPane.add(getJCheckBoxIpf(), null);
952 jContentPane.add(getJCheckBoxEbc(), null);
953 jContentPane.add(getJCheckBoxArm(), null);
954 jContentPane.add(getJCheckBoxPpc(), null);
955
956 jContentPane.add(getJCheckBoxPcd(), null);
957 jContentPane.add(getJComboBoxPcdIsDriver(), null);
958 jContentPane.add(getJCheckBoxFlashMap(), null);
959 }
960 return jContentPane;
961 }
962
963 /* (non-Javadoc)
964 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
965 *
966 * Override actionPerformed to listen all actions
967 *
968 */
969 public void actionPerformed(ActionEvent arg0) {
970 if (arg0.getSource() == jButtonOk) {
971 if (this.check()) {
972 this.save();
973 } else {
974 return;
975 }
976 this.setEdited(true);
977 this.dispose();
978 }
979
980 if (arg0.getSource() == jButtonCancel) {
981 this.setEdited(false);
982 }
983
984 if (arg0.getSource() == jButtonGenerateGuid) {
985 jTextFieldGuid.setText(Tools.generateUuidString());
986 jTextFieldGuid.requestFocus();
987 jButtonGenerateGuid.requestFocus();
988 }
989
990 if (arg0.getSource() == this.jCheckBoxPcd) {
991 this.jComboBoxPcdIsDriver.setEnabled(this.jCheckBoxPcd.isSelected());
992 }
993 }
994
995 /**
996 Data validation for all fields
997
998 @retval true - All datas are valid
999 @retval false - At least one data is invalid
1000
1001 **/
1002 public boolean check() {
1003 //
1004 // Check if all required fields are not empty
1005 // and check if all data fields values are valid
1006 //
1007
1008 //
1009 // Check Base Name
1010 //
1011 if (isEmpty(this.jTextFieldBaseName.getText())) {
1012 Log.wrn("Update Msa Header", "Name must be entered!");
1013 //this.jTextFieldBaseName.requestFocus();
1014 return false;
1015 }
1016 if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
1017 Log.wrn("Update Msa Header", "Incorrect data type for Name, it must start with an alpha character!");
1018 //this.jTextFieldBaseName.requestFocus();
1019 return false;
1020 }
1021
1022 //
1023 // Check Guid
1024 //
1025 if (isEmpty(this.jTextFieldGuid.getText())) {
1026 Log.wrn("Update Msa Header", "The Guid Value must be entered!");
1027 //this.jTextFieldGuid.requestFocus();
1028 return false;
1029 }
1030 if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
1031 Log.wrn("Update Msa Header", "Incorrect data type for Guid, it must be registry format, 8-4-4-4-12");
1032 //this.jTextFieldGuid.requestFocus();
1033 return false;
1034 }
1035
1036 //
1037 // Check Version
1038 //
1039 if (isEmpty(this.jTextFieldVersion.getText())) {
1040 Log.wrn("Update Msa Header", "Version must be entered!");
1041 //this.jTextFieldVersion.requestFocus();
1042 return false;
1043 }
1044 if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {
1045 Log.wrn("Update Msa Header", "Incorrect data type for Version, it must start with a digit.");
1046 //this.jTextFieldVersion.requestFocus();
1047 return false;
1048 }
1049
1050 //
1051 // Check Abstact
1052 //
1053 if (isEmpty(this.jTextFieldAbstract.getText())) {
1054 Log.wrn("Update Msa Header", "Abstract must be entered!");
1055 //this.jTextFieldAbstract.requestFocus();
1056 return false;
1057 }
1058 if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {
1059 Log.wrn("Update Msa Header",
1060 "Incorrect data type for Abstract, is should be a sentence describing the module.");
1061 //this.jTextFieldAbstract.requestFocus();
1062 return false;
1063 }
1064
1065 //
1066 // Check Description
1067 //
1068 if (isEmpty(this.jTextAreaDescription.getText())) {
1069 Log.wrn("Update Msa Header", "Description must be entered!");
1070 //this.jTextAreaDescription.requestFocus();
1071 return false;
1072 }
1073
1074 //
1075 // Check Copyright
1076 //
1077 if (isEmpty(this.jTextAreaCopyright.getText())) {
1078 Log.wrn("Update Msa Header", "Copyright must be entered!");
1079 //this.jTextFieldCopyright.requestFocus();
1080 return false;
1081 }
1082
1083 //
1084 // Check License
1085 //
1086 if (isEmpty(this.jTextAreaLicense.getText())) {
1087 Log.wrn("Update Msa Header", "License must be entered!");
1088 //this.jTextAreaLicense.requestFocus();
1089 return false;
1090 }
1091
1092 //
1093 // Check Specification
1094 //
1095 if (isEmpty(this.jTextFieldSpecification.getText())) {
1096 Log.wrn("Update Msa Header", "Specification must exist.");
1097 //this.jTextFieldSpecification.requestFocus();
1098 return false;
1099 }
1100 if (!DataValidation.isSpecification(this.jTextFieldSpecification.getText())) {
1101 // TODO Add code to check the specification number.
1102 // Future releases of Schema may require that we process these files
1103 // differently.
1104 Log.wrn("Update Msa Header", "Incorrect data type for Specification");
1105 //this.jTextFieldSpecification.requestFocus();
1106 return false;
1107 }
1108
1109 return true;
1110 }
1111
1112 /**
1113 Save all components of Msa Header
1114 if exists msaHeader, set the value directly
1115 if not exists msaHeader, new an instance first
1116
1117 **/
1118 public void save() {
1119 try {
1120 msaHeader.setSpecification(this.jTextFieldSpecification.getText());
1121 msa.setMsaHeader(msaHeader);
1122 msa.setModuleDefinitions(md);
1123 this.omt.setSaved(false);
1124 } catch (Exception e) {
1125 Log.wrn("Save Module", e.getMessage());
1126 Log.err("Save Module", e.getMessage());
1127 }
1128 }
1129
1130 /**
1131 This method initializes Module type and Compontent type
1132
1133 **/
1134 private void initFrame() {
1135 EnumerationData ed = new EnumerationData();
1136 Tools.generateComboBoxByVector(jComboBoxModuleType, ed.getVModuleType());
1137 Tools.generateComboBoxByVector(jComboBoxBinaryModule, ed.getVBoolean());
1138 this.setSelectedItems(ed.getVSupportedArchitectures());
1139 }
1140
1141 /**
1142 Get MsaHeaderDocument.MsaHeader
1143
1144 @return MsaHeaderDocument.MsaHeader
1145
1146 **/
1147 public MsaHeaderDocument.MsaHeader getMsaHeader() {
1148 return msaHeader;
1149 }
1150
1151 /**
1152 Set MsaHeaderDocument.MsaHeader
1153
1154 @param msaHeader The input data of MsaHeaderDocument.MsaHeader
1155
1156 **/
1157 public void setMsaHeader(MsaHeaderDocument.MsaHeader msaHeader) {
1158 this.msaHeader = msaHeader;
1159 }
1160
1161 /* (non-Javadoc)
1162 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
1163 *
1164 * Override componentResized to resize all components when frame's size is changed
1165 */
1166 public void componentResized(ComponentEvent arg0) {
1167 int intCurrentWidth = this.getJContentPane().getWidth();
1168 int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
1169
1170 Tools.resizeComponentWidth(this.jTextFieldBaseName, intCurrentWidth, intPreferredWidth);
1171 Tools.resizeComponentWidth(this.jTextFieldGuid, intCurrentWidth, intPreferredWidth);
1172 Tools.resizeComponentWidth(this.jTextFieldVersion, intCurrentWidth, intPreferredWidth);
1173 Tools.resizeComponentWidth(this.jScrollPaneLicense, intCurrentWidth, intPreferredWidth);
1174 Tools.resizeComponentWidth(this.jTextFieldURL, intCurrentWidth, intPreferredWidth);
1175 Tools.resizeComponentWidth(this.jScrollPaneCopyright, intCurrentWidth, intPreferredWidth);
1176 Tools.resizeComponentWidth(this.jScrollPaneDescription, intCurrentWidth, intPreferredWidth);
1177 Tools.resizeComponentWidth(this.jTextFieldSpecification, intCurrentWidth, intPreferredWidth);
1178 Tools.resizeComponentWidth(this.jTextFieldAbstract, intCurrentWidth, intPreferredWidth);
1179 Tools.resizeComponentWidth(this.jComboBoxModuleType, intCurrentWidth, intPreferredWidth);
1180 Tools.resizeComponentWidth(this.jComboBoxBinaryModule, intCurrentWidth, intPreferredWidth);
1181 Tools.resizeComponentWidth(this.jTextFieldOutputFileBasename, intCurrentWidth, intPreferredWidth);
1182 Tools.resizeComponentWidth(this.jComboBoxPcdIsDriver, intCurrentWidth, intPreferredWidth);
1183
1184 Tools.relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth,
1185 DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
1186 }
1187
1188 public void focusLost(FocusEvent arg0) {
1189 if (this.msaHeader == null) {
1190 msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance();
1191 }
1192
1193 //
1194 // Check BaseName
1195 //
1196 if (arg0.getSource() == this.jTextFieldBaseName) {
1197 if (isEmpty(this.jTextFieldBaseName.getText())) {
1198 Log.wrn("Update Msa Header", "The Name must be entered!");
1199 //this.jTextFieldBaseName.requestFocus();
1200 return;
1201 }
1202 if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
1203 Log.wrn("Update Msa Header", "Incorrect data type for Name, it must begin with an alpha character.");
1204 //this.jTextFieldBaseName.requestFocus();
1205 return;
1206 }
1207 if (!this.jTextFieldBaseName.getText().equals(msaHeader.getModuleName())) {
1208 this.msaHeader.setModuleName(this.jTextFieldBaseName.getText());
1209 } else {
1210 return;
1211 }
1212 }
1213
1214 //
1215 // Check Module Type
1216 //
1217 if (arg0.getSource() == this.jComboBoxModuleType) {
1218 if (!jComboBoxModuleType.getSelectedItem().toString().equals(msaHeader.getModuleType().toString())) {
1219 msaHeader.setModuleType(ModuleTypeDef.Enum.forString(jComboBoxModuleType.getSelectedItem().toString()));
1220 } else {
1221 return;
1222 }
1223 }
1224
1225 //
1226 // Check Guid
1227 //
1228 if (arg0.getSource() == this.jTextFieldGuid) {
1229 if (isEmpty(this.jTextFieldGuid.getText())) {
1230 Log.wrn("Update Msa Header", "Guid must be entered!");
1231 //this.jTextFieldGuid.requestFocus();
1232 return;
1233 }
1234 if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
1235 Log.wrn("Update Msa Header", "Incorrect data type for Guid, it must be registry format. (8-4-4-4-12)");
1236 //this.jTextFieldGuid.requestFocus();
1237 return;
1238 }
1239 if (!this.jTextFieldGuid.getText().equals(msaHeader.getGuidValue())) {
1240 this.msaHeader.setGuidValue(this.jTextFieldGuid.getText());
1241 } else {
1242 return;
1243 }
1244 }
1245
1246 //
1247 // Check Version
1248 //
1249 if (arg0.getSource() == this.jTextFieldVersion) {
1250 if (isEmpty(this.jTextFieldVersion.getText())) {
1251 Log.wrn("Update Msa Header", "Version must be entered!");
1252 //this.jTextFieldVersion.requestFocus();
1253 return;
1254 }
1255 if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {
1256 Log.wrn("Update Msa Header", "Incorrect data type for Version, it must start with a digit.");
1257 //this.jTextFieldVersion.requestFocus();
1258 return;
1259 }
1260 if (!this.jTextFieldVersion.getText().equals(msaHeader.getVersion())) {
1261 this.msaHeader.setVersion(this.jTextFieldVersion.getText());
1262 } else {
1263 return;
1264 }
1265 }
1266
1267 //
1268 // Check Abstact
1269 //
1270 if (arg0.getSource() == this.jTextFieldAbstract) {
1271 if (isEmpty(this.jTextFieldAbstract.getText())) {
1272 Log.wrn("Update Msa Header", "Abstract must be entered!");
1273 //this.jTextFieldAbstract.requestFocus();
1274 return;
1275 }
1276 if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {
1277 Log.wrn("Update Msa Header", "Incorrect data type for Abstract, it must be sentence.");
1278 //this.jTextFieldAbstract.requestFocus();
1279 return;
1280 }
1281 if (!this.jTextFieldAbstract.getText().equals(msaHeader.getAbstract())) {
1282 this.msaHeader.setAbstract(this.jTextFieldAbstract.getText());
1283 } else {
1284 return;
1285 }
1286 }
1287
1288 //
1289 // Check Description
1290 //
1291 if (arg0.getSource() == this.jTextAreaDescription) {
1292 if (isEmpty(this.jTextAreaDescription.getText())) {
1293 Log.wrn("Update Msa Header", "Description must be entered!");
1294 //this.jTextAreaDescription.requestFocus();
1295 return;
1296 }
1297 if (!this.jTextAreaDescription.getText().equals(msaHeader.getDescription())) {
1298 this.msaHeader.setDescription(this.jTextAreaDescription.getText());
1299 } else {
1300 return;
1301 }
1302 }
1303
1304 //
1305 // Check Copyright
1306 //
1307 if (arg0.getSource() == this.jTextAreaCopyright) {
1308 if (isEmpty(this.jTextAreaCopyright.getText())) {
1309 Log.wrn("Update Msa Header", "Copyright must be entered!");
1310 //this.jTextFieldCopyright.requestFocus();
1311 return;
1312 }
1313 if (!this.jTextAreaCopyright.getText().equals(msaHeader.getCopyright())) {
1314 this.msaHeader.setCopyright(this.jTextAreaCopyright.getText());
1315 } else {
1316 return;
1317 }
1318 }
1319
1320 //
1321 // Check License
1322 //
1323 if (arg0.getSource() == this.jTextAreaLicense) {
1324 if (isEmpty(this.jTextAreaLicense.getText())) {
1325 Log.wrn("Update Msa Header", "License must be entered!");
1326 //this.jTextAreaLicense.requestFocus();
1327 return;
1328 }
1329 if (this.msaHeader.getLicense() != null) {
1330 if (!this.jTextAreaLicense.getText().equals(msaHeader.getLicense().getStringValue())) {
1331 this.msaHeader.getLicense().setStringValue(this.jTextAreaLicense.getText());
1332 } else {
1333 return;
1334 }
1335 } else {
1336 License mLicense = License.Factory.newInstance();
1337 mLicense.setStringValue(this.jTextAreaLicense.getText());
1338 this.msaHeader.setLicense(mLicense);
1339 }
1340 }
1341
1342 //
1343 // Check License URL
1344 //
1345 if (arg0.getSource() == this.jTextFieldURL) {
1346 if (!isEmpty(this.jTextFieldURL.getText())) {
1347 if (this.msaHeader.getLicense() == null) {
1348 License mLicense = License.Factory.newInstance();
1349 mLicense.setURL(this.jTextFieldURL.getText());
1350 this.msaHeader.setLicense(mLicense);
1351 } else {
1352 if (!this.jTextFieldURL.getText().equals(msaHeader.getLicense().getURL())) {
1353 this.msaHeader.getLicense().setURL(this.jTextFieldURL.getText());
1354 } else {
1355 return;
1356 }
1357 }
1358 }
1359 }
1360
1361 //
1362 // Check Output File Basename
1363 //
1364 if (arg0.getSource() == this.jTextFieldOutputFileBasename) {
1365 if (isEmpty(this.jTextFieldOutputFileBasename.getText())) {
1366 Log.wrn("Update Msa Header", "Output File Basename must be entered!");
1367 // jTextFieldOutputFileBasename.removeFocusListener(this);
1368 // jTextFieldOutputFileBasename.requestFocus();
1369 // jTextFieldOutputFileBasename.addFocusListener(this);
1370 return;
1371 }
1372 if (!this.jTextFieldOutputFileBasename.getText().equals(md.getOutputFileBasename())) {
1373 this.md.setOutputFileBasename(this.jTextFieldOutputFileBasename.getText());
1374 } else {
1375 return;
1376 }
1377 }
1378
1379 //
1380 // Check Binary Module Type
1381 //
1382 if (arg0.getSource() == this.jComboBoxBinaryModule) {
1383 if (jComboBoxBinaryModule.getSelectedItem().toString().equals(DataType.TRUE)) {
1384 if (md.getBinaryModule()) {
1385 return;
1386 } else {
1387 md.setBinaryModule(true);
1388 }
1389 } else if (jComboBoxBinaryModule.getSelectedItem().toString().equals(DataType.FALSE)) {
1390 if (md.getBinaryModule()) {
1391 md.setBinaryModule(false);
1392 } else {
1393 return;
1394 }
1395 }
1396 }
1397
1398 //
1399 // Check Supported Arch
1400 //
1401 if (arg0.getSource() == this.jCheckBoxArm || arg0.getSource() == this.jCheckBoxEbc
1402 || arg0.getSource() == this.jCheckBoxIa32 || arg0.getSource() == this.jCheckBoxIpf
1403 || arg0.getSource() == this.jCheckBoxPpc || arg0.getSource() == this.jCheckBoxX64) {
1404 if (!this.getSelectedItemsString().equals(md.getSupportedArchitectures().toString())) {
1405 md.setSupportedArchitectures(this.getSelectedItemsVector());
1406 } else {
1407 return;
1408 }
1409 }
1410
1411 //
1412 // Check Pcd is Driver
1413 //
1414 if (arg0.getSource() == this.jCheckBoxPcd) {
1415 if ((this.ex == null) && this.jCheckBoxPcd.isSelected()) {
1416 this.ex = ExternsDocument.Externs.Factory.newInstance();
1417 this.ex.setPcdIsDriver(PcdDriverTypes.Enum.forString(this.jComboBoxPcdIsDriver.getSelectedItem()
1418 .toString()));
1419 this.msa.setExterns(this.ex);
1420 }
1421
1422 if ((this.ex != null) && (this.ex.getPcdIsDriver() == null) && this.jCheckBoxPcd.isSelected()) {
1423 this.ex.setPcdIsDriver(PcdDriverTypes.Enum.forString(this.jComboBoxPcdIsDriver.getSelectedItem()
1424 .toString()));
1425 this.msa.setExterns(this.ex);
1426 }
1427
1428 if ((this.ex != null) && (this.ex.getPcdIsDriver() != null)) {
1429 if (this.jCheckBoxPcd.isSelected()
1430 && !this.jComboBoxPcdIsDriver.getSelectedItem().toString().equals(
1431 this.ex.getPcdIsDriver()
1432 .toString())) {
1433 this.ex.setPcdIsDriver(PcdDriverTypes.Enum.forString(this.jComboBoxPcdIsDriver.getSelectedItem()
1434 .toString()));
1435 this.msa.setExterns(this.ex);
1436 }
1437 if (!this.jCheckBoxPcd.isSelected()) {
1438 ExternsDocument.Externs newEx = ExternsDocument.Externs.Factory.newInstance();
1439 if (this.ex.getExternList() != null) {
1440 for (int index = 0; index < this.ex.getExternList().size(); index++) {
1441 newEx.addNewExtern();
1442 newEx.setExternArray(index, this.ex.getExternArray(index));
1443 }
1444 }
1445 if (this.ex.getSpecificationList() != null) {
1446 for (int index = 0; index < this.ex.getSpecificationList().size(); index++) {
1447 newEx.addNewSpecification();
1448 newEx.setSpecificationArray(index, this.ex.getSpecificationArray(index));
1449 }
1450 }
1451 if (this.ex.getTianoR8FlashMapH()) {
1452 newEx.setTianoR8FlashMapH(this.ex.getTianoR8FlashMapH());
1453 }
1454 this.ex = newEx;
1455 this.msa.setExterns(this.ex);
1456 }
1457 }
1458 }
1459
1460 //
1461 // Check Flash Map
1462 //
1463 if (arg0.getSource() == this.jCheckBoxFlashMap) {
1464 if ((this.ex == null) && this.jCheckBoxFlashMap.isSelected()) {
1465 this.ex = ExternsDocument.Externs.Factory.newInstance();
1466 this.ex.setTianoR8FlashMapH(this.jCheckBoxFlashMap.isSelected());
1467 this.msa.setExterns(this.ex);
1468 }
1469
1470 if ((this.ex != null) && this.jCheckBoxFlashMap.isSelected()) {
1471 this.ex.setTianoR8FlashMapH(this.jCheckBoxFlashMap.isSelected());
1472 this.msa.setExterns(this.ex);
1473 }
1474
1475 if ((this.ex != null) && !this.jCheckBoxFlashMap.isSelected()) {
1476 ExternsDocument.Externs newEx = ExternsDocument.Externs.Factory.newInstance();
1477 if (this.ex.getExternList() != null) {
1478 for (int index = 0; index < this.ex.getExternList().size(); index++) {
1479 newEx.addNewExtern();
1480 newEx.setExternArray(index, this.ex.getExternArray(index));
1481 }
1482 }
1483 if (this.ex.getSpecificationList() != null) {
1484 for (int index = 0; index < this.ex.getSpecificationList().size(); index++) {
1485 newEx.addNewSpecification();
1486 newEx.setSpecificationArray(index, this.ex.getSpecificationArray(index));
1487 }
1488 }
1489 if (this.ex.getPcdIsDriver() != null) {
1490 newEx.setPcdIsDriver(this.ex.getPcdIsDriver());
1491 }
1492 this.ex = newEx;
1493 this.msa.setExterns(this.ex);
1494 }
1495 }
1496
1497 this.save();
1498 }
1499
1500 private Vector<String> getSelectedItemsVector() {
1501 Vector<String> v = new Vector<String>();
1502 if (this.jCheckBoxIa32.isSelected()) {
1503 v.addElement(jCheckBoxIa32.getText());
1504 }
1505 if (this.jCheckBoxX64.isSelected()) {
1506 v.addElement(jCheckBoxX64.getText());
1507 }
1508 if (this.jCheckBoxIpf.isSelected()) {
1509 v.addElement(jCheckBoxIpf.getText());
1510 }
1511 if (this.jCheckBoxEbc.isSelected()) {
1512 v.addElement(jCheckBoxEbc.getText());
1513 }
1514 if (this.jCheckBoxArm.isSelected()) {
1515 v.addElement(jCheckBoxArm.getText());
1516 }
1517 if (this.jCheckBoxPpc.isSelected()) {
1518 v.addElement(jCheckBoxPpc.getText());
1519 }
1520 return v;
1521 }
1522
1523 private String getSelectedItemsString() {
1524 String s = "";
1525 if (this.jCheckBoxIa32.isSelected()) {
1526 s = s + jCheckBoxIa32.getText() + " ";
1527 }
1528 if (this.jCheckBoxX64.isSelected()) {
1529 s = s + jCheckBoxX64.getText() + " ";
1530 }
1531 if (this.jCheckBoxIpf.isSelected()) {
1532 s = s + jCheckBoxIpf.getText() + " ";
1533 }
1534 if (this.jCheckBoxEbc.isSelected()) {
1535 s = s + jCheckBoxEbc.getText() + " ";
1536 }
1537 if (this.jCheckBoxArm.isSelected()) {
1538 s = s + jCheckBoxArm.getText() + " ";
1539 }
1540 if (this.jCheckBoxPpc.isSelected()) {
1541 s = s + jCheckBoxPpc.getText() + " ";
1542 }
1543 return s.trim();
1544 }
1545
1546 private void setAllItemsSelected(boolean isSelected) {
1547 this.jCheckBoxIa32.setSelected(isSelected);
1548 this.jCheckBoxX64.setSelected(isSelected);
1549 this.jCheckBoxIpf.setSelected(isSelected);
1550 this.jCheckBoxEbc.setSelected(isSelected);
1551 this.jCheckBoxArm.setSelected(isSelected);
1552 this.jCheckBoxPpc.setSelected(isSelected);
1553 }
1554
1555 private void setSelectedItems(Vector<String> v) {
1556 setAllItemsSelected(false);
1557 if (v != null) {
1558 for (int index = 0; index < v.size(); index++) {
1559 if (v.get(index).equals(this.jCheckBoxIa32.getText())) {
1560 this.jCheckBoxIa32.setSelected(true);
1561 continue;
1562 }
1563 if (v.get(index).equals(this.jCheckBoxIpf.getText())) {
1564 this.jCheckBoxIpf.setSelected(true);
1565 continue;
1566 }
1567 if (v.get(index).equals(this.jCheckBoxX64.getText())) {
1568 this.jCheckBoxX64.setSelected(true);
1569 continue;
1570 }
1571 if (v.get(index).equals(this.jCheckBoxEbc.getText())) {
1572 this.jCheckBoxEbc.setSelected(true);
1573 continue;
1574 }
1575 if (v.get(index).equals(this.jCheckBoxArm.getText())) {
1576 this.jCheckBoxArm.setSelected(true);
1577 continue;
1578 }
1579 if (v.get(index).equals(this.jCheckBoxPpc.getText())) {
1580 this.jCheckBoxPpc.setSelected(true);
1581 continue;
1582 }
1583 }
1584 }
1585 }
1586
1587 /**
1588 * This method initializes jCheckBoxPcd
1589 *
1590 * @return javax.swing.JCheckBox
1591 */
1592 private JCheckBox getJCheckBoxPcd() {
1593 if (jCheckBoxPcd == null) {
1594 jCheckBoxPcd = new JCheckBox();
1595 jCheckBoxPcd.setBounds(new java.awt.Rectangle(0, 530, 140, 20));
1596 jCheckBoxPcd.setText("Is this a PCD Driver?");
1597 jCheckBoxPcd.addFocusListener(this);
1598 jCheckBoxPcd.addActionListener(this);
1599 }
1600 return jCheckBoxPcd;
1601 }
1602
1603 /**
1604 * This method initializes jCheckBoxFlashMap
1605 *
1606 * @return javax.swing.JCheckBox
1607 */
1608 private JCheckBox getJCheckBoxFlashMap() {
1609 if (jCheckBoxFlashMap == null) {
1610 jCheckBoxFlashMap = new JCheckBox();
1611 jCheckBoxFlashMap.setBounds(new java.awt.Rectangle(0, 555, 480, 20));
1612 jCheckBoxFlashMap.setText("Are you using a legacy FlashMap header file?");
1613 jCheckBoxFlashMap.addFocusListener(this);
1614 }
1615 return jCheckBoxFlashMap;
1616 }
1617 }