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