]>
Commit | Line | Data |
---|---|---|
a13899c5 | 1 | /** @file\r |
2 | \r | |
3 | The file is used to create, update Library Class Definition of MSA/MBD 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 | package org.tianocore.frameworkwizard.module.ui;\r | |
16 | \r | |
17 | import java.awt.Dimension;\r | |
18 | import java.awt.event.ActionEvent;\r | |
19 | import java.awt.event.ComponentEvent;\r | |
20 | import java.awt.event.ItemEvent;\r | |
21 | import java.util.Vector;\r | |
22 | \r | |
23 | import javax.swing.JButton;\r | |
24 | import javax.swing.JComboBox;\r | |
25 | import javax.swing.JLabel;\r | |
26 | import javax.swing.JPanel;\r | |
27 | import javax.swing.JScrollPane;\r | |
28 | import javax.swing.JTextArea;\r | |
29 | import javax.swing.JTextField;\r | |
30 | \r | |
31 | import org.tianocore.LibraryClassDefinitionsDocument;\r | |
32 | import org.tianocore.LibraryUsage;\r | |
33 | import org.tianocore.ModuleSurfaceAreaDocument;\r | |
34 | import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;\r | |
35 | import org.tianocore.LibraryClassDocument.LibraryClass;\r | |
36 | import org.tianocore.frameworkwizard.common.DataType;\r | |
37 | import org.tianocore.frameworkwizard.common.DataValidation;\r | |
38 | import org.tianocore.frameworkwizard.common.EnumerationData;\r | |
39 | import org.tianocore.frameworkwizard.common.Log;\r | |
40 | import org.tianocore.frameworkwizard.common.OpeningModuleType;\r | |
41 | import org.tianocore.frameworkwizard.common.Tools;\r | |
42 | import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r | |
43 | import org.tianocore.frameworkwizard.common.ui.StarLabel;\r | |
44 | import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r | |
45 | import org.tianocore.frameworkwizard.module.Identification.LibraryClass.LibraryClassIdentification;\r | |
46 | import org.tianocore.frameworkwizard.module.Identification.LibraryClass.LibraryClassVector;\r | |
47 | import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r | |
48 | \r | |
49 | /**\r | |
50 | The class is used to create, update Library Class Definition of MSA/MBD file\r | |
51 | It extends IInternalFrame\r | |
52 | \r | |
53 | **/\r | |
54 | public class ModuleLibraryClassDefinitions extends IInternalFrame {\r | |
55 | \r | |
56 | ///\r | |
57 | /// Define class Serial Version UID\r | |
58 | ///\r | |
59 | private static final long serialVersionUID = -1743248695411382857L;\r | |
60 | \r | |
61 | //\r | |
62 | //Define class members\r | |
63 | //\r | |
64 | private JPanel jContentPane = null;\r | |
65 | \r | |
66 | private JComboBox jComboBoxLibraryClassName = null;\r | |
67 | \r | |
68 | private JLabel jLabelUsage = null;\r | |
69 | \r | |
70 | private JComboBox jComboBoxUsage = null;\r | |
71 | \r | |
72 | private JComboBox jComboBoxList = null;\r | |
73 | \r | |
74 | private JButton jButtonAdd = null;\r | |
75 | \r | |
76 | private JButton jButtonRemove = null;\r | |
77 | \r | |
78 | private JButton jButtonUpdate = null;\r | |
79 | \r | |
80 | private JLabel jLabelLibraryClassName = null;\r | |
81 | \r | |
82 | private JScrollPane jScrollPaneList = null;\r | |
83 | \r | |
84 | private JScrollPane jScrollPane = null;\r | |
85 | \r | |
86 | private JTextArea jTextAreaList = null;\r | |
87 | \r | |
88 | private StarLabel jStarLabel1 = null;\r | |
89 | \r | |
90 | private StarLabel jStarLabel2 = null;\r | |
91 | \r | |
92 | private ICheckBoxList iCheckBoxListArch = null;\r | |
93 | \r | |
94 | private JScrollPane jScrollPaneArch = null;\r | |
95 | \r | |
96 | private JLabel jLabelRecommendedInstanceVersion = null;\r | |
97 | \r | |
98 | private JTextField jTextFieldRecommendedInstanceVersion = null;\r | |
99 | \r | |
100 | private JLabel jLabelRecommendedInstanceGuid = null;\r | |
101 | \r | |
102 | private JTextField jTextFieldRecommendedInstanceGuid = null;\r | |
103 | \r | |
104 | private JButton jButtonGenerateGuid = null;\r | |
105 | \r | |
106 | private JLabel jLabelFeatureFlag = null;\r | |
107 | \r | |
108 | private JTextField jTextFieldFeatureFlag = null;\r | |
109 | \r | |
110 | private JLabel jLabelArch = null;\r | |
111 | \r | |
112 | private JLabel jLabelModuleList = null;\r | |
113 | \r | |
114 | private JScrollPane jScrollPaneModuleList = null;\r | |
115 | \r | |
116 | private ICheckBoxList iCheckBoxListModule = null;\r | |
117 | \r | |
118 | private JLabel jLabelHelpText = null;\r | |
119 | \r | |
120 | private JTextField jTextFieldHelpText = null;\r | |
121 | \r | |
122 | //\r | |
123 | // Not for UI\r | |
124 | //\r | |
125 | private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;\r | |
126 | \r | |
127 | private LibraryClassDefinitions lcd = null;\r | |
128 | \r | |
129 | private LibraryClassVector vLibraryClass = new LibraryClassVector();\r | |
130 | \r | |
131 | private EnumerationData ed = new EnumerationData();\r | |
132 | \r | |
133 | private Vector<String> vLib = new Vector<String>();\r | |
134 | \r | |
135 | private int intSelectedItemId = 0;\r | |
136 | \r | |
137 | private WorkspaceTools wt = new WorkspaceTools();\r | |
138 | \r | |
139 | private LibraryClassIdentification lcid = null;\r | |
140 | \r | |
141 | private OpeningModuleType omt = null;\r | |
142 | \r | |
143 | /**\r | |
144 | This method initializes jComboBoxSelect \r | |
145 | \r | |
146 | @return javax.swing.JComboBox jComboBoxSelect\r | |
147 | \r | |
148 | **/\r | |
149 | private JComboBox getJComboBoxLibraryClassName() {\r | |
150 | if (jComboBoxLibraryClassName == null) {\r | |
151 | jComboBoxLibraryClassName = new JComboBox();\r | |
152 | jComboBoxLibraryClassName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));\r | |
153 | jComboBoxLibraryClassName.setPreferredSize(new Dimension(320, 20));\r | |
154 | jComboBoxLibraryClassName.setEnabled(true);\r | |
155 | }\r | |
156 | return jComboBoxLibraryClassName;\r | |
157 | }\r | |
158 | \r | |
159 | /**\r | |
160 | This method initializes jComboBoxUsage \r | |
161 | \r | |
162 | @return javax.swing.JComboBox jComboBoxUsage\r | |
163 | \r | |
164 | **/\r | |
165 | private JComboBox getJComboBoxUsage() {\r | |
166 | if (jComboBoxUsage == null) {\r | |
167 | jComboBoxUsage = new JComboBox();\r | |
168 | jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));\r | |
169 | jComboBoxUsage.setPreferredSize(new Dimension(320, 20));\r | |
170 | }\r | |
171 | return jComboBoxUsage;\r | |
172 | }\r | |
173 | \r | |
174 | /**\r | |
175 | This method initializes jComboBoxFileList \r | |
176 | \r | |
177 | @return javax.swing.JComboBox jComboBoxFileList\r | |
178 | \r | |
179 | **/\r | |
180 | private JComboBox getJComboBoxList() {\r | |
181 | if (jComboBoxList == null) {\r | |
182 | jComboBoxList = new JComboBox();\r | |
183 | jComboBoxList.setBounds(new java.awt.Rectangle(15, 330, 210, 20));\r | |
184 | jComboBoxList.setPreferredSize(new Dimension(210, 20));\r | |
185 | jComboBoxList.addItemListener(this);\r | |
186 | jComboBoxList.addActionListener(this);\r | |
187 | }\r | |
188 | return jComboBoxList;\r | |
189 | }\r | |
190 | \r | |
191 | /**\r | |
192 | This method initializes jButtonAdd \r | |
193 | \r | |
194 | @return javax.swing.JButton jButtonAdd\r | |
195 | \r | |
196 | **/\r | |
197 | private JButton getJButtonAdd() {\r | |
198 | if (jButtonAdd == null) {\r | |
199 | jButtonAdd = new JButton();\r | |
200 | jButtonAdd.setBounds(new java.awt.Rectangle(230, 330, 80, 20));\r | |
201 | jButtonAdd.setPreferredSize(new Dimension(80, 20));\r | |
202 | jButtonAdd.setText("Add");\r | |
203 | jButtonAdd.addActionListener(this);\r | |
204 | }\r | |
205 | return jButtonAdd;\r | |
206 | }\r | |
207 | \r | |
208 | /**\r | |
209 | This method initializes jButtonRemove \r | |
210 | \r | |
211 | @return javax.swing.JButton jButtonRemove\r | |
212 | \r | |
213 | **/\r | |
214 | private JButton getJButtonRemove() {\r | |
215 | if (jButtonRemove == null) {\r | |
216 | jButtonRemove = new JButton();\r | |
217 | jButtonRemove.setBounds(new java.awt.Rectangle(400, 330, 80, 20));\r | |
218 | jButtonRemove.setText("Remove");\r | |
219 | jButtonRemove.setPreferredSize(new Dimension(80, 20));\r | |
220 | jButtonRemove.addActionListener(this);\r | |
221 | }\r | |
222 | return jButtonRemove;\r | |
223 | }\r | |
224 | \r | |
225 | /**\r | |
226 | This method initializes jButtonUpdate \r | |
227 | \r | |
228 | @return javax.swing.JButton jButtonUpdate\r | |
229 | \r | |
230 | **/\r | |
231 | private JButton getJButtonUpdate() {\r | |
232 | if (jButtonUpdate == null) {\r | |
233 | jButtonUpdate = new JButton();\r | |
234 | jButtonUpdate.setBounds(new java.awt.Rectangle(315, 330, 80, 20));\r | |
235 | jButtonUpdate.setText("Update");\r | |
236 | jButtonUpdate.setPreferredSize(new Dimension(80, 20));\r | |
237 | jButtonUpdate.addActionListener(this);\r | |
238 | }\r | |
239 | return jButtonUpdate;\r | |
240 | }\r | |
241 | \r | |
242 | /**\r | |
243 | This method initializes jScrollPane \r | |
244 | \r | |
245 | @return javax.swing.JScrollPane \r | |
246 | */\r | |
247 | private JScrollPane getJScrollPaneList() {\r | |
248 | if (jScrollPaneList == null) {\r | |
249 | jScrollPaneList = new JScrollPane();\r | |
250 | jScrollPaneList.setBounds(new java.awt.Rectangle(15, 355, 465, 100));\r | |
251 | jScrollPaneList.setPreferredSize(new Dimension(465, 260));\r | |
252 | jScrollPaneList.setViewportView(getJTextAreaList());\r | |
253 | }\r | |
254 | return jScrollPaneList;\r | |
255 | }\r | |
256 | \r | |
257 | /**\r | |
258 | This method initializes jScrollPane \r | |
259 | \r | |
260 | @return javax.swing.JScrollPane \r | |
261 | */\r | |
262 | private JScrollPane getJScrollPane() {\r | |
263 | if (jScrollPane == null) {\r | |
264 | jScrollPane = new JScrollPane();\r | |
265 | jScrollPane.setViewportView(getJContentPane());\r | |
266 | }\r | |
267 | return jScrollPane;\r | |
268 | }\r | |
269 | \r | |
270 | /**\r | |
271 | * This method initializes jTextAreaList \r | |
272 | * \r | |
273 | * @return javax.swing.JTextArea \r | |
274 | */\r | |
275 | private JTextArea getJTextAreaList() {\r | |
276 | if (jTextAreaList == null) {\r | |
277 | jTextAreaList = new JTextArea();\r | |
278 | jTextAreaList.setEditable(false);\r | |
279 | }\r | |
280 | return jTextAreaList;\r | |
281 | }\r | |
282 | \r | |
283 | /**\r | |
284 | * This method initializes jTextFieldRecommendedInstanceVersion \r | |
285 | * \r | |
286 | * @return javax.swing.JTextField \r | |
287 | */\r | |
288 | private JTextField getJTextFieldRecommendedInstanceVersion() {\r | |
289 | if (jTextFieldRecommendedInstanceVersion == null) {\r | |
290 | jTextFieldRecommendedInstanceVersion = new JTextField();\r | |
291 | jTextFieldRecommendedInstanceVersion.setPreferredSize(new java.awt.Dimension(260, 20));\r | |
292 | jTextFieldRecommendedInstanceVersion.setSize(new java.awt.Dimension(260, 20));\r | |
293 | jTextFieldRecommendedInstanceVersion.setLocation(new java.awt.Point(220, 85));\r | |
294 | }\r | |
295 | return jTextFieldRecommendedInstanceVersion;\r | |
296 | }\r | |
297 | \r | |
298 | /**\r | |
299 | * This method initializes jTextFieldRecommendedInstanceGuid \r | |
300 | * \r | |
301 | * @return javax.swing.JTextField \r | |
302 | */\r | |
303 | private JTextField getJTextFieldRecommendedInstanceGuid() {\r | |
304 | if (jTextFieldRecommendedInstanceGuid == null) {\r | |
305 | jTextFieldRecommendedInstanceGuid = new JTextField();\r | |
306 | jTextFieldRecommendedInstanceGuid.setBounds(new java.awt.Rectangle(220, 110, 190, 20));\r | |
307 | jTextFieldRecommendedInstanceGuid.setPreferredSize(new java.awt.Dimension(190, 20));\r | |
308 | }\r | |
309 | return jTextFieldRecommendedInstanceGuid;\r | |
310 | }\r | |
311 | \r | |
312 | /**\r | |
313 | * This method initializes jButtonGenerateGuid \r | |
314 | * \r | |
315 | * @return javax.swing.JButton \r | |
316 | */\r | |
317 | private JButton getJButtonGenerateGuid() {\r | |
318 | if (jButtonGenerateGuid == null) {\r | |
319 | jButtonGenerateGuid = new JButton();\r | |
320 | jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 110, 65, 20));\r | |
321 | jButtonGenerateGuid.setPreferredSize(new java.awt.Dimension(65, 20));\r | |
322 | jButtonGenerateGuid.setText("GEN");\r | |
323 | jButtonGenerateGuid.addActionListener(this);\r | |
324 | }\r | |
325 | return jButtonGenerateGuid;\r | |
326 | }\r | |
327 | \r | |
328 | /**\r | |
329 | * This method initializes jTextFieldFeatureFlag \r | |
330 | * \r | |
331 | * @return javax.swing.JTextField \r | |
332 | */\r | |
333 | private JTextField getJTextFieldFeatureFlag() {\r | |
334 | if (jTextFieldFeatureFlag == null) {\r | |
335 | jTextFieldFeatureFlag = new JTextField();\r | |
336 | jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 135, 320, 20));\r | |
337 | jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
338 | }\r | |
339 | return jTextFieldFeatureFlag;\r | |
340 | }\r | |
341 | \r | |
342 | /**\r | |
343 | This method initializes iCheckBoxListArch \r | |
344 | \r | |
345 | @return ICheckBoxList \r | |
346 | **/\r | |
347 | private ICheckBoxList getICheckBoxListSupportedArchitectures() {\r | |
348 | if (iCheckBoxListArch == null) {\r | |
349 | iCheckBoxListArch = new ICheckBoxList();\r | |
350 | iCheckBoxListArch.addFocusListener(this);\r | |
351 | }\r | |
352 | return iCheckBoxListArch;\r | |
353 | }\r | |
354 | \r | |
355 | /**\r | |
356 | This method initializes iCheckBoxListArch \r | |
357 | \r | |
358 | @return ICheckBoxList \r | |
359 | **/\r | |
360 | private ICheckBoxList getICheckBoxListSupModuleList() {\r | |
361 | if (iCheckBoxListModule == null) {\r | |
362 | iCheckBoxListModule = new ICheckBoxList();\r | |
363 | }\r | |
364 | return iCheckBoxListModule;\r | |
365 | }\r | |
366 | \r | |
367 | /**\r | |
368 | This method initializes jScrollPaneArch \r | |
369 | \r | |
370 | @return javax.swing.JScrollPane \r | |
371 | \r | |
372 | **/\r | |
373 | private JScrollPane getJScrollPaneArch() {\r | |
374 | if (jScrollPaneArch == null) {\r | |
375 | jScrollPaneArch = new JScrollPane();\r | |
376 | jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 160, 320, 80));\r | |
377 | jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));\r | |
378 | jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());\r | |
379 | }\r | |
380 | return jScrollPaneArch;\r | |
381 | }\r | |
382 | \r | |
383 | /**\r | |
384 | This method initializes jScrollPaneModuleList \r | |
385 | \r | |
386 | @return javax.swing.JScrollPane \r | |
387 | \r | |
388 | **/\r | |
389 | private JScrollPane getJScrollPaneModuleList() {\r | |
390 | if (jScrollPaneModuleList == null) {\r | |
391 | jScrollPaneModuleList = new JScrollPane();\r | |
392 | jScrollPaneModuleList.setBounds(new java.awt.Rectangle(160, 245, 320, 80));\r | |
393 | jScrollPaneModuleList.setPreferredSize(new java.awt.Dimension(320, 80));\r | |
394 | jScrollPaneModuleList.setViewportView(getICheckBoxListSupModuleList());\r | |
395 | }\r | |
396 | return jScrollPaneModuleList;\r | |
397 | }\r | |
398 | \r | |
399 | /**\r | |
400 | This method initializes jTextFieldHelpText \r | |
401 | \r | |
402 | @return javax.swing.JTextField \r | |
403 | \r | |
404 | **/\r | |
405 | private JTextField getJTextFieldHelpText() {\r | |
406 | if (jTextFieldHelpText == null) {\r | |
407 | jTextFieldHelpText = new JTextField();\r | |
408 | jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));\r | |
409 | jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
410 | }\r | |
411 | return jTextFieldHelpText;\r | |
412 | }\r | |
413 | \r | |
414 | public static void main(String[] args) {\r | |
415 | \r | |
416 | }\r | |
417 | \r | |
418 | /**\r | |
419 | This is the default constructor\r | |
420 | \r | |
421 | **/\r | |
422 | public ModuleLibraryClassDefinitions() {\r | |
423 | super();\r | |
424 | init();\r | |
425 | this.setVisible(true);\r | |
426 | }\r | |
427 | \r | |
428 | /**\r | |
429 | This is the override edit constructor\r | |
430 | \r | |
431 | @param \r | |
432 | \r | |
433 | **/\r | |
434 | public ModuleLibraryClassDefinitions(OpeningModuleType inOmt) {\r | |
435 | super();\r | |
436 | this.omt = inOmt;\r | |
437 | this.msa = omt.getXmlMsa();\r | |
438 | initLibraryClass();\r | |
439 | init(msa.getLibraryClassDefinitions());\r | |
440 | this.setVisible(true);\r | |
441 | }\r | |
442 | \r | |
443 | // private void initLibraryClass(MsaHeaderDocument.MsaHeader msaHeader) {\r | |
444 | // Enum e = msaHeader.getModuleType();\r | |
445 | // if (e == ModuleTypeDef.BASE) {\r | |
446 | // vLib = ed.getVLibClassDefBase();\r | |
447 | // } else if (e == ModuleTypeDef.PEI_CORE) {\r | |
448 | // vLib = ed.getVLibClassDefPei();\r | |
449 | // } else if (e == ModuleTypeDef.PEIM) {\r | |
450 | // vLib = ed.getVLibClassDefPeim();\r | |
451 | // } else if (e == ModuleTypeDef.DXE_CORE) {\r | |
452 | // vLib = ed.getVLibClassDefDxeCore();\r | |
453 | // } else if (e == ModuleTypeDef.DXE_DRIVER) {\r | |
454 | // vLib = ed.getVLibClassDefDxeDriver();\r | |
455 | // } else if (e == ModuleTypeDef.DXE_SMM_DRIVER) {\r | |
456 | // vLib = ed.getVLibClassDefDxeSmmDriver();\r | |
457 | // } else if (e == ModuleTypeDef.UEFI_DRIVER) {\r | |
458 | // vLib = ed.getVLibClassDefUefiDriver();\r | |
459 | // } else {\r | |
460 | // //vLib = ed.getVLibClassDef();\r | |
461 | // }\r | |
462 | // }\r | |
463 | \r | |
464 | /**\r | |
465 | \r | |
466 | **/\r | |
467 | private void initLibraryClass() {\r | |
468 | vLib = wt.getAllLibraryClassDefinitionsFromWorkspace();\r | |
469 | }\r | |
470 | \r | |
471 | /**\r | |
472 | This method initializes this\r | |
473 | Fill values to all fields if these values are not empty\r | |
474 | \r | |
475 | @param inLibraryClassDefinitions The input data of LibraryClassDefinitionsDocument.LibraryClassDefinitions\r | |
476 | \r | |
477 | **/\r | |
478 | private void init(LibraryClassDefinitionsDocument.LibraryClassDefinitions inLibraryClassDefinitions) {\r | |
479 | init();\r | |
480 | this.lcd = inLibraryClassDefinitions;\r | |
481 | if (this.lcd != null) {\r | |
482 | if (this.lcd.getLibraryClassList().size() > 0) {\r | |
483 | for (int index = 0; index < this.lcd.getLibraryClassList().size(); index++) {\r | |
484 | String name = lcd.getLibraryClassList().get(index).getKeyword();\r | |
485 | String usage = null;\r | |
486 | if (lcd.getLibraryClassList().get(index).getUsage() != null) {\r | |
487 | usage = lcd.getLibraryClassList().get(index).getUsage().toString(); \r | |
488 | }\r | |
489 | String version = lcd.getLibraryClassList().get(index).getRecommendedInstanceVersion();\r | |
490 | String guid = lcd.getLibraryClassList().get(index).getRecommendedInstanceGuid();\r | |
491 | String featureFlag = lcd.getLibraryClassList().get(index).getFeatureFlag();\r | |
492 | Vector<String> arch = Tools.convertListToVector(lcd.getLibraryClassList().get(index)\r | |
493 | .getSupArchList());\r | |
494 | Vector<String> module = Tools.convertListToVector(lcd.getLibraryClassList().get(index)\r | |
495 | .getSupModuleList());\r | |
496 | String help = lcd.getLibraryClassList().get(index).getHelpText();\r | |
497 | LibraryClassIdentification lcid = new LibraryClassIdentification(name, usage, version, guid, arch,\r | |
498 | featureFlag, module, help);\r | |
499 | vLibraryClass.addLibraryClass(lcid);\r | |
500 | }\r | |
501 | }\r | |
502 | }\r | |
503 | //\r | |
504 | // Update the list\r | |
505 | //\r | |
506 | Tools.generateComboBoxByVector(jComboBoxList, vLibraryClass.getLibraryClassName());\r | |
507 | reloadListArea();\r | |
508 | }\r | |
509 | \r | |
510 | /**\r | |
511 | This method initializes this\r | |
512 | \r | |
513 | **/\r | |
514 | private void init() {\r | |
515 | this.setContentPane(getJScrollPane());\r | |
516 | this.setTitle("Library Class Definitions");\r | |
517 | this.setBounds(new java.awt.Rectangle(0, 0, 500, 515));\r | |
518 | initFrame();\r | |
519 | this.setViewMode(false);\r | |
520 | }\r | |
521 | \r | |
522 | /**\r | |
523 | Disable all components when the mode is view\r | |
524 | \r | |
525 | @param isView true - The view mode; false - The non-view mode\r | |
526 | \r | |
527 | **/\r | |
528 | public void setViewMode(boolean isView) {\r | |
529 | if (isView) {\r | |
530 | this.jComboBoxLibraryClassName.setEnabled(!isView);\r | |
531 | this.jComboBoxUsage.setEnabled(!isView);\r | |
532 | }\r | |
533 | }\r | |
534 | \r | |
535 | /**\r | |
536 | This method initializes jContentPane\r | |
537 | \r | |
538 | @return javax.swing.JPanel jContentPane\r | |
539 | \r | |
540 | **/\r | |
541 | private JPanel getJContentPane() {\r | |
542 | if (jContentPane == null) {\r | |
543 | jLabelHelpText = new JLabel();\r | |
544 | jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));\r | |
545 | jLabelHelpText.setText("Help Text");\r | |
546 | jLabelModuleList = new JLabel();\r | |
547 | jLabelModuleList.setBounds(new java.awt.Rectangle(15, 245, 140, 20));\r | |
548 | jLabelModuleList.setText("Sup Module List");\r | |
549 | jLabelArch = new JLabel();\r | |
550 | jLabelArch.setBounds(new java.awt.Rectangle(15, 160, 140, 20));\r | |
551 | jLabelArch.setText("Sup Arch List");\r | |
552 | jLabelFeatureFlag = new JLabel();\r | |
553 | jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 135, 140, 20));\r | |
554 | jLabelFeatureFlag.setText("Feature Flag");\r | |
555 | jLabelRecommendedInstanceGuid = new JLabel();\r | |
556 | jLabelRecommendedInstanceGuid.setBounds(new java.awt.Rectangle(15, 110, 200, 20));\r | |
557 | jLabelRecommendedInstanceGuid.setText("Recommended Instance Guid");\r | |
558 | jLabelRecommendedInstanceVersion = new JLabel();\r | |
559 | jLabelRecommendedInstanceVersion.setBounds(new java.awt.Rectangle(15, 85, 200, 20));\r | |
560 | jLabelRecommendedInstanceVersion.setText("Recommended Instance Version");\r | |
561 | jLabelLibraryClassName = new JLabel();\r | |
562 | jLabelLibraryClassName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));\r | |
563 | jLabelLibraryClassName.setText("Library Class Name");\r | |
564 | jLabelUsage = new JLabel();\r | |
565 | jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));\r | |
566 | jLabelUsage.setText("Usage");\r | |
567 | jContentPane = new JPanel();\r | |
568 | jContentPane.setLayout(null);\r | |
569 | jContentPane.setPreferredSize(new java.awt.Dimension(490, 465));\r | |
570 | \r | |
571 | jContentPane.add(getJComboBoxLibraryClassName(), null);\r | |
572 | jContentPane.add(jLabelUsage, null);\r | |
573 | jContentPane.add(getJComboBoxUsage(), null);\r | |
574 | jContentPane.add(jLabelLibraryClassName, null);\r | |
575 | jContentPane.add(getJScrollPaneList(), null);\r | |
576 | jContentPane.add(getJComboBoxList(), null);\r | |
577 | jContentPane.add(getJButtonAdd(), null);\r | |
578 | jContentPane.add(getJButtonRemove(), null);\r | |
579 | jContentPane.add(getJButtonUpdate(), null);\r | |
580 | jContentPane.add(jLabelRecommendedInstanceVersion, null);\r | |
581 | jContentPane.add(getJTextFieldRecommendedInstanceVersion(), null);\r | |
582 | jContentPane.add(jLabelRecommendedInstanceGuid, null);\r | |
583 | jContentPane.add(getJTextFieldRecommendedInstanceGuid(), null);\r | |
584 | jContentPane.add(getJButtonGenerateGuid(), null);\r | |
585 | jContentPane.add(jLabelFeatureFlag, null);\r | |
586 | jContentPane.add(getJTextFieldFeatureFlag(), null);\r | |
587 | jContentPane.add(jLabelArch, null);\r | |
588 | jContentPane.add(getJScrollPaneArch(), null);\r | |
589 | jStarLabel1 = new StarLabel();\r | |
590 | jStarLabel1.setLocation(new java.awt.Point(0, 10));\r | |
591 | jStarLabel2 = new StarLabel();\r | |
592 | jStarLabel2.setLocation(new java.awt.Point(0, 35));\r | |
593 | \r | |
594 | jContentPane.add(jStarLabel1, null);\r | |
595 | jContentPane.add(jStarLabel2, null);\r | |
596 | jContentPane.add(jLabelModuleList, null);\r | |
597 | jContentPane.add(getJScrollPaneModuleList(), null);\r | |
598 | jContentPane.add(jLabelHelpText, null);\r | |
599 | jContentPane.add(getJTextFieldHelpText(), null);\r | |
600 | }\r | |
601 | return jContentPane;\r | |
602 | }\r | |
603 | \r | |
604 | /**\r | |
605 | This method initializes all existing libraries and usage types\r | |
606 | \r | |
607 | **/\r | |
608 | private void initFrame() {\r | |
609 | Tools.generateComboBoxByVector(jComboBoxLibraryClassName, vLib);\r | |
610 | Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVLibraryUsage());\r | |
611 | this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());\r | |
612 | this.iCheckBoxListModule.setAllItems(ed.getVFrameworkModuleTypes());\r | |
613 | }\r | |
614 | \r | |
615 | /* (non-Javadoc)\r | |
616 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r | |
617 | *\r | |
618 | * Override actionPerformed to listen all actions\r | |
619 | * \r | |
620 | */\r | |
621 | public void actionPerformed(ActionEvent arg0) {\r | |
622 | if (arg0.getSource() == jButtonAdd) {\r | |
623 | if (!checkAdd()) {\r | |
624 | return;\r | |
625 | }\r | |
626 | addToList();\r | |
627 | }\r | |
628 | if (arg0.getSource() == jButtonRemove) {\r | |
629 | removeFromList();\r | |
630 | }\r | |
631 | if (arg0.getSource() == jButtonUpdate) {\r | |
632 | updateForList();\r | |
633 | }\r | |
634 | if (arg0.getSource() == jButtonGenerateGuid) {\r | |
635 | this.jTextFieldRecommendedInstanceGuid.setText(Tools.generateUuidString());\r | |
636 | }\r | |
637 | }\r | |
638 | \r | |
639 | /**\r | |
640 | Data validation for all fields\r | |
641 | \r | |
642 | @retval true - All datas are valid\r | |
643 | @retval false - At least one data is invalid\r | |
644 | \r | |
645 | **/\r | |
646 | public boolean checkAdd() {\r | |
647 | //\r | |
648 | // Check LibraryClass\r | |
649 | //\r | |
650 | if (this.jComboBoxLibraryClassName.getSelectedItem() == null) {\r | |
651 | Log.err("No Library Class can be added");\r | |
652 | return false;\r | |
653 | }\r | |
654 | if (!DataValidation.isLibraryClass(this.jComboBoxLibraryClassName.getSelectedItem().toString())) {\r | |
655 | Log.err("Incorrect data type for Library Class");\r | |
656 | return false;\r | |
657 | }\r | |
658 | \r | |
659 | //\r | |
660 | // Check RecommendedInstanceVersion\r | |
661 | //\r | |
662 | if (!isEmpty(this.jTextFieldRecommendedInstanceVersion.getText())) {\r | |
663 | if (!DataValidation.isRecommendedInstanceVersion(this.jTextFieldRecommendedInstanceVersion.getText())) {\r | |
664 | Log.err("Incorrect data type for Recommended Instance Version");\r | |
665 | return false;\r | |
666 | }\r | |
667 | }\r | |
668 | \r | |
669 | //\r | |
670 | // Check RecommendedInstanceGuid\r | |
671 | //\r | |
672 | if (!isEmpty(this.jTextFieldRecommendedInstanceGuid.getText())) {\r | |
673 | if (!DataValidation.isGuid(this.jTextFieldRecommendedInstanceGuid.getText())) {\r | |
674 | Log.err("Incorrect data type for Recommended Instance Guid");\r | |
675 | return false;\r | |
676 | }\r | |
677 | }\r | |
678 | \r | |
679 | //\r | |
680 | // Check FeatureFlag\r | |
681 | //\r | |
682 | if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {\r | |
683 | if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {\r | |
684 | Log.err("Incorrect data type for Feature Flag");\r | |
685 | return false;\r | |
686 | }\r | |
687 | }\r | |
688 | \r | |
689 | if (this.vLibraryClass.findLibraryClass(this.jComboBoxLibraryClassName.getSelectedItem().toString()) > -1) {\r | |
690 | Log.err("The Library Class has been added already!");\r | |
691 | return false;\r | |
692 | }\r | |
693 | return true;\r | |
694 | }\r | |
695 | \r | |
696 | /**\r | |
697 | Save all components of Mbd Header\r | |
698 | if exists mbdHeader, set the value directly\r | |
699 | if not exists mbdHeader, new an instance first\r | |
700 | \r | |
701 | **/\r | |
702 | public void save() {\r | |
703 | try {\r | |
704 | int intLibraryCount = this.vLibraryClass.size();\r | |
705 | \r | |
706 | lcd = LibraryClassDefinitions.Factory.newInstance();\r | |
707 | if (intLibraryCount > 0) {\r | |
708 | for (int index = 0; index < intLibraryCount; index++) {\r | |
709 | LibraryClass mLibraryClass = LibraryClass.Factory.newInstance();\r | |
710 | \r | |
711 | mLibraryClass.setKeyword(vLibraryClass.getLibraryClass(index).getLibraryClassName());\r | |
712 | mLibraryClass\r | |
713 | .setUsage(LibraryUsage.Enum.forString(vLibraryClass.getLibraryClass(index).getUsage()));\r | |
714 | if (!isEmpty(vLibraryClass.getLibraryClass(index).getRecommendedInstanceVersion())) {\r | |
715 | mLibraryClass.setRecommendedInstanceVersion(vLibraryClass.getLibraryClass(index)\r | |
716 | .getRecommendedInstanceVersion());\r | |
717 | }\r | |
718 | if (!isEmpty(vLibraryClass.getLibraryClass(index).getRecommendedInstanceGuid())) {\r | |
719 | mLibraryClass.setRecommendedInstanceGuid(vLibraryClass.getLibraryClass(index)\r | |
720 | .getRecommendedInstanceGuid());\r | |
721 | }\r | |
722 | if (!isEmpty(vLibraryClass.getLibraryClass(index).getFeatureFlag())) {\r | |
723 | mLibraryClass.setFeatureFlag(vLibraryClass.getLibraryClass(index).getFeatureFlag());\r | |
724 | }\r | |
725 | if (vLibraryClass.getLibraryClass(index).getSupArchList() != null\r | |
726 | && vLibraryClass.getLibraryClass(index).getSupArchList().size() > 0) {\r | |
727 | mLibraryClass.setSupArchList(vLibraryClass.getLibraryClass(index).getSupArchList());\r | |
728 | }\r | |
729 | if (!isEmpty(vLibraryClass.getLibraryClass(index).getHelp())) {\r | |
730 | mLibraryClass.setHelpText(vLibraryClass.getLibraryClass(index).getHelp());\r | |
731 | }\r | |
732 | \r | |
733 | this.lcd.addNewLibraryClass();\r | |
734 | this.lcd.setLibraryClassArray(index, mLibraryClass);\r | |
735 | }\r | |
736 | }\r | |
737 | \r | |
738 | if (msa.getLibraryClassDefinitions() == null) {\r | |
739 | this.msa.addNewLibraryClassDefinitions();\r | |
740 | }\r | |
741 | this.msa.setLibraryClassDefinitions(this.lcd);\r | |
742 | \r | |
743 | this.omt.setSaved(false);\r | |
744 | } catch (Exception e) {\r | |
745 | Log.err("Update Library Class Definitions", e.getMessage());\r | |
746 | }\r | |
747 | }\r | |
748 | \r | |
749 | private LibraryClassIdentification getCurrentLibraryClass() {\r | |
750 | String name = this.jComboBoxLibraryClassName.getSelectedItem().toString();\r | |
751 | String usage = this.jComboBoxUsage.getSelectedItem().toString();\r | |
752 | String version = this.jTextFieldRecommendedInstanceVersion.getText();\r | |
753 | String guid = this.jTextFieldRecommendedInstanceGuid.getText();\r | |
754 | String featureFlag = this.jTextFieldFeatureFlag.getText();\r | |
755 | Vector<String> arch = this.iCheckBoxListArch.getAllCheckedItemsString();\r | |
756 | Vector<String> module = this.iCheckBoxListModule.getAllCheckedItemsString();\r | |
757 | String help = this.jTextFieldHelpText.getText();\r | |
758 | lcid = new LibraryClassIdentification(name, usage, version, guid, arch, featureFlag, module, help);\r | |
759 | return lcid;\r | |
760 | }\r | |
761 | \r | |
762 | /**\r | |
763 | Add current item to Vector\r | |
764 | \r | |
765 | **/\r | |
766 | private void addToList() {\r | |
767 | intSelectedItemId = vLibraryClass.size();\r | |
768 | \r | |
769 | vLibraryClass.addLibraryClass(getCurrentLibraryClass());\r | |
770 | \r | |
771 | jComboBoxList.addItem(lcid.getLibraryClassName());\r | |
772 | jComboBoxList.setSelectedItem(lcid.getLibraryClassName());\r | |
773 | \r | |
774 | //\r | |
775 | // Reset select item index\r | |
776 | //\r | |
777 | intSelectedItemId = vLibraryClass.size();\r | |
778 | \r | |
779 | //\r | |
780 | // Reload all fields of selected item\r | |
781 | //\r | |
782 | reloadFromList();\r | |
783 | \r | |
784 | // \r | |
785 | // Save to memory\r | |
786 | //\r | |
787 | save();\r | |
788 | }\r | |
789 | \r | |
790 | /**\r | |
791 | Remove current item from Vector\r | |
792 | \r | |
793 | **/\r | |
794 | private void removeFromList() {\r | |
795 | //\r | |
796 | // Check if exist items\r | |
797 | //\r | |
798 | if (this.vLibraryClass.size() < 1) {\r | |
799 | return;\r | |
800 | }\r | |
801 | \r | |
802 | int intTempIndex = intSelectedItemId;\r | |
803 | \r | |
804 | jComboBoxList.removeItemAt(intSelectedItemId);\r | |
805 | \r | |
806 | vLibraryClass.removeLibraryClass(intTempIndex);\r | |
807 | \r | |
808 | //\r | |
809 | // Reload all fields of selected item\r | |
810 | //\r | |
811 | reloadFromList();\r | |
812 | \r | |
813 | // \r | |
814 | // Save to memory\r | |
815 | //\r | |
816 | save();\r | |
817 | }\r | |
818 | \r | |
819 | /**\r | |
820 | Update current item of Vector\r | |
821 | \r | |
822 | **/\r | |
823 | private void updateForList() {\r | |
824 | //\r | |
825 | // Check if exist items\r | |
826 | //\r | |
827 | if (this.vLibraryClass.size() < 1) {\r | |
828 | return;\r | |
829 | }\r | |
830 | \r | |
831 | //\r | |
832 | // Backup selected item index\r | |
833 | //\r | |
834 | int intTempIndex = intSelectedItemId;\r | |
835 | \r | |
836 | vLibraryClass.updateLibraryClass(getCurrentLibraryClass(), intTempIndex);\r | |
837 | \r | |
838 | jComboBoxList.removeAllItems();\r | |
839 | for (int index = 0; index < vLibraryClass.size(); index++) {\r | |
840 | jComboBoxList.addItem(vLibraryClass.getLibraryClass(index).getLibraryClassName());\r | |
841 | }\r | |
842 | \r | |
843 | //\r | |
844 | // Restore selected item index\r | |
845 | //\r | |
846 | intSelectedItemId = intTempIndex;\r | |
847 | \r | |
848 | //\r | |
849 | // Reset select item index\r | |
850 | //\r | |
851 | jComboBoxList.setSelectedIndex(intSelectedItemId);\r | |
852 | \r | |
853 | //\r | |
854 | // Reload all fields of selected item\r | |
855 | //\r | |
856 | reloadFromList();\r | |
857 | \r | |
858 | // \r | |
859 | // Save to memory\r | |
860 | //\r | |
861 | save();\r | |
862 | }\r | |
863 | \r | |
864 | /**\r | |
865 | Refresh all fields' values of selected item of Vector\r | |
866 | \r | |
867 | **/\r | |
868 | private void reloadFromList() {\r | |
869 | if (vLibraryClass.size() > 0) {\r | |
870 | //\r | |
871 | // Get selected item index\r | |
872 | //\r | |
873 | intSelectedItemId = jComboBoxList.getSelectedIndex();\r | |
874 | \r | |
875 | this.jComboBoxLibraryClassName.setSelectedItem(vLibraryClass.getLibraryClass(intSelectedItemId)\r | |
876 | .getLibraryClassName());\r | |
877 | this.jComboBoxUsage.setSelectedItem(vLibraryClass.getLibraryClass(intSelectedItemId).getUsage());\r | |
878 | this.jTextFieldRecommendedInstanceVersion.setText(vLibraryClass.getLibraryClass(intSelectedItemId)\r | |
879 | .getRecommendedInstanceVersion());\r | |
880 | this.jTextFieldRecommendedInstanceGuid.setText(vLibraryClass.getLibraryClass(intSelectedItemId)\r | |
881 | .getRecommendedInstanceGuid());\r | |
882 | this.jTextFieldFeatureFlag.setText(vLibraryClass.getLibraryClass(intSelectedItemId).getFeatureFlag());\r | |
883 | this.iCheckBoxListArch.setAllItemsUnchecked();\r | |
884 | this.iCheckBoxListArch.initCheckedItem(true, vLibraryClass.getLibraryClass(intSelectedItemId)\r | |
885 | .getSupArchList());\r | |
886 | this.iCheckBoxListModule.setAllItemsUnchecked();\r | |
887 | this.iCheckBoxListModule.initCheckedItem(true, vLibraryClass.getLibraryClass(intSelectedItemId)\r | |
888 | .getSupModuleList());\r | |
889 | this.jTextFieldHelpText.setText(vLibraryClass.getLibraryClass(intSelectedItemId).getHelp());\r | |
890 | } else {\r | |
891 | }\r | |
892 | \r | |
893 | reloadListArea();\r | |
894 | }\r | |
895 | \r | |
896 | /**\r | |
897 | Update list area pane via the elements of Vector\r | |
898 | \r | |
899 | **/\r | |
900 | private void reloadListArea() {\r | |
901 | String strListItem = "";\r | |
902 | for (int index = 0; index < vLibraryClass.size(); index++) {\r | |
903 | strListItem = strListItem + vLibraryClass.getLibraryClass(index).getLibraryClassName()\r | |
904 | + DataType.UNIX_LINE_SEPARATOR;\r | |
905 | }\r | |
906 | this.jTextAreaList.setText(strListItem);\r | |
907 | }\r | |
908 | \r | |
909 | /* (non-Javadoc)\r | |
910 | * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)\r | |
911 | *\r | |
912 | * Reflesh the frame when selected item changed\r | |
913 | * \r | |
914 | */\r | |
915 | public void itemStateChanged(ItemEvent arg0) {\r | |
916 | if (arg0.getStateChange() == ItemEvent.SELECTED) {\r | |
917 | reloadFromList();\r | |
918 | }\r | |
919 | }\r | |
920 | \r | |
921 | /* (non-Javadoc)\r | |
922 | * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)\r | |
923 | * \r | |
924 | * Override componentResized to resize all components when frame's size is changed\r | |
925 | */\r | |
926 | public void componentResized(ComponentEvent arg0) {\r | |
927 | int intCurrentWidth = this.getJContentPane().getWidth();\r | |
928 | int intCurrentHeight = this.getJContentPane().getHeight();\r | |
929 | int intPreferredWidth = this.getJContentPane().getPreferredSize().width;\r | |
930 | int intPreferredHeight = this.getJContentPane().getPreferredSize().height;\r | |
931 | \r | |
932 | resizeComponentWidth(this.jComboBoxLibraryClassName, intCurrentWidth, intPreferredWidth);\r | |
933 | resizeComponentWidth(this.jComboBoxUsage, intCurrentWidth, intPreferredWidth);\r | |
934 | resizeComponentWidth(this.jTextFieldHelpText, intCurrentWidth, intPreferredWidth);\r | |
935 | resizeComponentWidth(this.jTextFieldRecommendedInstanceVersion, intCurrentWidth, intPreferredWidth);\r | |
936 | resizeComponentWidth(this.jTextFieldRecommendedInstanceGuid, intCurrentWidth, intPreferredWidth);\r | |
937 | resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);\r | |
938 | resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);\r | |
939 | resizeComponentWidth(this.jScrollPaneModuleList, intCurrentWidth, intPreferredWidth);\r | |
940 | \r | |
941 | relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth,\r | |
942 | DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);\r | |
943 | \r | |
944 | resizeComponentWidth(this.jComboBoxList, intCurrentWidth, intPreferredWidth);\r | |
945 | resizeComponent(this.jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);\r | |
946 | relocateComponentX(this.jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);\r | |
947 | relocateComponentX(this.jButtonRemove, intCurrentWidth, intPreferredWidth,\r | |
948 | DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);\r | |
949 | relocateComponentX(this.jButtonUpdate, intCurrentWidth, intPreferredWidth,\r | |
950 | DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);\r | |
951 | }\r | |
952 | }\r |