Modify FrameworkModules editor for FPD files to meet the new PCD type adjust operatio...
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / packaging / ui / SpdHeader.java
1 /** @file
2
3 The file is used to create, update spdHeader of Spd 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.packaging.ui;
17
18 import java.awt.event.ActionEvent;
19 import java.awt.event.ComponentEvent;
20 import java.awt.event.FocusAdapter;
21 import java.awt.event.FocusEvent;
22
23 import javax.swing.JButton;
24 import javax.swing.JFrame;
25 import javax.swing.JLabel;
26 import javax.swing.JOptionPane;
27 import javax.swing.JPanel;
28 import javax.swing.JScrollPane;
29 import javax.swing.JTextArea;
30 import javax.swing.JTextField;
31
32 import org.tianocore.PackageSurfaceAreaDocument;
33 import org.tianocore.frameworkwizard.common.DataValidation;
34 import org.tianocore.frameworkwizard.common.Tools;
35 import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;
36 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
37 import org.tianocore.frameworkwizard.common.ui.StarLabel;
38 import javax.swing.JCheckBox;
39 import javax.swing.event.DocumentEvent;
40 import javax.swing.event.DocumentListener;
41
42 /**
43 The class is used to create, update spdHeader of Spd file
44 It extends IInternalFrame
45
46 @since PackageEditor 1.0
47
48 **/
49 public class SpdHeader extends IInternalFrame implements DocumentListener{
50
51 private int dialogWidth = 560;
52
53 private int labelColumn = 12;
54
55 private int labelWidth = 155;
56
57 private int buttonWidth = 60;
58
59 private final int valueColumn = 168;
60
61 private final int valueWidth = 320;
62
63 private final int specWidth = 420;
64
65 private int shortValueWidth = valueWidth - (buttonWidth + 5);
66
67 private final int oneRowHeight = 20;
68
69 private final int threeRowHeight = 60;
70
71 private final int fourRowHeight = 80;
72
73 private final int rowSep = 5;
74
75 private final int rowOne = 12;
76
77 private final int rowTwo = rowOne + oneRowHeight + rowSep;
78
79 private final int rowThree = rowTwo + oneRowHeight + rowSep;
80
81 private final int rowFour = rowThree + oneRowHeight + rowSep;
82
83 private final int rowFive = rowFour + threeRowHeight + rowSep;
84
85 private final int rowSix = rowFive + fourRowHeight + rowSep;
86
87 private final int rowSeven = rowSix + oneRowHeight + rowSep;
88
89 private final int rowEight = rowSeven + oneRowHeight + rowSep;
90
91 private final int rowNine = rowEight + fourRowHeight + rowSep;
92
93 private final int rowTen = rowNine + oneRowHeight + rowSep;
94
95 private int dialogHeight = rowTen + threeRowHeight;
96
97 ///
98 /// Define class Serial Version UID
99 ///
100 private static final long serialVersionUID = -8152099582923006900L;
101
102 //
103 //Define class members
104 //
105 static JFrame frame;
106
107 private JPanel jContentPane = null;
108
109 private JLabel jPackageNameLabel = null;
110
111 private JTextField jPackageNameTextField = null;
112
113 private JLabel jGuidLabel = null;
114
115 private JTextField jGuidTextField = null;
116
117 private JLabel jVersionLabel = null;
118
119 private JTextField jVersionTextField = null;
120
121 private JButton jGenerateGuidButton = null;
122
123 private JLabel jLicenseLabel = null;
124
125 private JTextArea jLicenseTextArea = null;
126
127 private JLabel jLabelCopyright = null;
128
129 private JLabel jDescriptionLabel = null;
130
131 private JTextArea jDescriptionTextArea = null;
132
133 private JTextField jSpecificationTextField = null;
134
135 private JScrollPane jLicenseScrollPane = null;
136
137 private JScrollPane jDescriptionScrollPane = null;
138
139 private JScrollPane jCopyrightScrollPane = null;
140
141 private JLabel jAbstractLabel = null;
142
143 private JTextField jAbstractTextField = null;
144
145 private StarLabel jStarLabel1 = null;
146
147 private StarLabel jStarLabel2 = null;
148
149 private StarLabel jStarLabel3 = null;
150
151 private StarLabel jStarLabel4 = null;
152
153 private StarLabel jStarLabel5 = null;
154
155 private StarLabel jStarLabel6 = null;
156
157 private StarLabel jStarLabel7 = null;
158
159 private StarLabel jStarLabel8 = null;
160
161 private StarLabel jStarLabel9 = null;
162
163 private SpdFileContents sfc = null;
164
165 private OpeningPackageType docConsole = null;
166
167 private JTextArea jCopyrightTextArea = null;
168
169 private JScrollPane topScrollPane = null;
170
171 private JLabel jUrlLabel = null;
172
173 private JTextField jUrlTextField = null;
174
175 private JCheckBox jCheckBoxRdOnly = null;
176
177 private JCheckBox jCheckBoxRePkg = null;
178
179 /**
180 This method initializes jPackageNameTextField
181
182 @return javax.swing.JTextField jPackageNameTextField
183
184 **/
185 private JTextField getJPackageNameTextField() {
186 if (jPackageNameTextField == null) {
187 jPackageNameTextField = new JTextField();
188 jPackageNameTextField.setBounds(new java.awt.Rectangle(valueColumn, rowOne, valueWidth, oneRowHeight));
189 jPackageNameTextField.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));
190 jPackageNameTextField.getDocument().addDocumentListener(this);
191 jPackageNameTextField.addFocusListener(new FocusAdapter() {
192 public void focusLost(FocusEvent e) {
193 if (!DataValidation.isUiNameType(jPackageNameTextField.getText())) {
194 JOptionPane.showMessageDialog(frame, "Package Name must start with a letter.");
195 return;
196 }
197 if (jPackageNameTextField.getText().equals(sfc.getSpdHdrPkgName())) {
198 return;
199 }
200 sfc.setSpdHdrPkgName(jPackageNameTextField.getText());
201 }
202 });
203 }
204 return jPackageNameTextField;
205 }
206
207 /**
208 This method initializes jGuidTextField
209
210 @return javax.swing.JTextField jGuidTextField
211
212 **/
213 private JTextField getJGuidTextField() {
214 if (jGuidTextField == null) {
215 jGuidTextField = new JTextField();
216 jGuidTextField.setBounds(new java.awt.Rectangle(valueColumn, rowTwo, shortValueWidth, oneRowHeight));
217 jGuidTextField.setPreferredSize(new java.awt.Dimension(shortValueWidth, oneRowHeight));
218 jGuidTextField.getDocument().addDocumentListener(this);
219 jGuidTextField.addFocusListener(new FocusAdapter() {
220 public void focusLost(FocusEvent e) {
221 if (!DataValidation.isGuid(jGuidTextField.getText())) {
222 JOptionPane.showMessageDialog(frame, "Guid must be in registry (8-4-4-4-12) format.");
223 return;
224 }
225 if (jGuidTextField.getText().equals(sfc.getSpdHdrGuidValue())) {
226 return;
227 }
228 sfc.setSpdHdrGuidValue(jGuidTextField.getText());
229 }
230 });
231 }
232 return jGuidTextField;
233 }
234
235 /**
236 This method initializes jVersionTextField
237
238 @return javax.swing.JTextField jVersionTextField
239
240 **/
241 private JTextField getJVersionTextField() {
242 if (jVersionTextField == null) {
243 jVersionTextField = new JTextField();
244 jVersionTextField.setBounds(new java.awt.Rectangle(valueColumn, rowThree, valueWidth, oneRowHeight));
245 jVersionTextField.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));
246 jVersionTextField.getDocument().addDocumentListener(this);
247 jVersionTextField.addFocusListener(new FocusAdapter() {
248 public void focusLost(FocusEvent e) {
249 if (!DataValidation.isVersion(jVersionTextField.getText())) {
250 JOptionPane.showMessageDialog(frame, "Version must start with a number.");
251 return;
252 }
253 if (jVersionTextField.getText().equals(sfc.getSpdHdrVer())) {
254 return;
255 }
256 sfc.setSpdHdrVer(jVersionTextField.getText());
257 }
258 });
259 }
260 return jVersionTextField;
261 }
262
263 /**
264 This method initializes jGenerateGuidButton
265
266 @return javax.swing.JButton jGenerateGuidButton
267
268 **/
269 private JButton getJGenerateGuidButton() {
270 if (jGenerateGuidButton == null) {
271 jGenerateGuidButton = new JButton();
272 jGenerateGuidButton.setBounds(new java.awt.Rectangle(valueColumn + shortValueWidth + 5, rowTwo, buttonWidth, oneRowHeight));
273 jGenerateGuidButton.setText("GEN");
274 jGenerateGuidButton.addActionListener(this);
275 }
276 return jGenerateGuidButton;
277 }
278
279 /**
280 This method initializes jLicenseTextArea
281
282 @return javax.swing.JTextArea jLicenseTextArea
283
284 **/
285 private JTextArea getJLicenseTextArea() {
286 if (jLicenseTextArea == null) {
287 jLicenseTextArea = new JTextArea();
288 jLicenseTextArea.setLineWrap(true);
289 jLicenseTextArea.getDocument().addDocumentListener(this);
290 jLicenseTextArea.addFocusListener(new FocusAdapter() {
291 public void focusLost(FocusEvent e) {
292 if (jLicenseTextArea.getText().length() == 0) {
293 JOptionPane.showMessageDialog(frame, "License is a required field.");
294 return;
295 }
296 if (jLicenseTextArea.getText().equals(sfc.getSpdHdrLicense())) {
297 return;
298 }
299 sfc.setSpdHdrLicense(jLicenseTextArea.getText());
300 }
301 });
302 }
303 return jLicenseTextArea;
304 }
305
306 /**
307 This method initializes jDescriptionTextArea
308
309 @return javax.swing.JTextArea jDescriptionTextArea
310
311 **/
312 private JTextArea getJDescriptionTextArea() {
313 if (jDescriptionTextArea == null) {
314 jDescriptionTextArea = new JTextArea();
315 jDescriptionTextArea.setLineWrap(true);
316 jDescriptionTextArea.getDocument().addDocumentListener(this);
317 jDescriptionTextArea.addFocusListener(new FocusAdapter() {
318 public void focusLost(FocusEvent e) {
319 if (jDescriptionTextArea.getText().length() == 0) {
320 JOptionPane
321 .showMessageDialog(frame,
322 "Description is a required field, and should reflect the contents of the package.");
323 return;
324 }
325 if (jDescriptionTextArea.getText().equals(sfc.getSpdHdrDescription())) {
326 return;
327 }
328 sfc.setSpdHdrDescription(jDescriptionTextArea.getText());
329 }
330 });
331 }
332 return jDescriptionTextArea;
333 }
334
335 /**
336 This method initializes jSpecificationTextField
337
338 @return javax.swing.JTextField jSpecificationTextField
339
340 **/
341 private JTextField getJSpecificationTextField() {
342 if (jSpecificationTextField == null) {
343 jSpecificationTextField = new JTextField();
344 jSpecificationTextField.setBounds(new java.awt.Rectangle(labelColumn, dialogHeight - 40, specWidth, oneRowHeight));
345 jSpecificationTextField.setEditable(false);
346 jSpecificationTextField.setPreferredSize(new java.awt.Dimension(specWidth, oneRowHeight));
347 jSpecificationTextField.setLocation(new java.awt.Point(2, dialogHeight - oneRowHeight));
348 jSpecificationTextField.setBorder(null);
349
350 // jSpecificationTextField.addFocusListener(new FocusAdapter(){
351 // public void focusLost(FocusEvent e){
352 // sfc.setSpdHdrSpec(jSpecificationTextField.getText());
353 // }
354 // });
355 }
356 return jSpecificationTextField;
357 }
358
359 /**
360 This method initializes jLicenseScrollPane
361
362 @return javax.swing.JScrollPane jLicenseScrollPane
363
364 **/
365 private JScrollPane getJLicenseScrollPane() {
366 if (jLicenseScrollPane == null) {
367 jLicenseScrollPane = new JScrollPane();
368 jLicenseScrollPane.setBounds(new java.awt.Rectangle(valueColumn, rowFive, valueWidth, fourRowHeight));
369 jLicenseScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
370 jLicenseScrollPane.setPreferredSize(new java.awt.Dimension(valueWidth, fourRowHeight));
371 jLicenseScrollPane.setViewportView(getJLicenseTextArea());
372 }
373 return jLicenseScrollPane;
374 }
375
376 /**
377 This method initializes jDescriptionScrollPane
378
379 @return javax.swing.JScrollPane jDescriptionScrollPane
380
381 **/
382 private JScrollPane getJDescriptionScrollPane() {
383 if (jDescriptionScrollPane == null) {
384 jDescriptionScrollPane = new JScrollPane();
385 jDescriptionScrollPane.setBounds(new java.awt.Rectangle(valueColumn, rowEight, valueWidth, fourRowHeight));
386 jDescriptionScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
387 jDescriptionScrollPane.setPreferredSize(new java.awt.Dimension(valueWidth, fourRowHeight));
388 jDescriptionScrollPane.setViewportView(getJDescriptionTextArea());
389 }
390 return jDescriptionScrollPane;
391 }
392
393 /**
394 This method initializes jAbstractTextField
395
396 @return javax.swing.JTextField jAbstractTextField
397
398 **/
399 private JTextField getJAbstractTextField() {
400 if (jAbstractTextField == null) {
401 jAbstractTextField = new JTextField();
402 jAbstractTextField.setBounds(new java.awt.Rectangle(valueColumn, rowSeven, valueWidth, oneRowHeight));
403 jAbstractTextField.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));
404 jAbstractTextField.getDocument().addDocumentListener(this);
405 jAbstractTextField.addFocusListener(new FocusAdapter() {
406 public void focusLost(FocusEvent e) {
407 if (!DataValidation.isAbstract(jAbstractTextField.getText())) {
408 JOptionPane.showMessageDialog(frame, "Abstract could NOT be empty.");
409 return;
410 }
411 if (jAbstractTextField.getText().equals(sfc.getSpdHdrAbs())) {
412 return;
413 }
414 sfc.setSpdHdrAbs(jAbstractTextField.getText());
415 }
416 });
417 }
418 return jAbstractTextField;
419 }
420
421 private JScrollPane getCopyrightScrollPane() {
422 if (jCopyrightScrollPane == null) {
423 jCopyrightScrollPane = new JScrollPane();
424 jCopyrightScrollPane.setBounds(new java.awt.Rectangle(valueColumn, rowFour, valueWidth, threeRowHeight));
425 jCopyrightScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
426 jCopyrightScrollPane.setPreferredSize(new java.awt.Dimension(valueWidth, threeRowHeight));
427 jCopyrightScrollPane.setViewportView(getJCopyrightTextArea());
428 }
429 return jCopyrightScrollPane;
430 }
431 /**
432 This method initializes jTextFieldCopyright
433
434 @return javax.swing.JTextField jTextFieldCopyright
435
436 **/
437 private JTextArea getJCopyrightTextArea() {
438 if (jCopyrightTextArea == null) {
439 jCopyrightTextArea = new JTextArea();
440 jCopyrightTextArea.setWrapStyleWord(true);
441 jCopyrightTextArea.setLineWrap(true);
442 jCopyrightTextArea.getDocument().addDocumentListener(this);
443 jCopyrightTextArea.addFocusListener(new FocusAdapter() {
444 public void focusLost(FocusEvent e) {
445 if (!DataValidation.isCopyright(jCopyrightTextArea.getText())) {
446 JOptionPane.showMessageDialog(frame, "Copyright must be entered.");
447 return;
448 }
449 if (jCopyrightTextArea.getText().equals(sfc.getSpdHdrCopyright())) {
450 return;
451 }
452 sfc.setSpdHdrCopyright(jCopyrightTextArea.getText());
453 }
454 });
455 }
456 return jCopyrightTextArea;
457 }
458
459 /**
460 * This method initializes jTextField
461 *
462 * @return javax.swing.JTextField
463 */
464 private JTextField getJUrlTextField() {
465 if (jUrlTextField == null) {
466 jUrlTextField = new JTextField();
467 jUrlTextField.setBounds(new java.awt.Rectangle(valueColumn, rowSix, valueWidth, oneRowHeight));
468 jUrlTextField.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));
469 jUrlTextField.getDocument().addDocumentListener(this);
470 jUrlTextField.addFocusListener(new FocusAdapter() {
471 public void focusLost(FocusEvent e) {
472 if (jUrlTextField.getText().length() == 0 && sfc.getSpdHdrUrl() == null) {
473 return;
474 }
475 if (jUrlTextField.getText().equals(sfc.getSpdHdrUrl())) {
476 return;
477 }
478 sfc.setSpdHdrLicense(jLicenseTextArea.getText());
479 sfc.setSpdHdrUrl(jUrlTextField.getText());
480 }
481 });
482 }
483 return jUrlTextField;
484 }
485
486 /**
487 * This method initializes jCheckBoxRdOnly
488 *
489 * @return javax.swing.JCheckBox
490 */
491 private JCheckBox getJCheckBoxRdOnly() {
492 if (jCheckBoxRdOnly == null) {
493 jCheckBoxRdOnly = new JCheckBox();
494 jCheckBoxRdOnly.setText("Read Only");
495 jCheckBoxRdOnly.setLocation(new java.awt.Point(labelColumn, rowNine));
496 jCheckBoxRdOnly.setSize(new java.awt.Dimension(labelWidth, oneRowHeight));
497 jCheckBoxRdOnly.addItemListener(new java.awt.event.ItemListener() {
498 public void itemStateChanged(java.awt.event.ItemEvent e) {
499 if (docConsole != null) {
500 docConsole.setSaved(false);
501 }
502 sfc.setSpdPkgDefsRdOnly(jCheckBoxRdOnly.isSelected()+"");
503 initFrame();
504 }
505 });
506 }
507 return jCheckBoxRdOnly;
508 }
509
510 /**
511 * This method initializes jCheckBoxRePkg
512 *
513 * @return javax.swing.JCheckBox
514 */
515 private JCheckBox getJCheckBoxRePkg() {
516 if (jCheckBoxRePkg == null) {
517 jCheckBoxRePkg = new JCheckBox();
518 jCheckBoxRePkg.setLocation(new java.awt.Point(labelColumn, rowTen));
519 jCheckBoxRePkg.setText("RePackagable");
520 jCheckBoxRePkg.setSize(new java.awt.Dimension(labelWidth, oneRowHeight));
521 jCheckBoxRePkg.addItemListener(new java.awt.event.ItemListener() {
522 public void itemStateChanged(java.awt.event.ItemEvent e) {
523 if (docConsole != null) {
524 docConsole.setSaved(false);
525 }
526 sfc.setSpdPkgDefsRePkg(jCheckBoxRePkg.isSelected()+"");
527 }
528 });
529 }
530 return jCheckBoxRePkg;
531 }
532
533 public static void main(String[] args) {
534 new SpdHeader().setVisible(true);
535 }
536
537 /**
538 This is the default constructor
539
540 **/
541 public SpdHeader() {
542 super();
543 init();
544 this.setVisible(true);
545 }
546
547 /**
548 This is the override edit constructor
549
550 @param inspdHeader The input data of spdHeaderDocument.spdHeader
551
552 **/
553 public SpdHeader(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa) {
554 this();
555 sfc = new SpdFileContents(inPsa);
556 init(sfc);
557 }
558
559 public SpdHeader(OpeningPackageType opt) {
560 this(opt.getXmlSpd());
561 docConsole = opt;
562 initFrame();
563 }
564
565 /**
566 This method initializes this
567
568 **/
569 private void init() {
570 this.setContentPane(getTopScrollPane());
571 this.setTitle("Package Surface Area Header");
572 }
573
574 /**
575 This method initializes this
576 Fill values to all fields if these values are not empty
577
578 @param inspdHeader The input data of spdHeaderDocument.spdHeader
579
580 **/
581 private void init(SpdFileContents sfc) {
582 if (sfc.getSpdHdrPkgName() != null) {
583 jPackageNameTextField.setText(sfc.getSpdHdrPkgName());
584 }
585 if (sfc.getSpdHdrGuidValue() != null) {
586 jGuidTextField.setText(sfc.getSpdHdrGuidValue());
587 }
588 if (sfc.getSpdHdrVer() != null) {
589 jVersionTextField.setText(sfc.getSpdHdrVer());
590 }
591 if (sfc.getSpdHdrLicense() != null) {
592 jLicenseTextArea.setText(sfc.getSpdHdrLicense());
593 }
594 if (sfc.getSpdHdrUrl() != null) {
595 jUrlTextField.setText(sfc.getSpdHdrUrl());
596 }
597 if (sfc.getSpdHdrCopyright() != null) {
598 jCopyrightTextArea.setText(sfc.getSpdHdrCopyright());
599 }
600 if (sfc.getSpdHdrAbs() != null) {
601 jAbstractTextField.setText(sfc.getSpdHdrAbs());
602 }
603 if (sfc.getSpdHdrDescription() != null) {
604 jDescriptionTextArea.setText(sfc.getSpdHdrDescription());
605 }
606 if (sfc.getSpdHdrSpec() != null) {
607 jSpecificationTextField.setText(sfc.getSpdHdrSpec());
608 }
609 sfc.setSpdHdrSpec(jSpecificationTextField.getText());
610
611 if (!sfc.getSpdPkgDefsRdOnly().equals("true")) {
612 sfc.setSpdPkgDefsRdOnly("false");
613 jCheckBoxRdOnly.setSelected(false);
614 } else {
615 jCheckBoxRdOnly.setSelected(true);
616 }
617 if (!sfc.getSpdPkgDefsRePkg().equals("true")) {
618 sfc.setSpdPkgDefsRePkg("false");
619 jCheckBoxRePkg.setSelected(false);
620 } else {
621 jCheckBoxRePkg.setSelected(true);
622 }
623
624 }
625
626 /**
627 This method initializes jContentPane
628
629 @return javax.swing.JPanel jContentPane
630
631 **/
632 private JPanel getJContentPane() {
633 if (jContentPane == null) {
634 jStarLabel1 = new StarLabel();
635 jStarLabel1.setLocation(new java.awt.Point(2, rowOne));
636 jStarLabel2 = new StarLabel();
637 jStarLabel2.setLocation(new java.awt.Point(2, rowTwo));
638 jStarLabel3 = new StarLabel();
639 jStarLabel3.setLocation(new java.awt.Point(2, rowThree));
640 jStarLabel4 = new StarLabel();
641 jStarLabel4.setLocation(new java.awt.Point(2, rowFour));
642 jStarLabel5 = new StarLabel();
643 jStarLabel5.setLocation(new java.awt.Point(2, rowFive));
644 jStarLabel6 = new StarLabel();
645 jStarLabel6.setLocation(new java.awt.Point(2, rowSeven));
646 jStarLabel7 = new StarLabel();
647 jStarLabel7.setLocation(new java.awt.Point(2, rowEight));
648 jStarLabel8 = new StarLabel();
649 jStarLabel8.setLocation(new java.awt.Point(2, rowNine));
650 jStarLabel8.setVisible(false);
651 jStarLabel9 = new StarLabel();
652 jStarLabel9.setLocation(new java.awt.Point(2, rowTen));
653
654 jStarLabel9.setVisible(false);
655 jPackageNameLabel = new JLabel();
656 jPackageNameLabel.setText("Package Name");
657 jPackageNameLabel.setBounds(new java.awt.Rectangle(labelColumn, rowOne, labelWidth, oneRowHeight));
658 jGuidLabel = new JLabel();
659 jGuidLabel.setBounds(new java.awt.Rectangle(labelColumn, rowTwo, labelWidth, oneRowHeight));
660 jGuidLabel.setText("Guid");
661 jVersionLabel = new JLabel();
662 jVersionLabel.setText("Version");
663 jVersionLabel.setBounds(new java.awt.Rectangle(labelColumn, rowThree, labelWidth, oneRowHeight));
664 jLabelCopyright = new JLabel();
665 jLabelCopyright.setText("Copyright");
666 jLabelCopyright.setBounds(new java.awt.Rectangle(labelColumn, rowFour, labelWidth, oneRowHeight));
667 jLicenseLabel = new JLabel();
668 jLicenseLabel.setText("License");
669 jLicenseLabel.setBounds(new java.awt.Rectangle(labelColumn, rowFive, labelWidth, oneRowHeight));
670 jUrlLabel = new JLabel();
671 jUrlLabel.setBounds(new java.awt.Rectangle(labelColumn, rowSix, labelWidth, oneRowHeight));
672 jUrlLabel.setText("URL");
673 jAbstractLabel = new JLabel();
674 jAbstractLabel.setBounds(new java.awt.Rectangle(labelColumn, rowSeven, labelWidth, oneRowHeight));
675 jAbstractLabel.setText("Abstract");
676 jDescriptionLabel = new JLabel();
677 jDescriptionLabel.setText("Description");
678 jDescriptionLabel.setBounds(new java.awt.Rectangle(labelColumn, rowEight, labelWidth, oneRowHeight));
679
680 jContentPane = new JPanel();
681 jContentPane.setLayout(null);
682 jContentPane.setLocation(new java.awt.Point(0, 0));
683 jContentPane.setPreferredSize(new java.awt.Dimension(dialogWidth - 20, dialogHeight - 20));
684
685 jContentPane.add(jStarLabel1, null);
686 jContentPane.add(jStarLabel2, null);
687 jContentPane.add(jStarLabel3, null);
688 jContentPane.add(jStarLabel4, null);
689 jContentPane.add(jStarLabel5, null);
690 jContentPane.add(jStarLabel6, null);
691 jContentPane.add(jStarLabel7, null);
692 jContentPane.add(jStarLabel8, null);
693 jContentPane.add(jStarLabel9, null);
694
695 jContentPane.add(jPackageNameLabel, null);
696 jContentPane.add(getJPackageNameTextField(), null);
697 jContentPane.add(jGuidLabel, null);
698 jContentPane.add(getJGuidTextField(), null);
699 jContentPane.add(jVersionLabel, null);
700 jContentPane.add(getJVersionTextField(), null);
701 jContentPane.add(getJGenerateGuidButton(), null);
702 jContentPane.add(jLabelCopyright, null);
703 jContentPane.add(getCopyrightScrollPane(), null);
704 jContentPane.add(jLicenseLabel, null);
705 jContentPane.add(getJLicenseScrollPane(), null);
706 jContentPane.add(jUrlLabel, null);
707 jContentPane.add(getJUrlTextField(), null);
708 jContentPane.add(jAbstractLabel, null);
709 jContentPane.add(getJAbstractTextField(), null);
710 jContentPane.add(jDescriptionLabel, null);
711 jContentPane.add(getJDescriptionScrollPane(), null);
712
713 // jContentPane.add(getJButtonOk(), null);
714 // jContentPane.add(getJButtonCancel(), null);
715
716 jContentPane.add(getJCheckBoxRdOnly(), null);
717 jContentPane.add(getJCheckBoxRePkg(), null);
718 jContentPane.add(getJSpecificationTextField(), null);
719
720 }
721 return jContentPane;
722 }
723
724 /* (non-Javadoc)
725 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
726 *
727 * Override actionPerformed to listen all actions
728 *
729 */
730 public void actionPerformed(ActionEvent arg0) {
731
732 if (arg0.getSource() == jGenerateGuidButton) {
733 //ToDo: invoke GuidValueEditor
734 jGuidTextField.setText(Tools.generateUuidString());
735 sfc.setSpdHdrGuidValue(jGuidTextField.getText());
736 }
737 }
738
739 /**
740 This method initializes Package type and Compontent type
741
742 **/
743 private void initFrame() {
744 boolean editable = true;
745 if (sfc.getSpdPkgDefsRdOnly().equals("true")) {
746 editable = false;
747 }
748 jPackageNameTextField.setEditable(editable);
749 jGuidTextField.setEditable(editable);
750 jGenerateGuidButton.setEnabled(editable);
751 jVersionTextField.setEditable(editable);
752 jCopyrightTextArea.setEditable(editable);
753 jLicenseTextArea.setEditable(editable);
754 jUrlTextField.setEditable(editable);
755 jAbstractTextField.setEditable(editable);
756 jDescriptionTextArea.setEditable(editable);
757 jCheckBoxRePkg.setEnabled(editable);
758 }
759
760 /* (non-Javadoc)
761 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
762 *
763 * Override componentResized to resize all components when frame's size is changed
764 */
765 public void componentResized(ComponentEvent arg0) {
766 int intPreferredWidth = dialogWidth;
767 int intCurrentWidth = this.getJContentPane().getWidth();
768
769 // Tools.resizeComponentWidth(this.jPackageNameTextField, intCurrentWidth, intPreferredWidth);
770 // Tools.resizeComponentWidth(this.jGuidTextField, intCurrentWidth, intPreferredWidth);
771 // Tools.resizeComponentWidth(this.jVersionTextField, intCurrentWidth, intPreferredWidth);
772 Tools.resizeComponentWidth(this.jUrlTextField, intCurrentWidth, intPreferredWidth);
773 Tools.resizeComponentWidth(this.jLicenseScrollPane, intCurrentWidth, intPreferredWidth);
774 Tools.resizeComponentWidth(this.jCopyrightTextArea, intCurrentWidth, intPreferredWidth);
775 Tools.resizeComponentWidth(this.jDescriptionScrollPane, intCurrentWidth, intPreferredWidth);
776 // Tools.resizeComponentWidth(this.jSpecificationTextField, intCurrentWidth,intPreferredWidth);
777 Tools.resizeComponentWidth(this.jAbstractTextField, intCurrentWidth, intPreferredWidth);
778 // Tools.relocateComponentX(this.jGenerateGuidButton, intCurrentWidth, jGenerateGuidButton.getWidth(), 30);
779 }
780
781 private JScrollPane getTopScrollPane() {
782 if (topScrollPane == null) {
783 topScrollPane = new JScrollPane();
784 topScrollPane.setViewportView(getJContentPane());
785 }
786 return topScrollPane;
787 }
788
789 /* (non-Javadoc)
790 * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
791 */
792 public void changedUpdate(DocumentEvent arg0) {
793 // TODO Auto-generated method stub
794
795 }
796
797 /* (non-Javadoc)
798 * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
799 */
800 public void insertUpdate(DocumentEvent arg0) {
801 // TODO Auto-generated method stub
802 if (docConsole != null) {
803 docConsole.setSaved(false);
804 }
805 }
806
807 /* (non-Javadoc)
808 * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
809 */
810 public void removeUpdate(DocumentEvent arg0) {
811 // TODO Auto-generated method stub
812 if (docConsole != null) {
813 docConsole.setSaved(false);
814 }
815 }
816 }