]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java
1. Change ToolCode from text field to drop down list, and user can enter their custom...
[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
22 import javax.swing.JButton;
23 import javax.swing.JComboBox;
24 import javax.swing.JLabel;
25 import javax.swing.JPanel;
26 import javax.swing.JScrollPane;
27 import javax.swing.JTextArea;
28 import javax.swing.JTextField;
29
30 import org.tianocore.ModuleDefinitionsDocument;
31 import org.tianocore.ModuleSurfaceAreaDocument;
32 import org.tianocore.ModuleTypeDef;
33 import org.tianocore.MsaHeaderDocument;
34 import org.tianocore.LicenseDocument.License;
35 import org.tianocore.frameworkwizard.common.DataType;
36 import org.tianocore.frameworkwizard.common.DataValidation;
37 import org.tianocore.frameworkwizard.common.EnumerationData;
38 import org.tianocore.frameworkwizard.common.Log;
39 import org.tianocore.frameworkwizard.common.Tools;
40 import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
41 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
42 import org.tianocore.frameworkwizard.common.ui.StarLabel;
43
44 /**
45 The class is used to create, update MsaHeader of MSA file
46 It extends IInternalFrame
47
48
49
50 **/
51 public class MsaHeader extends IInternalFrame {
52
53 ///
54 /// Define class Serial Version UID
55 ///
56 private static final long serialVersionUID = -8152099582923006900L;
57
58 //
59 //Define class members
60 //
61 private JPanel jContentPane = null;
62
63 private JLabel jLabelBaseName = null;
64
65 private JTextField jTextFieldBaseName = null;
66
67 private JLabel jLabelGuid = null;
68
69 private JTextField jTextFieldGuid = null;
70
71 private JLabel jLabelVersion = null;
72
73 private JTextField jTextFieldVersion = null;
74
75 private JButton jButtonGenerateGuid = null;
76
77 private JLabel jLabelLicense = null;
78
79 private JTextArea jTextAreaLicense = null;
80
81 private JLabel jLabelCopyright = 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 JButton jButtonOk = null;
92
93 private JButton jButtonCancel = null;
94
95 private JScrollPane jScrollPaneLicense = null;
96
97 private JScrollPane jScrollPaneDescription = null;
98
99 private JLabel jLabelAbstract = null;
100
101 private JTextField jTextFieldAbstract = null;
102
103 private JLabel jLabelModuleType = null;
104
105 private JComboBox jComboBoxModuleType = null;
106
107 private StarLabel jStarLabel1 = null;
108
109 private StarLabel jStarLabel2 = null;
110
111 private StarLabel jStarLabel4 = null;
112
113 private StarLabel jStarLabel5 = null;
114
115 private StarLabel jStarLabel6 = null;
116
117 private StarLabel jStarLabel7 = null;
118
119 private StarLabel jStarLabel8 = null;
120
121 private StarLabel jStarLabel10 = null;
122
123 private StarLabel jStarLabel12 = null;
124
125 private MsaHeaderDocument.MsaHeader msaHeader = null;
126
127 private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;
128
129 private JTextField jTextFieldCopyright = null;
130
131 private JLabel jLabelURL = null;
132
133 private JTextField jTextFieldURL = null;
134
135 private JScrollPane jScrollPane = null;
136
137 private OpeningModuleType omt = null;
138
139 private EnumerationData ed = new EnumerationData();
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 jTextFieldBaseName.setPreferredSize(new java.awt.Dimension(320, 20));
152 jTextFieldBaseName.addFocusListener(this);
153 jTextFieldBaseName.setToolTipText("A brief Identifier, such as USB I/O Library, of the module");
154 }
155 return jTextFieldBaseName;
156 }
157
158 /**
159 This method initializes jTextFieldGuid
160
161 @return javax.swing.JTextField jTextFieldGuid
162
163 **/
164 private JTextField getJTextFieldGuid() {
165 if (jTextFieldGuid == null) {
166 jTextFieldGuid = new JTextField();
167 jTextFieldGuid.setPreferredSize(new java.awt.Dimension(250, 20));
168 jTextFieldGuid.setLocation(new java.awt.Point(160, 60));
169 jTextFieldGuid.setSize(new java.awt.Dimension(250, 20));
170 jTextFieldGuid.addFocusListener(this);
171 jTextFieldGuid.setToolTipText("Guaranteed Unique Identification Number, Registry Format (8-4-4-4-12)");
172 }
173 return jTextFieldGuid;
174 }
175
176 /**
177 This method initializes jTextFieldVersion
178
179 @return javax.swing.JTextField jTextFieldVersion
180
181 **/
182 private JTextField getJTextFieldVersion() {
183 if (jTextFieldVersion == null) {
184 jTextFieldVersion = new JTextField();
185 jTextFieldVersion.setPreferredSize(new java.awt.Dimension(320, 20));
186 jTextFieldVersion.setLocation(new java.awt.Point(160, 85));
187 jTextFieldVersion.setSize(new java.awt.Dimension(320, 20));
188 jTextFieldVersion.addFocusListener(this);
189 jTextFieldVersion.setToolTipText("A Version Number, 1.0, 1, 1.01, 1.0.1");
190 }
191 return jTextFieldVersion;
192 }
193
194 /**
195 This method initializes jButtonGenerateGuid
196
197 @return javax.swing.JButton jButtonGenerateGuid
198
199 **/
200 private JButton getJButtonGenerateGuid() {
201 if (jButtonGenerateGuid == null) {
202 jButtonGenerateGuid = new JButton();
203 jButtonGenerateGuid.setPreferredSize(new java.awt.Dimension(65, 20));
204 jButtonGenerateGuid.setSize(new java.awt.Dimension(65, 20));
205 jButtonGenerateGuid.setLocation(new java.awt.Point(415, 60));
206 jButtonGenerateGuid.setText("GEN");
207 jButtonGenerateGuid.addActionListener(this);
208 }
209 return jButtonGenerateGuid;
210 }
211
212 /**
213 This method initializes jTextAreaLicense
214
215 @return javax.swing.JTextArea jTextAreaLicense
216
217 **/
218 private JTextArea getJTextAreaLicense() {
219 if (jTextAreaLicense == null) {
220 jTextAreaLicense = new JTextArea();
221 jTextAreaLicense.setText("");
222 jTextAreaLicense.setLineWrap(true);
223 jTextAreaLicense.addFocusListener(this);
224 jTextAreaLicense.setWrapStyleWord(true);
225 jTextAreaLicense.setSelectionStart(0);
226 jTextAreaLicense.setSelectionEnd(0);
227 jTextAreaLicense.setToolTipText("The License for this Module.");
228 }
229 return jTextAreaLicense;
230 }
231
232 /**
233 This method initializes jTextAreaDescription
234
235 @return javax.swing.JTextArea jTextAreaDescription
236
237 **/
238 private JTextArea getJTextAreaDescription() {
239 if (jTextAreaDescription == null) {
240 jTextAreaDescription = new JTextArea();
241 jTextAreaDescription.setLineWrap(true);
242 jTextAreaDescription.addFocusListener(this);
243 jTextAreaDescription.setToolTipText("A verbose description of the module");
244 jTextAreaDescription.setWrapStyleWord(true);
245 jTextAreaDescription.setSelectionStart(0);
246 jTextAreaDescription.setSelectionEnd(0);
247 }
248 return jTextAreaDescription;
249 }
250
251 /**
252 This method initializes jTextFieldSpecification
253
254 @return javax.swing.JTextField jTextFieldSpecification
255
256 **/
257 private JTextField getJTextFieldSpecification() {
258 if (jTextFieldSpecification == null) {
259 jTextFieldSpecification = new JTextField();
260 jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(320, 20));
261 jTextFieldSpecification.setText("FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052");
262 jTextFieldSpecification.setSize(new java.awt.Dimension(320, 20));
263 jTextFieldSpecification.setLocation(new java.awt.Point(160, 435));
264 jTextFieldSpecification.setEditable(false);
265 jTextFieldSpecification.addFocusListener(this);
266 }
267 return jTextFieldSpecification;
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.setPreferredSize(new java.awt.Dimension(90, 20));
281 jButtonOk.setBounds(new java.awt.Rectangle(390, 455, 90, 20));
282 jButtonOk.addActionListener(this);
283 jButtonOk.setVisible(false);
284 }
285 return jButtonOk;
286 }
287
288 /**
289 This method initializes jButtonCancel
290
291 @return javax.swing.JButton jButtonCancel
292
293 **/
294 private JButton getJButtonCancel() {
295 if (jButtonCancel == null) {
296 jButtonCancel = new JButton();
297 jButtonCancel.setText("Cancel");
298 jButtonCancel.setBounds(new java.awt.Rectangle(390, 445, 90, 20));
299 jButtonCancel.addActionListener(this);
300 jButtonCancel.setPreferredSize(new java.awt.Dimension(90, 20));
301 jButtonCancel.setVisible(false);
302 }
303 return jButtonCancel;
304 }
305
306 /**
307 This method initializes jScrollPaneLicense
308
309 @return javax.swing.JScrollPane jScrollPaneLicense
310
311 **/
312 private JScrollPane getJScrollPaneLicense() {
313 if (jScrollPaneLicense == null) {
314 jScrollPaneLicense = new JScrollPane();
315 jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
316 jScrollPaneLicense.setSize(new java.awt.Dimension(320, 120));
317 jScrollPaneLicense.setLocation(new java.awt.Point(160, 285));
318 jScrollPaneLicense.setViewportView(getJTextAreaLicense());
319 jScrollPaneLicense.setPreferredSize(new java.awt.Dimension(320, 120));
320 }
321 return jScrollPaneLicense;
322 }
323
324 /**
325 This method initializes jScrollPaneDescription
326
327 @return javax.swing.JScrollPane jScrollPaneDescription
328
329 **/
330 private JScrollPane getJScrollPaneDescription() {
331 if (jScrollPaneDescription == null) {
332 jScrollPaneDescription = new JScrollPane();
333 jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
334 jScrollPaneDescription.setSize(new java.awt.Dimension(320, 120));
335 jScrollPaneDescription.setLocation(new java.awt.Point(160, 135));
336 jScrollPaneDescription.setViewportView(getJTextAreaDescription());
337 jScrollPaneDescription.setPreferredSize(new java.awt.Dimension(320, 120));
338 }
339 return jScrollPaneDescription;
340 }
341
342 /**
343 This method initializes jTextFieldAbstract
344
345 @return javax.swing.JTextField jTextFieldAbstract
346
347 **/
348 private JTextField getJTextFieldAbstract() {
349 if (jTextFieldAbstract == null) {
350 jTextFieldAbstract = new JTextField();
351 jTextFieldAbstract.setPreferredSize(new java.awt.Dimension(320, 20));
352 jTextFieldAbstract.setLocation(new java.awt.Point(160, 110));
353 jTextFieldAbstract.setSize(new java.awt.Dimension(320, 20));
354 jTextFieldAbstract.addFocusListener(this);
355 jTextFieldAbstract.setToolTipText("A one sentence description of this module");
356 }
357 return jTextFieldAbstract;
358 }
359
360 /**
361 This method initializes jComboBoxModuleType
362
363 @return javax.swing.JComboBox jComboBoxModuleType
364
365 **/
366 private JComboBox getJComboBoxModuleType() {
367 if (jComboBoxModuleType == null) {
368 jComboBoxModuleType = new JComboBox();
369 jComboBoxModuleType.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
370 jComboBoxModuleType.setPreferredSize(new java.awt.Dimension(320, 20));
371 jComboBoxModuleType.addFocusListener(this);
372 }
373 return jComboBoxModuleType;
374 }
375
376 /**
377 This method initializes jTextFieldCopyright
378
379 @return javax.swing.JTextField jTextFieldCopyright
380
381 **/
382 private JTextField getJTextFieldCopyright() {
383 if (jTextFieldCopyright == null) {
384 jTextFieldCopyright = new JTextField();
385 jTextFieldCopyright.setPreferredSize(new java.awt.Dimension(320, 20));
386 jTextFieldCopyright.setLocation(new java.awt.Point(160, 260));
387 jTextFieldCopyright.setSize(new java.awt.Dimension(320, 20));
388 jTextFieldCopyright.addFocusListener(this);
389 jTextFieldCopyright.setToolTipText("One or more copyright lines");
390 }
391 return jTextFieldCopyright;
392 }
393
394 /**
395 * This method initializes jTextFieldURL
396 *
397 * @return javax.swing.JTextField
398 */
399 private JTextField getJTextFieldURL() {
400 if (jTextFieldURL == null) {
401 jTextFieldURL = new JTextField();
402 jTextFieldURL.setPreferredSize(new java.awt.Dimension(320, 20));
403 jTextFieldURL.setLocation(new java.awt.Point(160, 410));
404 jTextFieldURL.setSize(new java.awt.Dimension(320, 20));
405 jTextFieldURL.addFocusListener(this);
406 jTextFieldURL.setToolTipText("A URL for the latest version of the license");
407 }
408 return jTextFieldURL;
409 }
410
411 /**
412 * This method initializes jScrollPane
413 *
414 * @return javax.swing.JScrollPane
415 */
416 private JScrollPane getJScrollPane() {
417 if (jScrollPane == null) {
418 jScrollPane = new JScrollPane();
419 jScrollPane.setViewportView(getJContentPane());
420 }
421 return jScrollPane;
422 }
423
424 public static void main(String[] args) {
425
426 }
427
428 /**
429 This is the default constructor
430
431 **/
432 public MsaHeader() {
433 super();
434 init();
435 this.setVisible(true);
436 }
437
438 /**
439 This is the override edit constructor
440
441 @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader
442
443 **/
444 public MsaHeader(OpeningModuleType inMsa) {
445 super();
446 this.omt = inMsa;
447 this.msa = omt.getXmlMsa();
448
449 //
450 // Set module definitions default value
451 //
452 if (msa.getModuleDefinitions() == null) {
453 ModuleDefinitionsDocument.ModuleDefinitions md = ModuleDefinitionsDocument.ModuleDefinitions.Factory
454 .newInstance();
455 md.setOutputFileBasename(msa.getMsaHeader().getModuleName());
456 md.setBinaryModule(false);
457 md.setSupportedArchitectures(ed.getVSupportedArchitectures());
458 msa.setModuleDefinitions(md);
459 }
460 init(msa.getMsaHeader());
461 this.setVisible(true);
462 this.setViewMode(false);
463 }
464
465 /**
466 Disable all components when the mode is view
467
468 @param isView true - The view mode; false - The non-view mode
469
470 **/
471 public void setViewMode(boolean isView) {
472 //this.jButtonOk.setVisible(false);
473 //this.jButtonCancel.setVisible(false);
474 if (isView) {
475 this.jTextFieldBaseName.setEnabled(!isView);
476 this.jTextFieldGuid.setEnabled(!isView);
477 this.jTextFieldVersion.setEnabled(!isView);
478 this.jTextAreaLicense.setEnabled(!isView);
479 this.jTextFieldCopyright.setEnabled(!isView);
480 this.jTextAreaDescription.setEnabled(!isView);
481 this.jTextFieldSpecification.setEnabled(!isView);
482 this.jTextFieldAbstract.setEnabled(!isView);
483 this.jComboBoxModuleType.setEnabled(!isView);
484 this.jButtonCancel.setEnabled(!isView);
485 this.jButtonGenerateGuid.setEnabled(!isView);
486 this.jButtonOk.setEnabled(!isView);
487 }
488 }
489
490 /**
491 This method initializes this
492
493 **/
494 private void init() {
495 this.setSize(500, 515);
496 this.setPreferredSize(new java.awt.Dimension(490, 520));
497 this.setContentPane(getJScrollPane());
498 this.setTitle("Module Surface Area Header");
499 initFrame();
500 }
501
502 /**
503 This method initializes this
504 Fill values to all fields if these values are not empty
505
506 @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader
507
508 **/
509 private void init(MsaHeaderDocument.MsaHeader inMsaHeader) {
510 init();
511 if (inMsaHeader != null) {
512 setMsaHeader(inMsaHeader);
513 if (this.msaHeader.getModuleName() != null) {
514 this.jTextFieldBaseName.setText(this.msaHeader.getModuleName());
515 }
516 if (this.msaHeader.getModuleType() != null) {
517 this.jComboBoxModuleType.setSelectedItem(this.msaHeader.getModuleType().toString());
518 }
519 if (this.msaHeader.getGuidValue() != null) {
520 this.jTextFieldGuid.setText(this.msaHeader.getGuidValue());
521 }
522 if (this.msaHeader.getVersion() != null) {
523 this.jTextFieldVersion.setText(this.msaHeader.getVersion());
524 }
525 if (this.msaHeader.getAbstract() != null) {
526 this.jTextFieldAbstract.setText(this.msaHeader.getAbstract());
527 }
528 if (this.msaHeader.getDescription() != null) {
529 this.jTextAreaDescription.setText(this.msaHeader.getDescription());
530 jTextAreaDescription.setSelectionStart(0);
531 jTextAreaDescription.setSelectionEnd(0);
532 }
533 if (this.msaHeader.getCopyright() != null) {
534 this.jTextFieldCopyright.setText(this.msaHeader.getCopyright());
535 }
536 if (this.msaHeader.getLicense() != null) {
537 this.jTextAreaLicense.setText(this.msaHeader.getLicense().getStringValue());
538 jTextAreaLicense.setSelectionStart(0);
539 jTextAreaLicense.setSelectionEnd(0);
540 }
541 if (this.msaHeader.getLicense() != null && this.msaHeader.getLicense().getURL() != null) {
542 this.jTextFieldURL.setText(this.msaHeader.getLicense().getURL());
543 }
544 if (this.msaHeader.getSpecification() != null) {
545 this.jTextFieldSpecification.setText(this.msaHeader.getSpecification());
546 }
547 }
548 }
549
550 /**
551 This method initializes jContentPane
552
553 @return javax.swing.JPanel jContentPane
554
555 **/
556 private JPanel getJContentPane() {
557 if (jContentPane == null) {
558
559 jLabelURL = new JLabel();
560 jLabelURL.setText("License URL");
561 jLabelURL.setLocation(new java.awt.Point(15, 410));
562 jLabelURL.setSize(new java.awt.Dimension(140, 20));
563 jLabelBaseName = new JLabel();
564 jLabelBaseName.setText("Module Name");
565 jLabelBaseName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
566 jLabelModuleType = new JLabel();
567 jLabelModuleType.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
568 jLabelModuleType.setText("Module Type");
569 jLabelGuid = new JLabel();
570 jLabelGuid.setText("Guid Value");
571 jLabelGuid.setLocation(new java.awt.Point(15, 60));
572 jLabelGuid.setSize(new java.awt.Dimension(140, 20));
573 jLabelVersion = new JLabel();
574 jLabelVersion.setText("Version");
575 jLabelVersion.setLocation(new java.awt.Point(15, 85));
576 jLabelVersion.setSize(new java.awt.Dimension(140, 20));
577 jLabelAbstract = new JLabel();
578 jLabelAbstract.setText("Abstract");
579 jLabelAbstract.setLocation(new java.awt.Point(15, 110));
580 jLabelAbstract.setSize(new java.awt.Dimension(140, 20));
581 jLabelDescription = new JLabel();
582 jLabelDescription.setText("Description");
583 jLabelDescription.setLocation(new java.awt.Point(15, 135));
584 jLabelDescription.setSize(new java.awt.Dimension(140, 20));
585 jLabelCopyright = new JLabel();
586 jLabelCopyright.setText("Copyright");
587 jLabelCopyright.setLocation(new java.awt.Point(15, 260));
588 jLabelCopyright.setSize(new java.awt.Dimension(140, 20));
589 jLabelLicense = new JLabel();
590 jLabelLicense.setText("License");
591 jLabelLicense.setLocation(new java.awt.Point(15, 285));
592 jLabelLicense.setSize(new java.awt.Dimension(140, 20));
593 jLabelSpecification = new JLabel();
594 jLabelSpecification.setText("Specification");
595 jLabelSpecification.setLocation(new java.awt.Point(14, 435));
596 jLabelSpecification.setSize(new java.awt.Dimension(140, 20));
597
598 jContentPane = new JPanel();
599 jContentPane.setLayout(null);
600 jContentPane.setPreferredSize(new java.awt.Dimension(490, 470));
601
602 jContentPane.add(jLabelBaseName, null);
603 jContentPane.add(getJTextFieldBaseName(), null);
604 jContentPane.add(jLabelGuid, null);
605 jContentPane.add(getJTextFieldGuid(), null);
606 jContentPane.add(jLabelVersion, null);
607 jContentPane.add(getJTextFieldVersion(), null);
608 jContentPane.add(getJButtonGenerateGuid(), null);
609 jContentPane.add(jLabelLicense, null);
610 jContentPane.add(jLabelCopyright, null);
611 jContentPane.add(jLabelDescription, null);
612 jContentPane.add(jLabelSpecification, null);
613 jContentPane.add(getJTextFieldSpecification(), null);
614 jContentPane.add(getJButtonOk(), null);
615 jContentPane.add(getJButtonCancel(), null);
616 jContentPane.add(getJScrollPaneLicense(), null);
617 jContentPane.add(getJScrollPaneDescription(), null);
618 jContentPane.add(jLabelAbstract, null);
619 jContentPane.add(getJTextFieldAbstract(), null);
620 jContentPane.add(jLabelModuleType, null);
621 jContentPane.add(getJComboBoxModuleType(), null);
622 jContentPane.add(jLabelURL, null);
623 jContentPane.add(getJTextFieldURL(), null);
624 jContentPane.add(getJTextFieldCopyright(), null);
625 jStarLabel1 = new StarLabel();
626 jStarLabel1.setLocation(new java.awt.Point(0, 10));
627 jStarLabel2 = new StarLabel();
628 jStarLabel2.setLocation(new java.awt.Point(0, 35));
629 jStarLabel4 = new StarLabel();
630 jStarLabel4.setLocation(new java.awt.Point(0, 60));
631 jStarLabel5 = new StarLabel();
632 jStarLabel5.setLocation(new java.awt.Point(0, 85));
633 jStarLabel6 = new StarLabel();
634 jStarLabel6.setLocation(new java.awt.Point(0, 135));
635 jStarLabel7 = new StarLabel();
636 jStarLabel7.setLocation(new java.awt.Point(0, 260));
637 jStarLabel8 = new StarLabel();
638 jStarLabel8.setLocation(new java.awt.Point(0, 285));
639 jStarLabel10 = new StarLabel();
640 jStarLabel10.setLocation(new java.awt.Point(0, 110));
641 jStarLabel12 = new StarLabel();
642 jStarLabel12.setLocation(new java.awt.Point(0, 435));
643
644 jContentPane.add(jStarLabel1, null);
645 jContentPane.add(jStarLabel2, null);
646 jContentPane.add(jStarLabel4, null);
647 jContentPane.add(jStarLabel5, null);
648 jContentPane.add(jStarLabel6, null);
649 jContentPane.add(jStarLabel7, null);
650 jContentPane.add(jStarLabel8, null);
651 jContentPane.add(jStarLabel10, null);
652 jContentPane.add(jStarLabel12, null);
653 }
654 return jContentPane;
655 }
656
657 /* (non-Javadoc)
658 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
659 *
660 * Override actionPerformed to listen all actions
661 *
662 */
663 public void actionPerformed(ActionEvent arg0) {
664 if (arg0.getSource() == jButtonOk) {
665 if (this.check()) {
666 this.save();
667 } else {
668 return;
669 }
670 this.setEdited(true);
671 this.dispose();
672 }
673 if (arg0.getSource() == jButtonCancel) {
674 this.setEdited(false);
675 }
676 if (arg0.getSource() == jButtonGenerateGuid) {
677 jTextFieldGuid.setText(Tools.generateUuidString());
678 }
679 }
680
681 /**
682 Data validation for all fields
683
684 @retval true - All datas are valid
685 @retval false - At least one data is invalid
686
687 **/
688 public boolean check() {
689 //
690 // Check if all required fields are not empty
691 // and check if all data fields values are valid
692 //
693
694 //
695 // Check Base Name
696 //
697 if (isEmpty(this.jTextFieldBaseName.getText())) {
698 Log.wrn("Update Msa Header", "Base Name couldn't be empty");
699 //this.jTextFieldBaseName.requestFocus();
700 return false;
701 }
702 if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
703 Log.wrn("Update Msa Header", "Incorrect data type for Base Name");
704 //this.jTextFieldBaseName.requestFocus();
705 return false;
706 }
707
708 //
709 // Check Guid
710 //
711 if (isEmpty(this.jTextFieldGuid.getText())) {
712 Log.wrn("Update Msa Header", "Guid Value couldn't be empty");
713 //this.jTextFieldGuid.requestFocus();
714 return false;
715 }
716 if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
717 Log.wrn("Update Msa Header", "Incorrect data type for Guid");
718 //this.jTextFieldGuid.requestFocus();
719 return false;
720 }
721
722 //
723 // Check Version
724 //
725 if (isEmpty(this.jTextFieldVersion.getText())) {
726 Log.wrn("Update Msa Header", "Version couldn't be empty");
727 //this.jTextFieldVersion.requestFocus();
728 return false;
729 }
730 if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {
731 Log.wrn("Update Msa Header", "Incorrect data type for Version");
732 //this.jTextFieldVersion.requestFocus();
733 return false;
734 }
735
736 //
737 // Check Abstact
738 //
739 if (isEmpty(this.jTextFieldAbstract.getText())) {
740 Log.wrn("Update Msa Header", "Abstract couldn't be empty");
741 //this.jTextFieldAbstract.requestFocus();
742 return false;
743 }
744 if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {
745 Log.wrn("Update Msa Header", "Incorrect data type for Abstract");
746 //this.jTextFieldAbstract.requestFocus();
747 return false;
748 }
749
750 //
751 // Check Description
752 //
753 if (isEmpty(this.jTextAreaDescription.getText())) {
754 Log.wrn("Update Msa Header", "Description couldn't be empty");
755 //this.jTextAreaDescription.requestFocus();
756 return false;
757 }
758
759 //
760 // Check Copyright
761 //
762 if (isEmpty(this.jTextFieldCopyright.getText())) {
763 Log.wrn("Update Msa Header", "Copyright couldn't be empty");
764 //this.jTextFieldCopyright.requestFocus();
765 return false;
766 }
767
768 //
769 // Check License
770 //
771 if (isEmpty(this.jTextAreaLicense.getText())) {
772 Log.wrn("Update Msa Header", "License couldn't be empty");
773 //this.jTextAreaLicense.requestFocus();
774 return false;
775 }
776
777 //
778 // Check Specification
779 //
780 if (isEmpty(this.jTextFieldSpecification.getText())) {
781 Log.wrn("Update Msa Header", "Specification couldn't be empty");
782 //this.jTextFieldSpecification.requestFocus();
783 return false;
784 }
785 if (!DataValidation.isSpecification(this.jTextFieldSpecification.getText())) {
786 Log.wrn("Update Msa Header", "Incorrect data type for Specification");
787 //this.jTextFieldSpecification.requestFocus();
788 return false;
789 }
790
791 return true;
792 }
793
794 /**
795 Save all components of Msa Header
796 if exists msaHeader, set the value directly
797 if not exists msaHeader, new an instance first
798
799 **/
800 public void save() {
801 try {
802 // this.msaHeader.setModuleName(this.jTextFieldBaseName.getText());
803 // this.msaHeader.setModuleType(ModuleTypeDef.Enum.forString(this.jComboBoxModuleType.getSelectedItem()
804 // .toString()));
805 // this.msaHeader.setGuidValue(this.jTextFieldGuid.getText());
806 // this.msaHeader.setVersion(this.jTextFieldVersion.getText());
807 // this.msaHeader.setAbstract(this.jTextFieldAbstract.getText());
808 // this.msaHeader.setDescription(this.jTextAreaDescription.getText());
809 // this.msaHeader.setCopyright(this.jTextFieldCopyright.getText());
810 // if (this.msaHeader.getLicense() != null) {
811 // this.msaHeader.getLicense().setStringValue(this.jTextAreaLicense.getText());
812 // } else {
813 // License mLicense = License.Factory.newInstance();
814 // mLicense.setStringValue(this.jTextAreaLicense.getText());
815 // this.msaHeader.setLicense(mLicense);
816 // }
817 // if (!isEmpty(this.jTextFieldURL.getText())) {
818 // this.msaHeader.getLicense().setURL(this.jTextFieldURL.getText());
819 // }
820 // this.msaHeader.setSpecification(this.jTextFieldSpecification.getText());
821
822 msaHeader.setSpecification(this.jTextFieldSpecification.getText());
823 msa.setMsaHeader(msaHeader);
824 this.omt.setSaved(false);
825 } catch (Exception e) {
826 Log.wrn("Save Module", e.getMessage());
827 Log.err("Save Module", e.getMessage());
828 }
829 }
830
831 /**
832 This method initializes Module type and Compontent type
833
834 **/
835 private void initFrame() {
836 EnumerationData ed = new EnumerationData();
837 Tools.generateComboBoxByVector(jComboBoxModuleType, ed.getVModuleType());
838 }
839
840 /**
841 Get MsaHeaderDocument.MsaHeader
842
843 @return MsaHeaderDocument.MsaHeader
844
845 **/
846 public MsaHeaderDocument.MsaHeader getMsaHeader() {
847 return msaHeader;
848 }
849
850 /**
851 Set MsaHeaderDocument.MsaHeader
852
853 @param msaHeader The input data of MsaHeaderDocument.MsaHeader
854
855 **/
856 public void setMsaHeader(MsaHeaderDocument.MsaHeader msaHeader) {
857 this.msaHeader = msaHeader;
858 }
859
860 /* (non-Javadoc)
861 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
862 *
863 * Override componentResized to resize all components when frame's size is changed
864 */
865 public void componentResized(ComponentEvent arg0) {
866 int intCurrentWidth = this.getJContentPane().getWidth();
867 int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
868
869 resizeComponentWidth(this.jTextFieldBaseName, intCurrentWidth, intPreferredWidth);
870 resizeComponentWidth(this.jTextFieldGuid, intCurrentWidth, intPreferredWidth);
871 resizeComponentWidth(this.jTextFieldVersion, intCurrentWidth, intPreferredWidth);
872 resizeComponentWidth(this.jScrollPaneLicense, intCurrentWidth, intPreferredWidth);
873 resizeComponentWidth(this.jTextFieldURL, intCurrentWidth, intPreferredWidth);
874 resizeComponentWidth(this.jTextFieldCopyright, intCurrentWidth, intPreferredWidth);
875 resizeComponentWidth(this.jScrollPaneDescription, intCurrentWidth, intPreferredWidth);
876 resizeComponentWidth(this.jTextFieldSpecification, intCurrentWidth, intPreferredWidth);
877 resizeComponentWidth(this.jTextFieldAbstract, intCurrentWidth, intPreferredWidth);
878 resizeComponentWidth(this.jComboBoxModuleType, intCurrentWidth, intPreferredWidth);
879 relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth,
880 DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
881 }
882
883 public void focusLost(FocusEvent arg0) {
884 if (this.msaHeader == null) {
885 msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance();
886 }
887
888 //
889 // Check BaseName
890 //
891 if (arg0.getSource() == this.jTextFieldBaseName) {
892 if (isEmpty(this.jTextFieldBaseName.getText())) {
893 Log.wrn("Update Msa Header", "Base Name couldn't be empty");
894 //this.jTextFieldBaseName.requestFocus();
895 return;
896 }
897 if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
898 Log.wrn("Update Msa Header", "Incorrect data type for Base Name");
899 //this.jTextFieldBaseName.requestFocus();
900 return;
901 }
902 if (!this.jTextFieldBaseName.getText().equals(msaHeader.getModuleName())) {
903 this.msaHeader.setModuleName(this.jTextFieldBaseName.getText());
904 } else {
905 return;
906 }
907 }
908
909 //
910 // Check Module Type
911 //
912 if (arg0.getSource() == this.jComboBoxModuleType) {
913 if (!jComboBoxModuleType.getSelectedItem().toString().equals(msaHeader.getModuleType().toString())) {
914 msaHeader.setModuleType(ModuleTypeDef.Enum.forString(jComboBoxModuleType.getSelectedItem().toString()));
915 } else {
916 return;
917 }
918 }
919
920 //
921 // Check Guid
922 //
923 if (arg0.getSource() == this.jTextFieldGuid) {
924 if (isEmpty(this.jTextFieldGuid.getText())) {
925 Log.wrn("Update Msa Header", "Guid Value couldn't be empty");
926 //this.jTextFieldGuid.requestFocus();
927 return;
928 }
929 if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
930 Log.wrn("Update Msa Header", "Incorrect data type for Guid");
931 //this.jTextFieldGuid.requestFocus();
932 return;
933 }
934 if (!this.jTextFieldGuid.getText().equals(msaHeader.getGuidValue())) {
935 this.msaHeader.setGuidValue(this.jTextFieldGuid.getText());
936 } else {
937 return;
938 }
939 }
940
941 //
942 // Check Version
943 //
944 if (arg0.getSource() == this.jTextFieldVersion) {
945 if (isEmpty(this.jTextFieldVersion.getText())) {
946 Log.wrn("Update Msa Header", "Version couldn't be empty");
947 //this.jTextFieldVersion.requestFocus();
948 return;
949 }
950 if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {
951 Log.wrn("Update Msa Header", "Incorrect data type for Version");
952 //this.jTextFieldVersion.requestFocus();
953 return;
954 }
955 if (!this.jTextFieldVersion.getText().equals(msaHeader.getVersion())) {
956 this.msaHeader.setVersion(this.jTextFieldVersion.getText());
957 } else {
958 return;
959 }
960 }
961
962 //
963 // Check Abstact
964 //
965 if (arg0.getSource() == this.jTextFieldAbstract) {
966 if (isEmpty(this.jTextFieldAbstract.getText())) {
967 Log.wrn("Update Msa Header", "Abstract couldn't be empty");
968 //this.jTextFieldAbstract.requestFocus();
969 return;
970 }
971 if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {
972 Log.wrn("Update Msa Header", "Incorrect data type for Abstract");
973 //this.jTextFieldAbstract.requestFocus();
974 return;
975 }
976 if (!this.jTextFieldAbstract.getText().equals(msaHeader.getAbstract())) {
977 this.msaHeader.setAbstract(this.jTextFieldAbstract.getText());
978 } else {
979 return;
980 }
981 }
982
983 //
984 // Check Description
985 //
986 if (arg0.getSource() == this.jTextAreaDescription) {
987 if (isEmpty(this.jTextAreaDescription.getText())) {
988 Log.wrn("Update Msa Header", "Description couldn't be empty");
989 //this.jTextAreaDescription.requestFocus();
990 return;
991 }
992 if (!this.jTextAreaDescription.getText().equals(msaHeader.getDescription())) {
993 this.msaHeader.setDescription(this.jTextAreaDescription.getText());
994 } else {
995 return;
996 }
997 }
998
999 //
1000 // Check Copyright
1001 //
1002 if (arg0.getSource() == this.jTextFieldCopyright) {
1003 if (isEmpty(this.jTextFieldCopyright.getText())) {
1004 Log.wrn("Update Msa Header", "Copyright couldn't be empty");
1005 //this.jTextFieldCopyright.requestFocus();
1006 return;
1007 }
1008 if (!this.jTextFieldCopyright.getText().equals(msaHeader.getCopyright())) {
1009 this.msaHeader.setCopyright(this.jTextFieldCopyright.getText());
1010 } else {
1011 return;
1012 }
1013 }
1014
1015 //
1016 // Check License
1017 //
1018 if (arg0.getSource() == this.jTextAreaLicense) {
1019 if (isEmpty(this.jTextAreaLicense.getText())) {
1020 Log.wrn("Update Msa Header", "License couldn't be empty");
1021 //this.jTextAreaLicense.requestFocus();
1022 return;
1023 }
1024 if (this.msaHeader.getLicense() != null) {
1025 if (!this.jTextAreaLicense.getText().equals(msaHeader.getLicense().getStringValue())) {
1026 this.msaHeader.getLicense().setStringValue(this.jTextAreaLicense.getText());
1027 } else {
1028 return;
1029 }
1030 } else {
1031 License mLicense = License.Factory.newInstance();
1032 mLicense.setStringValue(this.jTextAreaLicense.getText());
1033 this.msaHeader.setLicense(mLicense);
1034 }
1035 }
1036
1037 //
1038 // Check License URL
1039 //
1040 if (arg0.getSource() == this.jTextFieldURL) {
1041 if (!isEmpty(this.jTextFieldURL.getText())) {
1042 if (this.msaHeader.getLicense() == null) {
1043 License mLicense = License.Factory.newInstance();
1044 mLicense.setURL(this.jTextFieldURL.getText());
1045 this.msaHeader.setLicense(mLicense);
1046 } else {
1047 if (!this.jTextFieldURL.getText().equals(msaHeader.getLicense().getURL())) {
1048 this.msaHeader.getLicense().setURL(this.jTextFieldURL.getText());
1049 } else {
1050 return;
1051 }
1052 }
1053 }
1054 }
1055
1056 this.save();
1057 }
1058 }