]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java
1. Enhance Source Files selection in msa:
[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("An 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 (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");
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 file");
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.err("Base Name couldn't be empty");
699 //this.jTextFieldBaseName.requestFocus();
700 return false;
701 }
702 if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
703 Log.err("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.err("Guid Value couldn't be empty");
713 //this.jTextFieldGuid.requestFocus();
714 return false;
715 }
716 if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
717 Log.err("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.err("Version couldn't be empty");
727 //this.jTextFieldVersion.requestFocus();
728 return false;
729 }
730 if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {
731 Log.err("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.err("Abstract couldn't be empty");
741 //this.jTextFieldAbstract.requestFocus();
742 return false;
743 }
744 if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {
745 Log.err("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.err("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.err("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.err("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.err("Specification couldn't be empty");
782 //this.jTextFieldSpecification.requestFocus();
783 return false;
784 }
785 if (!DataValidation.isSpecification(this.jTextFieldSpecification.getText())) {
786 Log.err("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.err("Save Module", e.getMessage());
827 }
828 }
829
830 /**
831 This method initializes Module type and Compontent type
832
833 **/
834 private void initFrame() {
835 EnumerationData ed = new EnumerationData();
836 Tools.generateComboBoxByVector(jComboBoxModuleType, ed.getVModuleType());
837 }
838
839 /**
840 Get MsaHeaderDocument.MsaHeader
841
842 @return MsaHeaderDocument.MsaHeader
843
844 **/
845 public MsaHeaderDocument.MsaHeader getMsaHeader() {
846 return msaHeader;
847 }
848
849 /**
850 Set MsaHeaderDocument.MsaHeader
851
852 @param msaHeader The input data of MsaHeaderDocument.MsaHeader
853
854 **/
855 public void setMsaHeader(MsaHeaderDocument.MsaHeader msaHeader) {
856 this.msaHeader = msaHeader;
857 }
858
859 /* (non-Javadoc)
860 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
861 *
862 * Override componentResized to resize all components when frame's size is changed
863 */
864 public void componentResized(ComponentEvent arg0) {
865 int intCurrentWidth = this.getJContentPane().getWidth();
866 int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
867
868 resizeComponentWidth(this.jTextFieldBaseName, intCurrentWidth, intPreferredWidth);
869 resizeComponentWidth(this.jTextFieldGuid, intCurrentWidth, intPreferredWidth);
870 resizeComponentWidth(this.jTextFieldVersion, intCurrentWidth, intPreferredWidth);
871 resizeComponentWidth(this.jScrollPaneLicense, intCurrentWidth, intPreferredWidth);
872 resizeComponentWidth(this.jTextFieldURL, intCurrentWidth, intPreferredWidth);
873 resizeComponentWidth(this.jTextFieldCopyright, intCurrentWidth, intPreferredWidth);
874 resizeComponentWidth(this.jScrollPaneDescription, intCurrentWidth, intPreferredWidth);
875 resizeComponentWidth(this.jTextFieldSpecification, intCurrentWidth, intPreferredWidth);
876 resizeComponentWidth(this.jTextFieldAbstract, intCurrentWidth, intPreferredWidth);
877 resizeComponentWidth(this.jComboBoxModuleType, intCurrentWidth, intPreferredWidth);
878 relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth,
879 DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
880 }
881
882 public void focusLost(FocusEvent arg0) {
883 if (this.msaHeader == null) {
884 msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance();
885 }
886
887 //
888 // Check BaseName
889 //
890 if (arg0.getSource() == this.jTextFieldBaseName) {
891 if (isEmpty(this.jTextFieldBaseName.getText())) {
892 Log.err("Base Name couldn't be empty");
893 //this.jTextFieldBaseName.requestFocus();
894 return;
895 }
896 if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
897 Log.err("Incorrect data type for Base Name");
898 //this.jTextFieldBaseName.requestFocus();
899 return;
900 }
901 if (!this.jTextFieldBaseName.getText().equals(msaHeader.getModuleName())) {
902 this.msaHeader.setModuleName(this.jTextFieldBaseName.getText());
903 } else {
904 return;
905 }
906 }
907
908 //
909 // Check Module Type
910 //
911 if (arg0.getSource() == this.jComboBoxModuleType) {
912 if (!jComboBoxModuleType.getSelectedItem().toString().equals(msaHeader.getModuleType().toString())) {
913 msaHeader.setModuleType(ModuleTypeDef.Enum.forString(jComboBoxModuleType.getSelectedItem().toString()));
914 } else {
915 return;
916 }
917 }
918
919 //
920 // Check Guid
921 //
922 if (arg0.getSource() == this.jTextFieldGuid) {
923 if (isEmpty(this.jTextFieldGuid.getText())) {
924 Log.err("Guid Value couldn't be empty");
925 //this.jTextFieldGuid.requestFocus();
926 return;
927 }
928 if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
929 Log.err("Incorrect data type for Guid");
930 //this.jTextFieldGuid.requestFocus();
931 return;
932 }
933 if (!this.jTextFieldGuid.getText().equals(msaHeader.getGuidValue())) {
934 this.msaHeader.setGuidValue(this.jTextFieldGuid.getText());
935 } else {
936 return;
937 }
938 }
939
940 //
941 // Check Version
942 //
943 if (arg0.getSource() == this.jTextFieldVersion) {
944 if (isEmpty(this.jTextFieldVersion.getText())) {
945 Log.err("Version couldn't be empty");
946 //this.jTextFieldVersion.requestFocus();
947 return;
948 }
949 if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {
950 Log.err("Incorrect data type for Version");
951 //this.jTextFieldVersion.requestFocus();
952 return;
953 }
954 if (!this.jTextFieldVersion.getText().equals(msaHeader.getVersion())) {
955 this.msaHeader.setVersion(this.jTextFieldVersion.getText());
956 } else {
957 return;
958 }
959 }
960
961 //
962 // Check Abstact
963 //
964 if (arg0.getSource() == this.jTextFieldAbstract) {
965 if (isEmpty(this.jTextFieldAbstract.getText())) {
966 Log.err("Abstract couldn't be empty");
967 //this.jTextFieldAbstract.requestFocus();
968 return;
969 }
970 if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {
971 Log.err("Incorrect data type for Abstract");
972 //this.jTextFieldAbstract.requestFocus();
973 return;
974 }
975 if (!this.jTextFieldAbstract.getText().equals(msaHeader.getAbstract())) {
976 this.msaHeader.setAbstract(this.jTextFieldAbstract.getText());
977 } else {
978 return;
979 }
980 }
981
982 //
983 // Check Description
984 //
985 if (arg0.getSource() == this.jTextAreaDescription) {
986 if (isEmpty(this.jTextAreaDescription.getText())) {
987 Log.err("Description couldn't be empty");
988 //this.jTextAreaDescription.requestFocus();
989 return;
990 }
991 if (!this.jTextAreaDescription.getText().equals(msaHeader.getDescription())) {
992 this.msaHeader.setDescription(this.jTextAreaDescription.getText());
993 } else {
994 return;
995 }
996 }
997
998 //
999 // Check Copyright
1000 //
1001 if (arg0.getSource() == this.jTextFieldCopyright) {
1002 if (isEmpty(this.jTextFieldCopyright.getText())) {
1003 Log.err("Copyright couldn't be empty");
1004 //this.jTextFieldCopyright.requestFocus();
1005 return;
1006 }
1007 if (!this.jTextFieldCopyright.getText().equals(msaHeader.getCopyright())) {
1008 this.msaHeader.setCopyright(this.jTextFieldCopyright.getText());
1009 } else {
1010 return;
1011 }
1012 }
1013
1014 //
1015 // Check License
1016 //
1017 if (arg0.getSource() == this.jTextAreaLicense) {
1018 if (isEmpty(this.jTextAreaLicense.getText())) {
1019 Log.err("License couldn't be empty");
1020 //this.jTextAreaLicense.requestFocus();
1021 return;
1022 }
1023 if (this.msaHeader.getLicense() != null) {
1024 if (!this.jTextAreaLicense.getText().equals(msaHeader.getLicense().getStringValue())) {
1025 this.msaHeader.getLicense().setStringValue(this.jTextAreaLicense.getText());
1026 } else {
1027 return;
1028 }
1029 } else {
1030 License mLicense = License.Factory.newInstance();
1031 mLicense.setStringValue(this.jTextAreaLicense.getText());
1032 this.msaHeader.setLicense(mLicense);
1033 }
1034 }
1035
1036 //
1037 // Check License URL
1038 //
1039 if (arg0.getSource() == this.jTextFieldURL) {
1040 if (!isEmpty(this.jTextFieldURL.getText())) {
1041 if (this.msaHeader.getLicense() == null) {
1042 License mLicense = License.Factory.newInstance();
1043 mLicense.setURL(this.jTextFieldURL.getText());
1044 this.msaHeader.setLicense(mLicense);
1045 } else {
1046 if (!this.jTextFieldURL.getText().equals(msaHeader.getLicense().getURL())) {
1047 this.msaHeader.getLicense().setURL(this.jTextFieldURL.getText());
1048 } else {
1049 return;
1050 }
1051 }
1052 }
1053 }
1054
1055 this.save();
1056 }
1057 }