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