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