git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@671 6f19259b...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / packaging / ui / SpdHeader.java
CommitLineData
a13899c5 1/** @file\r
2 \r
3 The file is used to create, update spdHeader of Spd 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
16package org.tianocore.frameworkwizard.packaging.ui;\r
17\r
18import java.awt.Rectangle;\r
19import java.awt.event.ActionEvent;\r
20import java.awt.event.ComponentEvent;\r
21import java.awt.event.FocusAdapter;\r
22import java.awt.event.FocusEvent;\r
23\r
24import javax.swing.JButton;\r
25import javax.swing.JLabel;\r
26import javax.swing.JPanel;\r
27import javax.swing.JScrollPane;\r
28import javax.swing.JTextArea;\r
29import javax.swing.JTextField;\r
30\r
31import org.tianocore.PackageSurfaceAreaDocument;\r
32import org.tianocore.frameworkwizard.common.DataValidation;\r
33import org.tianocore.frameworkwizard.common.Log;\r
34import org.tianocore.frameworkwizard.common.Tools;\r
35import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r
36import org.tianocore.frameworkwizard.common.ui.StarLabel;\r
37\r
38/**\r
39 The class is used to create, update spdHeader of Spd file\r
40 It extends IInternalFrame\r
41 \r
42 @since PackageEditor 1.0\r
43\r
44 **/\r
45public class SpdHeader extends IInternalFrame {\r
46\r
47 ///\r
48 /// Define class Serial Version UID\r
49 ///\r
50 private static final long serialVersionUID = -8152099582923006900L;\r
51\r
52 //\r
53 //Define class members\r
54 //\r
55 private JPanel jContentPane = null;\r
56\r
57 private JLabel jLabelBaseName = null;\r
58\r
59 private JTextField jTextFieldBaseName = null;\r
60\r
61 private JLabel jLabelGuid = null;\r
62\r
63 private JTextField jTextFieldGuid = null;\r
64\r
65 private JLabel jLabelVersion = null;\r
66\r
67 private JTextField jTextFieldVersion = null;\r
68\r
69 private JButton jButtonGenerateGuid = null;\r
70\r
71 private JLabel jLabelLicense = null;\r
72\r
73 private JTextArea jTextAreaLicense = null;\r
74\r
75 private JLabel jLabelCopyright = null;\r
76\r
77 private JLabel jLabelDescription = null;\r
78\r
79 private JTextArea jTextAreaDescription = null;\r
80\r
81 private JLabel jLabelSpecification = null;\r
82\r
83 private JTextField jTextFieldSpecification = null;\r
84\r
85 private JButton jButtonOk = null;\r
86\r
87 private JButton jButtonCancel = null;\r
88\r
89 private JScrollPane jScrollPaneLicense = null;\r
90\r
91 private JScrollPane jScrollPaneDescription = null;\r
92\r
93 private JLabel jLabelAbstract = null;\r
94\r
95 private JTextField jTextFieldAbstract = null;\r
96\r
97 private StarLabel jStarLabel1 = null;\r
98\r
99 private StarLabel jStarLabel2 = null;\r
100\r
101 private StarLabel jStarLabel3 = null;\r
102\r
103 private StarLabel jStarLabel4 = null;\r
104\r
105 private StarLabel jStarLabel5 = null;\r
106\r
107 private StarLabel jStarLabel6 = null;\r
108\r
109 private StarLabel jStarLabel7 = null;\r
110\r
111 private StarLabel jStarLabel9 = null;\r
112 \r
113 private SpdFileContents sfc = null;\r
114\r
115 private JTextField jTextFieldCopyright = null;\r
116 \r
117 private JScrollPane topScrollPane = null;\r
118\r
119 private JLabel jLabel = null;\r
120\r
121 private JTextField jTextField = null;\r
122\r
123 /**\r
124 This method initializes jTextFieldBaseName \r
125 \r
126 @return javax.swing.JTextField jTextFieldBaseName\r
127 \r
128 **/\r
129 private JTextField getJTextFieldBaseName() {\r
130 if (jTextFieldBaseName == null) {\r
131 jTextFieldBaseName = new JTextField();\r
132 jTextFieldBaseName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));\r
133 jTextFieldBaseName.setPreferredSize(new java.awt.Dimension(320,20));\r
134 jTextFieldBaseName.addFocusListener(new FocusAdapter(){\r
135 public void focusLost(FocusEvent e){\r
136 sfc.setSpdHdrPkgName(jTextFieldBaseName.getText());\r
137 }\r
138 });\r
139 }\r
140 return jTextFieldBaseName;\r
141 }\r
142\r
143 /**\r
144 This method initializes jTextFieldGuid \r
145 \r
146 @return javax.swing.JTextField jTextFieldGuid\r
147 \r
148 **/\r
149 private JTextField getJTextFieldGuid() {\r
150 if (jTextFieldGuid == null) {\r
151 jTextFieldGuid = new JTextField();\r
152 jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 250, 20));\r
153 jTextFieldGuid.setPreferredSize(new java.awt.Dimension(250,20));\r
154 jTextFieldGuid.addFocusListener(new FocusAdapter(){\r
155 public void focusLost(FocusEvent e){\r
156 sfc.setSpdHdrGuidValue(jTextFieldGuid.getText());\r
157 }\r
158 });\r
159 }\r
160 return jTextFieldGuid;\r
161 }\r
162\r
163 /**\r
164 This method initializes jTextFieldVersion \r
165 \r
166 @return javax.swing.JTextField jTextFieldVersion\r
167 \r
168 **/\r
169 private JTextField getJTextFieldVersion() {\r
170 if (jTextFieldVersion == null) {\r
171 jTextFieldVersion = new JTextField();\r
172 jTextFieldVersion.setBounds(new java.awt.Rectangle(160, 60, 320, 20));\r
173 jTextFieldVersion.setPreferredSize(new java.awt.Dimension(320,20));\r
174 jTextFieldVersion.addFocusListener(new FocusAdapter(){\r
175 public void focusLost(FocusEvent e){\r
176 sfc.setSpdHdrVer(jTextFieldVersion.getText());\r
177 } \r
178 });\r
179 }\r
180 return jTextFieldVersion;\r
181 }\r
182\r
183 /**\r
184 This method initializes jButtonGenerateGuid \r
185 \r
186 @return javax.swing.JButton jButtonGenerateGuid\r
187 \r
188 **/\r
189 private JButton getJButtonGenerateGuid() {\r
190 if (jButtonGenerateGuid == null) {\r
191 jButtonGenerateGuid = new JButton();\r
192 jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 35, 65, 20));\r
193 jButtonGenerateGuid.setText("GEN");\r
194 jButtonGenerateGuid.addActionListener(this);\r
195 }\r
196 return jButtonGenerateGuid;\r
197 }\r
198\r
199 /**\r
200 This method initializes jTextAreaLicense \r
201 \r
202 @return javax.swing.JTextArea jTextAreaLicense\r
203 \r
204 **/\r
205 private JTextArea getJTextAreaLicense() {\r
206 if (jTextAreaLicense == null) {\r
207 jTextAreaLicense = new JTextArea();\r
208 jTextAreaLicense.setText("");\r
209 jTextAreaLicense.setPreferredSize(new java.awt.Dimension(317,77));\r
210 jTextAreaLicense.setLineWrap(true);\r
211 jTextAreaLicense.addFocusListener(new FocusAdapter(){\r
212 public void focusLost(FocusEvent e){\r
213 sfc.setSpdHdrLicense(jTextAreaLicense.getText());\r
214 }\r
215 });\r
216 }\r
217 return jTextAreaLicense;\r
218 }\r
219\r
220 /**\r
221 This method initializes jTextAreaDescription \r
222 \r
223 @return javax.swing.JTextArea jTextAreaDescription\r
224 \r
225 **/\r
226 private JTextArea getJTextAreaDescription() {\r
227 if (jTextAreaDescription == null) {\r
228 jTextAreaDescription = new JTextArea();\r
229 jTextAreaDescription.setLineWrap(true);\r
230 jTextAreaDescription.setPreferredSize(new java.awt.Dimension(317,77));\r
231 jTextAreaDescription.addFocusListener(new FocusAdapter(){\r
232 public void focusLost(FocusEvent e){\r
233 sfc.setSpdHdrDescription(jTextAreaDescription.getText());\r
234 }\r
235 });\r
236 }\r
237 return jTextAreaDescription;\r
238 }\r
239\r
240 /**\r
241 This method initializes jTextFieldSpecification \r
242 \r
243 @return javax.swing.JTextField jTextFieldSpecification\r
244 \r
245 **/\r
246 private JTextField getJTextFieldSpecification() {\r
247 if (jTextFieldSpecification == null) {\r
248 jTextFieldSpecification = new JTextField();\r
249 jTextFieldSpecification.setBounds(new java.awt.Rectangle(160, 305, 320, 20));\r
250 jTextFieldSpecification.setEditable(false);\r
251 jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(320,20));\r
252 jTextFieldSpecification.addFocusListener(new FocusAdapter(){\r
253 public void focusLost(FocusEvent e){\r
254 sfc.setSpdHdrSpec(jTextFieldSpecification.getText());\r
255 }\r
256 });\r
257 }\r
258 return jTextFieldSpecification;\r
259 }\r
260\r
261 /**\r
262 This method initializes jButtonOk \r
263 \r
264 @return javax.swing.JButton jButtonOk\r
265 \r
266 **/\r
267 private JButton getJButtonOk() {\r
268 if (jButtonOk == null) {\r
269 jButtonOk = new JButton();\r
270 jButtonOk.setText("OK");\r
271 jButtonOk.setBounds(new java.awt.Rectangle(290, 445, 90, 20));\r
272 jButtonOk.setVisible(false);\r
273 jButtonOk.addActionListener(this);\r
274 }\r
275 return jButtonOk;\r
276 }\r
277\r
278 /**\r
279 This method initializes jButtonCancel \r
280 \r
281 @return javax.swing.JButton jButtonCancel\r
282 \r
283 **/\r
284 private JButton getJButtonCancel() {\r
285 if (jButtonCancel == null) {\r
286 jButtonCancel = new JButton();\r
287 jButtonCancel.setText("Cancel");\r
288 jButtonCancel.setBounds(new java.awt.Rectangle(390, 445, 90, 20));\r
289 jButtonCancel.setVisible(false);\r
290 jButtonCancel.addActionListener(this);\r
291 }\r
292 return jButtonCancel;\r
293 }\r
294\r
295 /**\r
296 This method initializes jScrollPaneLicense \r
297 \r
298 @return javax.swing.JScrollPane jScrollPaneLicense\r
299 \r
300 **/\r
301 private JScrollPane getJScrollPaneLicense() {\r
302 if (jScrollPaneLicense == null) {\r
303 jScrollPaneLicense = new JScrollPane();\r
304 jScrollPaneLicense.setBounds(new java.awt.Rectangle(160, 85, 320, 80));\r
305 jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r
306 jScrollPaneLicense.setPreferredSize(new java.awt.Dimension(320,80));\r
307 jScrollPaneLicense.setViewportView(getJTextAreaLicense());\r
308 }\r
309 return jScrollPaneLicense;\r
310 }\r
311\r
312 /**\r
313 This method initializes jScrollPaneDescription \r
314 \r
315 @return javax.swing.JScrollPane jScrollPaneDescription\r
316 \r
317 **/\r
318 private JScrollPane getJScrollPaneDescription() {\r
319 if (jScrollPaneDescription == null) {\r
320 jScrollPaneDescription = new JScrollPane();\r
321 jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 220, 320, 80));\r
322 jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r
323 jScrollPaneDescription.setViewportView(getJTextAreaDescription());\r
324 }\r
325 return jScrollPaneDescription;\r
326 }\r
327\r
328 /**\r
329 This method initializes jTextFieldAbstract \r
330 \r
331 @return javax.swing.JTextField jTextFieldAbstract\r
332 \r
333 **/\r
334 private JTextField getJTextFieldAbstract() {\r
335 if (jTextFieldAbstract == null) {\r
336 jTextFieldAbstract = new JTextField();\r
337 jTextFieldAbstract.setBounds(new java.awt.Rectangle(160,195,320,20));\r
338 jTextFieldAbstract.setPreferredSize(new java.awt.Dimension(320, 20));\r
339 jTextFieldAbstract.addFocusListener(new FocusAdapter(){\r
340 public void focusLost(FocusEvent e){\r
341 sfc.setSpdHdrAbs(jTextFieldAbstract.getText());\r
342 }\r
343 });\r
344 }\r
345 return jTextFieldAbstract;\r
346 }\r
347\r
348 /**\r
349 This method initializes jTextFieldCopyright \r
350 \r
351 @return javax.swing.JTextField jTextFieldCopyright\r
352 \r
353 **/\r
354 private JTextField getJTextFieldCopyright() {\r
355 if (jTextFieldCopyright == null) {\r
356 jTextFieldCopyright = new JTextField();\r
357 jTextFieldCopyright.setBounds(new java.awt.Rectangle(160,330,320, 20));\r
358 jTextFieldCopyright.setPreferredSize(new java.awt.Dimension(320,20));\r
359 jTextFieldCopyright.addFocusListener(new FocusAdapter(){\r
360 public void focusLost(FocusEvent e){\r
361 sfc.setSpdHdrCopyright(jTextFieldCopyright.getText());\r
362 } \r
363 });\r
364 }\r
365 return jTextFieldCopyright;\r
366 }\r
367\r
368 /**\r
369 * This method initializes jTextField \r
370 * \r
371 * @return javax.swing.JTextField \r
372 */\r
373 private JTextField getJTextField() {\r
374 if (jTextField == null) {\r
375 jTextField = new JTextField();\r
376 jTextField.setBounds(new java.awt.Rectangle(160,170,320,20));\r
377 jTextField.setPreferredSize(new java.awt.Dimension(320, 20));\r
378 jTextField.addFocusListener(new FocusAdapter(){\r
379 public void focusLost(FocusEvent e){\r
380 sfc.setSpdHdrLicense(jTextAreaLicense.getText());\r
381 sfc.setSpdHdrUrl(jTextField.getText());\r
382 } \r
383 });\r
384 }\r
385 return jTextField;\r
386 }\r
387\r
388 public static void main(String[] args) {\r
389 new SpdHeader().setVisible(true);\r
390 }\r
391\r
392 /**\r
393 This is the default constructor\r
394 \r
395 **/\r
396 public SpdHeader() {\r
397 super();\r
398 init();\r
399 this.setVisible(true);\r
400 }\r
401\r
402 /**\r
403 This is the override edit constructor\r
404 \r
405 @param inspdHeader The input data of spdHeaderDocument.spdHeader\r
406 \r
407 **/\r
408 public SpdHeader(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa) {\r
409 this();\r
410 sfc = new SpdFileContents(inPsa);\r
411 init(sfc);\r
412 }\r
413 /**\r
414 This method initializes this\r
415 \r
416 **/\r
417 private void init() {\r
418 this.setContentPane(getTopScrollPane());\r
419 this.setTitle("Package Surface Area Header");\r
420 initFrame();\r
421 }\r
422\r
423 /**\r
424 This method initializes this\r
425 Fill values to all fields if these values are not empty\r
426 \r
427 @param inspdHeader The input data of spdHeaderDocument.spdHeader\r
428 \r
429 **/\r
430 private void init(SpdFileContents sfc) {\r
431 if (sfc.getSpdHdrPkgName() != null) {\r
432 jTextFieldBaseName.setText(sfc.getSpdHdrPkgName());\r
433 }\r
434 if (sfc.getSpdHdrGuidValue() != null) {\r
435 jTextFieldGuid.setText(sfc.getSpdHdrGuidValue());\r
436 }\r
437 if (sfc.getSpdHdrVer() != null) {\r
438 jTextFieldVersion.setText(sfc.getSpdHdrVer());\r
439 }\r
440 if (sfc.getSpdHdrLicense() != null) {\r
441 jTextAreaLicense.setText(sfc.getSpdHdrLicense());\r
442 }\r
443 if (sfc.getSpdHdrUrl() != null) {\r
444 jTextField.setText(sfc.getSpdHdrUrl());\r
445 }\r
446 if (sfc.getSpdHdrCopyright() != null) {\r
447 jTextFieldCopyright.setText(sfc.getSpdHdrCopyright());\r
448 }\r
449 if (sfc.getSpdHdrAbs() != null) {\r
450 jTextFieldAbstract.setText(sfc.getSpdHdrAbs());\r
451 }\r
452 if (sfc.getSpdHdrDescription() != null) {\r
453 jTextAreaDescription.setText(sfc.getSpdHdrDescription());\r
454 }\r
455 if (sfc.getSpdHdrSpec() != null) {\r
456 jTextFieldSpecification.setText(sfc.getSpdHdrSpec());\r
457 }\r
458\r
459 }\r
460\r
461 /**\r
462 This method initializes jContentPane\r
463 \r
464 @return javax.swing.JPanel jContentPane\r
465 \r
466 **/\r
467 private JPanel getJContentPane() {\r
468 if (jContentPane == null) {\r
469 jLabel = new JLabel();\r
470 jLabel.setBounds(new java.awt.Rectangle(15,170,140,20));\r
471 jLabel.setText("URL");\r
472 jContentPane = new JPanel();\r
473 jContentPane.setLayout(null);\r
474 jContentPane.setLocation(new java.awt.Point(0, 0));\r
475 jContentPane.setPreferredSize(new java.awt.Dimension(500, 524));\r
476 jLabelAbstract = new JLabel();\r
477 jLabelAbstract.setBounds(new java.awt.Rectangle(15, 220, 140, 20));\r
478 jLabelAbstract.setText("Description");\r
479 jLabelSpecification = new JLabel();\r
480 jLabelSpecification.setText("Specification");\r
481 jLabelSpecification.setBounds(new java.awt.Rectangle(15, 305, 140, 20));\r
482 jLabelDescription = new JLabel();\r
483 jLabelDescription.setText("Abstract");\r
484 jLabelDescription.setBounds(new java.awt.Rectangle(15, 195, 140, 20));\r
485 jLabelCopyright = new JLabel();\r
486 jLabelCopyright.setText("Copyright");\r
487 jLabelCopyright.setBounds(new java.awt.Rectangle(15, 330, 140, 20));\r
488 jLabelLicense = new JLabel();\r
489 jLabelLicense.setText("License");\r
490 jLabelLicense.setBounds(new java.awt.Rectangle(15, 85, 140, 20));\r
491 jLabelVersion = new JLabel();\r
492 jLabelVersion.setText("Version");\r
493 jLabelVersion.setBounds(new java.awt.Rectangle(15, 60, 140, 20));\r
494 jLabelGuid = new JLabel();\r
495 jLabelGuid.setPreferredSize(new java.awt.Dimension(25, 15));\r
496 jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));\r
497 jLabelGuid.setText("Guid");\r
498 jLabelBaseName = new JLabel();\r
499 jLabelBaseName.setText("Package Name");\r
500 jLabelBaseName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));\r
501 jContentPane.add(jLabelBaseName, null);\r
502 jContentPane.add(getJTextFieldBaseName(), null);\r
503 jContentPane.add(jLabelGuid, null);\r
504 jContentPane.add(getJTextFieldGuid(), null);\r
505 jContentPane.add(jLabelVersion, null);\r
506 jContentPane.add(getJTextFieldVersion(), null);\r
507 jContentPane.add(getJButtonGenerateGuid(), null);\r
508 jContentPane.add(jLabelLicense, null);\r
509 jContentPane.add(jLabelCopyright, null);\r
510 jContentPane.add(jLabelDescription, null);\r
511 jContentPane.add(jLabelSpecification, null);\r
512 jContentPane.add(getJTextFieldSpecification(), null);\r
513 jContentPane.add(getJButtonOk(), null);\r
514 jContentPane.add(getJButtonCancel(), null);\r
515 jContentPane.add(getJScrollPaneLicense(), null);\r
516 jContentPane.add(getJScrollPaneDescription(), null);\r
517 jContentPane.add(jLabelAbstract, null);\r
518 jContentPane.add(getJTextFieldAbstract(), null);\r
519 jStarLabel1 = new StarLabel();\r
520 jStarLabel1.setLocation(new java.awt.Point(0, 10));\r
521 jStarLabel2 = new StarLabel();\r
522 jStarLabel2.setLocation(new java.awt.Point(0, 35));\r
523 jStarLabel3 = new StarLabel();\r
524 jStarLabel3.setLocation(new java.awt.Point(0, 60));\r
525 jStarLabel4 = new StarLabel();\r
526 jStarLabel4.setLocation(new java.awt.Point(0, 85));\r
527 jStarLabel5 = new StarLabel();\r
528 jStarLabel5.setLocation(new java.awt.Point(0, 330));\r
529 jStarLabel6 = new StarLabel();\r
530 jStarLabel6.setLocation(new java.awt.Point(0, 195));\r
531 jStarLabel7 = new StarLabel();\r
532 jStarLabel7.setLocation(new java.awt.Point(0, 305));\r
533 jStarLabel7.setEnabled(false);\r
534 jStarLabel9 = new StarLabel();\r
535 jStarLabel9.setLocation(new java.awt.Point(0, 220));\r
536 jContentPane.add(jStarLabel1, null);\r
537 jContentPane.add(jStarLabel2, null);\r
538 jContentPane.add(jStarLabel3, null);\r
539 jContentPane.add(jStarLabel4, null);\r
540 jContentPane.add(jStarLabel5, null);\r
541 jContentPane.add(jStarLabel6, null);\r
542 jContentPane.add(jStarLabel7, null);\r
543 jContentPane.add(jStarLabel9, null);\r
544 jContentPane.add(getJTextFieldCopyright(), null);\r
545\r
546 jContentPane.add(jLabel, null);\r
547 jContentPane.add(getJTextField(), null);\r
548 }\r
549 return jContentPane;\r
550 }\r
551\r
552 /* (non-Javadoc)\r
553 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r
554 *\r
555 * Override actionPerformed to listen all actions\r
556 *\r
557 */\r
558 public void actionPerformed(ActionEvent arg0) {\r
559 if (arg0.getSource() == jButtonOk) {\r
560 this.save();\r
561 this.setEdited(true);\r
562 }\r
563 if (arg0.getSource() == jButtonCancel) {\r
564 this.setEdited(false);\r
565 }\r
566 if (arg0.getSource() == jButtonGenerateGuid) {\r
567 //ToDo: invoke GuidValueEditor\r
568 jTextFieldGuid.setText(Tools.generateUuidString());\r
569 sfc.setSpdHdrGuidValue(jTextFieldGuid.getText());\r
570 }\r
571 }\r
572\r
573 /**\r
574 Data validation for all fields\r
575 \r
576 @retval true - All datas are valid\r
577 @retval false - At least one data is invalid\r
578 \r
579 **/\r
580 public boolean check() {\r
581 //\r
582 // Check if all required fields are not empty\r
583 //\r
584 if (isEmpty(this.jTextFieldBaseName.getText())) {\r
585 Log.err("Base Name couldn't be empty");\r
586 return false;\r
587 }\r
588 if (isEmpty(this.jTextFieldGuid.getText())) {\r
589 Log.err("Guid couldn't be empty");\r
590 return false;\r
591 }\r
592 if (isEmpty(this.jTextFieldVersion.getText())) {\r
593 Log.err("Version couldn't be empty");\r
594 return false;\r
595 }\r
596 if (isEmpty(this.jTextAreaLicense.getText())) {\r
597 Log.err("License couldn't be empty");\r
598 return false;\r
599 }\r
600 if (isEmpty(this.jTextFieldCopyright.getText())) {\r
601 Log.err("Copyright couldn't be empty");\r
602 return false;\r
603 }\r
604 if (isEmpty(this.jTextAreaDescription.getText())) {\r
605 Log.err("Description couldn't be empty");\r
606 return false;\r
607 }\r
608 if (isEmpty(this.jTextFieldAbstract.getText())) {\r
609 Log.err("Abstract couldn't be empty");\r
610 return false;\r
611 }\r
612\r
613 //\r
614 // Check if all fields have correct data types \r
615 //\r
616 if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {\r
617 Log.err("Incorrect data type for Base Name");\r
618 return false;\r
619 }\r
620 if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {\r
621 Log.err("Incorrect data type for Guid");\r
622 return false;\r
623 }\r
624 if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {\r
625 Log.err("Incorrect data type for Abstract");\r
626 return false;\r
627 }\r
628 if (!DataValidation.isCopyright(this.jTextFieldCopyright.getText())) {\r
629 Log.err("Incorrect data type for Copyright");\r
630 return false;\r
631 }\r
632 return true;\r
633 }\r
634\r
635 /**\r
636 Save all components of Spd Header\r
637 if exists spdHeader, set the value directly\r
638 if not exists spdHeader, new an instance first\r
639 \r
640 **/\r
641 public void save() {\r
642 try {\r
643 \r
644 } catch (Exception e) {\r
645 Log.err("Save Package", e.getMessage());\r
646 }\r
647 }\r
648\r
649 /**\r
650 This method initializes Package type and Compontent type\r
651 \r
652 **/\r
653 private void initFrame() {\r
654 \r
655 }\r
656\r
657 /* (non-Javadoc)\r
658 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)\r
659 * \r
660 * Override componentResized to resize all components when frame's size is changed\r
661 */\r
662 public void componentResized(ComponentEvent arg0) {\r
663 int intPreferredWidth = 500;\r
664 int intCurrentWidth = this.getJContentPane().getWidth();\r
665 \r
666 resizeComponentWidth(this.jTextFieldBaseName, intCurrentWidth,intPreferredWidth);\r
667 resizeComponentWidth(this.jTextFieldGuid, intCurrentWidth,intPreferredWidth);\r
668 resizeComponentWidth(this.jTextFieldVersion, intCurrentWidth,intPreferredWidth);\r
669 resizeComponentWidth(this.jScrollPaneLicense, intCurrentWidth,intPreferredWidth);\r
670 resizeComponentWidth(this.jTextFieldCopyright, intCurrentWidth,intPreferredWidth);\r
671 resizeComponentWidth(this.jScrollPaneDescription, intCurrentWidth,intPreferredWidth);\r
672 resizeComponentWidth(this.jTextFieldSpecification, intCurrentWidth,intPreferredWidth);\r
673 resizeComponentWidth(this.jTextFieldAbstract, intCurrentWidth,intPreferredWidth);\r
674 relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, jButtonGenerateGuid.getWidth(),30);\r
675 }\r
676\r
677 private JScrollPane getTopScrollPane() {\r
678 if (topScrollPane == null){\r
679 topScrollPane = new JScrollPane();\r
680 topScrollPane.setViewportView(getJContentPane());\r
681 }\r
682 return topScrollPane;\r
683 }\r
684}\r