]>
Commit | Line | Data |
---|---|---|
06a19cee | 1 | /** @file\r |
2 | \r | |
928b45fb | 3 | The file is used to create, update Library Class Definition section of the MSA file\r |
06a19cee | 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.dialog;\r | |
16 | \r | |
17 | import java.awt.Dimension;\r | |
18 | import java.awt.event.ActionEvent;\r | |
19 | import java.util.Vector;\r | |
20 | \r | |
21 | import javax.swing.JButton;\r | |
22 | import javax.swing.JComboBox;\r | |
23 | import javax.swing.JLabel;\r | |
24 | import javax.swing.JPanel;\r | |
25 | import javax.swing.JScrollPane;\r | |
26 | import javax.swing.JTextField;\r | |
27 | \r | |
28 | import org.tianocore.frameworkwizard.common.DataType;\r | |
29 | import org.tianocore.frameworkwizard.common.DataValidation;\r | |
30 | import org.tianocore.frameworkwizard.common.EnumerationData;\r | |
31 | import org.tianocore.frameworkwizard.common.Log;\r | |
32 | import org.tianocore.frameworkwizard.common.Tools;\r | |
33 | import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;\r | |
34 | import org.tianocore.frameworkwizard.common.ui.IDialog;\r | |
35 | import org.tianocore.frameworkwizard.common.ui.IFrame;\r | |
36 | import org.tianocore.frameworkwizard.common.ui.StarLabel;\r | |
37 | import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r | |
c25ad66c | 38 | import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r |
06a19cee | 39 | import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassIdentification;\r |
c25ad66c | 40 | import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r |
06a19cee | 41 | import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r |
42 | \r | |
43 | /**\r | |
9e857952 | 44 | * The class is used to create, update Library Class Definition section of the MSA file\r |
928b45fb | 45 | * \r |
46 | * It extends IDialog\r | |
47 | * \r | |
9e857952 | 48 | */\r |
06a19cee | 49 | public class LibraryClassDefsDlg extends IDialog {\r |
50 | \r | |
51 | ///\r | |
52 | /// Define class Serial Version UID\r | |
53 | ///\r | |
54 | private static final long serialVersionUID = -1743248695411382857L;\r | |
55 | \r | |
56 | //\r | |
57 | //Define class members\r | |
58 | //\r | |
59 | private JPanel jContentPane = null;\r | |
60 | \r | |
61 | private JComboBox jComboBoxLibraryClassName = null;\r | |
62 | \r | |
63 | private JLabel jLabelUsage = null;\r | |
64 | \r | |
65 | private JComboBox jComboBoxUsage = null;\r | |
66 | \r | |
67 | private JLabel jLabelLibraryClassName = null;\r | |
68 | \r | |
69 | private JScrollPane jScrollPane = null;\r | |
70 | \r | |
71 | private StarLabel jStarLabel1 = null;\r | |
72 | \r | |
73 | private StarLabel jStarLabel2 = null;\r | |
74 | \r | |
75 | private JLabel jLabelRecommendedInstanceVersion = null;\r | |
76 | \r | |
77 | private JTextField jTextFieldRecommendedInstanceVersion = null;\r | |
78 | \r | |
79 | private JLabel jLabelRecommendedInstanceGuid = null;\r | |
80 | \r | |
81 | private JTextField jTextFieldRecommendedInstanceGuid = null;\r | |
82 | \r | |
83 | private JButton jButtonGenerateGuid = null;\r | |
84 | \r | |
85 | private JLabel jLabelFeatureFlag = null;\r | |
86 | \r | |
87 | private JTextField jTextFieldFeatureFlag = null;\r | |
88 | \r | |
89 | private JLabel jLabelArch = null;\r | |
90 | \r | |
91 | private JLabel jLabelModuleList = null;\r | |
92 | \r | |
93 | private JScrollPane jScrollPaneModuleList = null;\r | |
94 | \r | |
95 | private ICheckBoxList iCheckBoxListModule = null;\r | |
96 | \r | |
97 | private JLabel jLabelHelpText = null;\r | |
98 | \r | |
99 | private JTextField jTextFieldHelpText = null;\r | |
100 | \r | |
101 | private ArchCheckBox jArchCheckBox = null;\r | |
a929458e | 102 | \r |
06a19cee | 103 | private JButton jButtonOk = null;\r |
104 | \r | |
105 | private JButton jButtonCancel = null;\r | |
106 | \r | |
107 | //\r | |
108 | // Not for UI\r | |
109 | //\r | |
110 | private EnumerationData ed = new EnumerationData();\r | |
111 | \r | |
112 | private WorkspaceTools wt = new WorkspaceTools();\r | |
113 | \r | |
114 | private LibraryClassIdentification lcid = null;\r | |
115 | \r | |
116 | /**\r | |
117 | This method initializes jComboBoxSelect \r | |
118 | \r | |
119 | @return javax.swing.JComboBox jComboBoxSelect\r | |
120 | \r | |
121 | **/\r | |
122 | private JComboBox getJComboBoxLibraryClassName() {\r | |
123 | if (jComboBoxLibraryClassName == null) {\r | |
124 | jComboBoxLibraryClassName = new JComboBox();\r | |
928b45fb | 125 | jComboBoxLibraryClassName.setBounds(new java.awt.Rectangle(168, 12, 320, 20));\r |
06a19cee | 126 | jComboBoxLibraryClassName.setPreferredSize(new Dimension(320, 20));\r |
127 | jComboBoxLibraryClassName.setEnabled(true);\r | |
128 | }\r | |
129 | return jComboBoxLibraryClassName;\r | |
130 | }\r | |
131 | \r | |
132 | /**\r | |
133 | This method initializes jComboBoxUsage \r | |
134 | \r | |
135 | @return javax.swing.JComboBox jComboBoxUsage\r | |
136 | \r | |
137 | **/\r | |
138 | private JComboBox getJComboBoxUsage() {\r | |
139 | if (jComboBoxUsage == null) {\r | |
140 | jComboBoxUsage = new JComboBox();\r | |
928b45fb | 141 | jComboBoxUsage.setBounds(new java.awt.Rectangle(168, 37, 320, 20));\r |
06a19cee | 142 | jComboBoxUsage.setPreferredSize(new Dimension(320, 20));\r |
143 | }\r | |
144 | return jComboBoxUsage;\r | |
145 | }\r | |
146 | \r | |
147 | /**\r | |
148 | This method initializes jScrollPane \r | |
149 | \r | |
150 | @return javax.swing.JScrollPane \r | |
151 | */\r | |
152 | private JScrollPane getJScrollPane() {\r | |
153 | if (jScrollPane == null) {\r | |
154 | jScrollPane = new JScrollPane();\r | |
155 | jScrollPane.setViewportView(getJContentPane());\r | |
156 | }\r | |
157 | return jScrollPane;\r | |
158 | }\r | |
159 | \r | |
160 | /**\r | |
161 | * This method initializes jTextFieldRecommendedInstanceVersion \r | |
162 | * \r | |
163 | * @return javax.swing.JTextField \r | |
164 | */\r | |
165 | private JTextField getJTextFieldRecommendedInstanceVersion() {\r | |
166 | if (jTextFieldRecommendedInstanceVersion == null) {\r | |
167 | jTextFieldRecommendedInstanceVersion = new JTextField();\r | |
168 | jTextFieldRecommendedInstanceVersion.setPreferredSize(new java.awt.Dimension(260, 20));\r | |
169 | jTextFieldRecommendedInstanceVersion.setSize(new java.awt.Dimension(260, 20));\r | |
170 | jTextFieldRecommendedInstanceVersion.setLocation(new java.awt.Point(220, 85));\r | |
171 | jTextFieldRecommendedInstanceVersion.setVisible(false);\r | |
172 | }\r | |
173 | return jTextFieldRecommendedInstanceVersion;\r | |
174 | }\r | |
175 | \r | |
176 | /**\r | |
177 | * This method initializes jTextFieldRecommendedInstanceGuid \r | |
178 | * \r | |
179 | * @return javax.swing.JTextField \r | |
180 | */\r | |
181 | private JTextField getJTextFieldRecommendedInstanceGuid() {\r | |
182 | if (jTextFieldRecommendedInstanceGuid == null) {\r | |
183 | jTextFieldRecommendedInstanceGuid = new JTextField();\r | |
184 | jTextFieldRecommendedInstanceGuid.setBounds(new java.awt.Rectangle(220, 110, 190, 20));\r | |
185 | jTextFieldRecommendedInstanceGuid.setPreferredSize(new java.awt.Dimension(190, 20));\r | |
186 | jTextFieldRecommendedInstanceGuid.setVisible(false);\r | |
187 | }\r | |
188 | return jTextFieldRecommendedInstanceGuid;\r | |
189 | }\r | |
190 | \r | |
191 | /**\r | |
192 | * This method initializes jButtonGenerateGuid \r | |
193 | * \r | |
194 | * @return javax.swing.JButton \r | |
195 | */\r | |
196 | private JButton getJButtonGenerateGuid() {\r | |
197 | if (jButtonGenerateGuid == null) {\r | |
198 | jButtonGenerateGuid = new JButton();\r | |
928b45fb | 199 | jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 112, 65, 20));\r |
06a19cee | 200 | jButtonGenerateGuid.setPreferredSize(new java.awt.Dimension(65, 20));\r |
201 | jButtonGenerateGuid.setText("GEN");\r | |
202 | jButtonGenerateGuid.setVisible(false);\r | |
203 | jButtonGenerateGuid.addActionListener(this);\r | |
204 | }\r | |
205 | return jButtonGenerateGuid;\r | |
206 | }\r | |
207 | \r | |
208 | /**\r | |
209 | * This method initializes jTextFieldFeatureFlag \r | |
210 | * \r | |
211 | * @return javax.swing.JTextField \r | |
212 | */\r | |
213 | private JTextField getJTextFieldFeatureFlag() {\r | |
214 | if (jTextFieldFeatureFlag == null) {\r | |
215 | jTextFieldFeatureFlag = new JTextField();\r | |
21b42c66 | 216 | jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(168,197,320,20));\r |
06a19cee | 217 | jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));\r |
a929458e | 218 | jTextFieldFeatureFlag.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");\r |
21b42c66 | 219 | jTextFieldFeatureFlag.setEnabled(false);\r |
06a19cee | 220 | }\r |
221 | return jTextFieldFeatureFlag;\r | |
222 | }\r | |
223 | \r | |
224 | /**\r | |
225 | This method initializes iCheckBoxListArch \r | |
226 | \r | |
227 | @return ICheckBoxList \r | |
228 | **/\r | |
229 | private ICheckBoxList getICheckBoxListSupModuleList() {\r | |
230 | if (iCheckBoxListModule == null) {\r | |
231 | iCheckBoxListModule = new ICheckBoxList();\r | |
232 | }\r | |
233 | return iCheckBoxListModule;\r | |
234 | }\r | |
235 | \r | |
236 | /**\r | |
237 | This method initializes jScrollPaneModuleList \r | |
238 | \r | |
239 | @return javax.swing.JScrollPane \r | |
240 | \r | |
241 | **/\r | |
242 | private JScrollPane getJScrollPaneModuleList() {\r | |
243 | if (jScrollPaneModuleList == null) {\r | |
244 | jScrollPaneModuleList = new JScrollPane();\r | |
21b42c66 | 245 | jScrollPaneModuleList.setBounds(new java.awt.Rectangle(168, 112, 320, 80));\r |
06a19cee | 246 | jScrollPaneModuleList.setPreferredSize(new java.awt.Dimension(320, 80));\r |
247 | jScrollPaneModuleList.setViewportView(getICheckBoxListSupModuleList());\r | |
248 | }\r | |
249 | return jScrollPaneModuleList;\r | |
250 | }\r | |
251 | \r | |
252 | /**\r | |
253 | This method initializes jTextFieldHelpText \r | |
254 | \r | |
255 | @return javax.swing.JTextField \r | |
256 | \r | |
257 | **/\r | |
258 | private JTextField getJTextFieldHelpText() {\r | |
259 | if (jTextFieldHelpText == null) {\r | |
260 | jTextFieldHelpText = new JTextField();\r | |
928b45fb | 261 | jTextFieldHelpText.setBounds(new java.awt.Rectangle(168, 62, 320, 20));\r |
06a19cee | 262 | jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));\r |
263 | }\r | |
264 | return jTextFieldHelpText;\r | |
265 | }\r | |
266 | \r | |
267 | /**\r | |
268 | This method initializes jButtonOk \r | |
269 | \r | |
270 | @return javax.swing.JButton \r | |
271 | \r | |
272 | **/\r | |
273 | private JButton getJButtonOk() {\r | |
274 | if (jButtonOk == null) {\r | |
275 | jButtonOk = new JButton();\r | |
928b45fb | 276 | jButtonOk.setBounds(new java.awt.Rectangle(300, 232, 90, 20));\r |
06a19cee | 277 | jButtonOk.setText("Ok");\r |
278 | jButtonOk.addActionListener(this);\r | |
279 | }\r | |
280 | return jButtonOk;\r | |
281 | }\r | |
282 | \r | |
283 | /**\r | |
284 | This method initializes jButtonCancel \r | |
285 | \r | |
286 | @return javax.swing.JButton \r | |
287 | \r | |
288 | **/\r | |
289 | private JButton getJButtonCancel() {\r | |
290 | if (jButtonCancel == null) {\r | |
291 | jButtonCancel = new JButton();\r | |
928b45fb | 292 | jButtonCancel.setBounds(new java.awt.Rectangle(400, 232, 90, 20));\r |
06a19cee | 293 | jButtonCancel.setText("Cancel");\r |
294 | jButtonCancel.addActionListener(this);\r | |
295 | }\r | |
296 | return jButtonCancel;\r | |
297 | }\r | |
298 | \r | |
299 | public static void main(String[] args) {\r | |
300 | \r | |
301 | }\r | |
302 | \r | |
303 | /**\r | |
304 | This is the default constructor\r | |
305 | \r | |
306 | **/\r | |
c25ad66c | 307 | public LibraryClassDefsDlg(LibraryClassIdentification inLibraryClassIdentification, IFrame iFrame, ModuleIdentification mid) {\r |
06a19cee | 308 | super(iFrame, true);\r |
c25ad66c | 309 | init(inLibraryClassIdentification, mid);\r |
06a19cee | 310 | }\r |
311 | \r | |
312 | /**\r | |
313 | This method initializes this\r | |
314 | \r | |
315 | **/\r | |
316 | private void init() {\r | |
317 | this.setContentPane(getJScrollPane());\r | |
318 | this.setTitle("Library Class Definitions");\r | |
928b45fb | 319 | this.setBounds(new java.awt.Rectangle(0, 0, 505, 305));\r |
06a19cee | 320 | initFrame();\r |
321 | this.setViewMode(false);\r | |
322 | this.centerWindow();\r | |
323 | }\r | |
324 | \r | |
325 | /**\r | |
326 | This method initializes this\r | |
327 | \r | |
328 | **/\r | |
c25ad66c | 329 | private void init(LibraryClassIdentification inLibraryClassIdentification, ModuleIdentification mid) {\r |
06a19cee | 330 | init();\r |
331 | this.lcid = inLibraryClassIdentification;\r | |
c25ad66c | 332 | \r |
e08433ef | 333 | //\r |
334 | // Init arch with module's arch\r | |
335 | //\r | |
336 | this.jArchCheckBox.setEnabledItems(wt.getModuleArch(mid));\r | |
337 | \r | |
338 | //\r | |
339 | // Get defined library classes from dependent packages\r | |
340 | //\r | |
c25ad66c | 341 | Vector<PackageIdentification> vpid = wt.getPackageDependenciesOfModule(mid);\r |
342 | if (vpid.size() <= 0) {\r | |
343 | Log.wrn("Init Library Class", "This module hasn't defined any package dependency, so there is no library class can be added");\r | |
344 | }\r | |
345 | \r | |
346 | Tools.generateComboBoxByVector(this.jComboBoxLibraryClassName,\r | |
347 | wt.getAllLibraryClassDefinitionsFromPackages(wt.getPackageDependenciesOfModule(mid)));\r | |
348 | \r | |
06a19cee | 349 | if (lcid != null) {\r |
350 | this.jComboBoxLibraryClassName.setSelectedItem(lcid.getLibraryClassName());\r | |
351 | this.jComboBoxUsage.setSelectedItem(lcid.getUsage());\r | |
352 | this.jTextFieldRecommendedInstanceVersion.setText(lcid.getRecommendedInstanceVersion());\r | |
353 | this.jTextFieldRecommendedInstanceGuid.setText(lcid.getRecommendedInstanceGuid());\r | |
354 | this.jTextFieldFeatureFlag.setText(lcid.getFeatureFlag());\r | |
355 | this.jArchCheckBox.setSelectedItems(lcid.getSupArchList());\r | |
356 | this.iCheckBoxListModule.setAllItemsUnchecked();\r | |
357 | this.iCheckBoxListModule.initCheckedItem(true, lcid.getSupModuleList());\r | |
358 | this.jTextFieldHelpText.setText(lcid.getHelp());\r | |
359 | }\r | |
360 | }\r | |
361 | \r | |
362 | /**\r | |
363 | Disable all components when the mode is view\r | |
364 | \r | |
365 | @param isView true - The view mode; false - The non-view mode\r | |
366 | \r | |
367 | **/\r | |
368 | public void setViewMode(boolean isView) {\r | |
369 | if (isView) {\r | |
370 | this.jComboBoxLibraryClassName.setEnabled(!isView);\r | |
371 | this.jComboBoxUsage.setEnabled(!isView);\r | |
372 | }\r | |
373 | }\r | |
374 | \r | |
375 | /**\r | |
376 | This method initializes jContentPane\r | |
377 | \r | |
378 | @return javax.swing.JPanel jContentPane\r | |
379 | \r | |
380 | **/\r | |
381 | private JPanel getJContentPane() {\r | |
382 | if (jContentPane == null) {\r | |
383 | jArchCheckBox = new ArchCheckBox();\r | |
21b42c66 | 384 | jArchCheckBox.setBounds(new java.awt.Rectangle(168, 87, 320, 20));\r |
06a19cee | 385 | jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));\r |
386 | jLabelHelpText = new JLabel();\r | |
928b45fb | 387 | jLabelHelpText.setBounds(new java.awt.Rectangle(12, 62, 168, 20));\r |
06a19cee | 388 | jLabelHelpText.setText("Help Text");\r |
389 | jLabelModuleList = new JLabel();\r | |
21b42c66 | 390 | jLabelModuleList.setBounds(new java.awt.Rectangle(12, 112, 168, 20));\r |
ccb063b1 | 391 | jLabelModuleList.setText("Supported Module Types");\r |
06a19cee | 392 | jLabelArch = new JLabel();\r |
21b42c66 | 393 | jLabelArch.setBounds(new java.awt.Rectangle(12, 87, 168, 20));\r |
ccb063b1 | 394 | jLabelArch.setText("Supported Architectures");\r |
06a19cee | 395 | jLabelFeatureFlag = new JLabel();\r |
21b42c66 | 396 | jLabelFeatureFlag.setBounds(new java.awt.Rectangle(12,197,168,20));\r |
a929458e | 397 | jLabelFeatureFlag.setText("Feature Flag Expression");\r |
21b42c66 | 398 | jLabelFeatureFlag.setEnabled(false);\r |
06a19cee | 399 | jLabelRecommendedInstanceGuid = new JLabel();\r |
21b42c66 | 400 | jLabelRecommendedInstanceGuid.setBounds(new java.awt.Rectangle(12, 87, 200, 20));\r |
06a19cee | 401 | jLabelRecommendedInstanceGuid.setText("Recommended Instance Guid");\r |
402 | jLabelRecommendedInstanceGuid.setVisible(false);\r | |
403 | jLabelRecommendedInstanceVersion = new JLabel();\r | |
928b45fb | 404 | jLabelRecommendedInstanceVersion.setBounds(new java.awt.Rectangle(12, 87, 200, 20));\r |
06a19cee | 405 | jLabelRecommendedInstanceVersion.setText("Recommended Instance Version");\r |
406 | jLabelRecommendedInstanceVersion.setVisible(false);\r | |
407 | jLabelLibraryClassName = new JLabel();\r | |
928b45fb | 408 | jLabelLibraryClassName.setBounds(new java.awt.Rectangle(12, 12, 168, 20));\r |
06a19cee | 409 | jLabelLibraryClassName.setText("Library Class Name");\r |
410 | jLabelUsage = new JLabel();\r | |
928b45fb | 411 | jLabelUsage.setBounds(new java.awt.Rectangle(12, 37, 168, 20));\r |
06a19cee | 412 | jLabelUsage.setText("Usage");\r |
413 | jContentPane = new JPanel();\r | |
414 | jContentPane.setLayout(null);\r | |
928b45fb | 415 | jContentPane.setPreferredSize(new java.awt.Dimension(495, 255));\r |
06a19cee | 416 | \r |
417 | jContentPane.add(getJComboBoxLibraryClassName(), null);\r | |
418 | jContentPane.add(jLabelUsage, null);\r | |
419 | jContentPane.add(getJComboBoxUsage(), null);\r | |
420 | jContentPane.add(jLabelLibraryClassName, null);\r | |
421 | jContentPane.add(jLabelRecommendedInstanceVersion, null);\r | |
422 | jContentPane.add(getJTextFieldRecommendedInstanceVersion(), null);\r | |
423 | jContentPane.add(jLabelRecommendedInstanceGuid, null);\r | |
424 | jContentPane.add(getJTextFieldRecommendedInstanceGuid(), null);\r | |
425 | jContentPane.add(getJButtonGenerateGuid(), null);\r | |
426 | jContentPane.add(jLabelFeatureFlag, null);\r | |
427 | jContentPane.add(getJTextFieldFeatureFlag(), null);\r | |
428 | jContentPane.add(jLabelArch, null);\r | |
429 | jStarLabel1 = new StarLabel();\r | |
ccb063b1 | 430 | jStarLabel1.setLocation(new java.awt.Point(2, 10));\r |
06a19cee | 431 | jStarLabel2 = new StarLabel();\r |
ccb063b1 | 432 | jStarLabel2.setLocation(new java.awt.Point(2, 35));\r |
06a19cee | 433 | \r |
434 | jContentPane.add(jStarLabel1, null);\r | |
435 | jContentPane.add(jStarLabel2, null);\r | |
436 | jContentPane.add(jLabelModuleList, null);\r | |
437 | jContentPane.add(getJScrollPaneModuleList(), null);\r | |
438 | jContentPane.add(jLabelHelpText, null);\r | |
439 | jContentPane.add(getJTextFieldHelpText(), null);\r | |
440 | jContentPane.add(jArchCheckBox, null);\r | |
441 | jContentPane.add(getJButtonOk(), null);\r | |
442 | jContentPane.add(getJButtonCancel(), null);\r | |
443 | }\r | |
444 | return jContentPane;\r | |
445 | }\r | |
446 | \r | |
447 | /**\r | |
448 | This method initializes all existing libraries and usage types\r | |
449 | \r | |
450 | **/\r | |
451 | private void initFrame() {\r | |
06a19cee | 452 | Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVLibraryUsage());\r |
453 | this.iCheckBoxListModule.setAllItems(ed.getVFrameworkModuleTypes());\r | |
454 | }\r | |
455 | \r | |
456 | /* (non-Javadoc)\r | |
457 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r | |
458 | *\r | |
459 | * Override actionPerformed to listen all actions\r | |
460 | * \r | |
461 | */\r | |
462 | public void actionPerformed(ActionEvent arg0) {\r | |
463 | if (arg0.getSource() == jButtonGenerateGuid) {\r | |
464 | this.jTextFieldRecommendedInstanceGuid.setText(Tools.generateUuidString());\r | |
465 | }\r | |
466 | \r | |
467 | if (arg0.getSource() == jButtonOk) {\r | |
468 | if (checkAdd()) {\r | |
469 | getCurrentLibraryClass();\r | |
470 | this.returnType = DataType.RETURN_TYPE_OK;\r | |
471 | this.setVisible(false);\r | |
472 | }\r | |
473 | }\r | |
474 | \r | |
475 | if (arg0.getSource() == jButtonCancel) {\r | |
476 | this.returnType = DataType.RETURN_TYPE_CANCEL;\r | |
477 | this.setVisible(false);\r | |
478 | }\r | |
479 | }\r | |
480 | \r | |
481 | /**\r | |
482 | Data validation for all fields\r | |
483 | \r | |
484 | @retval true - All datas are valid\r | |
485 | @retval false - At least one data is invalid\r | |
486 | \r | |
487 | **/\r | |
488 | public boolean checkAdd() {\r | |
489 | //\r | |
490 | // Check LibraryClass\r | |
491 | //\r | |
492 | if (this.jComboBoxLibraryClassName.getSelectedItem() == null) {\r | |
c25ad66c | 493 | Log.wrn("Update Library Class Definitions", "Please select one Library Class");\r |
06a19cee | 494 | return false;\r |
495 | }\r | |
496 | if (!DataValidation.isLibraryClass(this.jComboBoxLibraryClassName.getSelectedItem().toString())) {\r | |
ed1665f2 | 497 | Log.wrn("Update Library Class Definitions", "Incorrect data type for Library Class");\r |
06a19cee | 498 | return false;\r |
499 | }\r | |
500 | \r | |
501 | //\r | |
502 | // Check RecommendedInstanceVersion\r | |
503 | //\r | |
504 | // if (!isEmpty(this.jTextFieldRecommendedInstanceVersion.getText())) {\r | |
505 | // if (!DataValidation.isRecommendedInstanceVersion(this.jTextFieldRecommendedInstanceVersion.getText())) {\r | |
506 | // Log.err("Incorrect data type for Recommended Instance Version");\r | |
507 | // return false;\r | |
508 | // }\r | |
509 | // }\r | |
510 | \r | |
511 | //\r | |
512 | // Check RecommendedInstanceGuid\r | |
513 | //\r | |
514 | // if (!isEmpty(this.jTextFieldRecommendedInstanceGuid.getText())) {\r | |
515 | // if (!DataValidation.isGuid(this.jTextFieldRecommendedInstanceGuid.getText())) {\r | |
516 | // Log.err("Incorrect data type for Recommended Instance Guid");\r | |
517 | // return false;\r | |
518 | // }\r | |
519 | // }\r | |
520 | \r | |
521 | //\r | |
522 | // Check FeatureFlag\r | |
523 | //\r | |
524 | if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {\r | |
525 | if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {\r | |
ed1665f2 | 526 | Log.wrn("Update Library Class Definitions", "Incorrect data type for Feature Flag");\r |
06a19cee | 527 | return false;\r |
528 | }\r | |
529 | }\r | |
530 | \r | |
531 | return true;\r | |
532 | }\r | |
533 | \r | |
534 | private LibraryClassIdentification getCurrentLibraryClass() {\r | |
535 | String name = this.jComboBoxLibraryClassName.getSelectedItem().toString();\r | |
536 | String usage = this.jComboBoxUsage.getSelectedItem().toString();\r | |
537 | String version = this.jTextFieldRecommendedInstanceVersion.getText();\r | |
538 | String guid = this.jTextFieldRecommendedInstanceGuid.getText();\r | |
539 | String featureFlag = this.jTextFieldFeatureFlag.getText();\r | |
540 | Vector<String> arch = this.jArchCheckBox.getSelectedItemsVector();\r | |
541 | Vector<String> module = this.iCheckBoxListModule.getAllCheckedItemsString();\r | |
542 | String help = this.jTextFieldHelpText.getText();\r | |
543 | lcid = new LibraryClassIdentification(name, usage, version, guid, arch, featureFlag, module, help);\r | |
544 | return lcid;\r | |
545 | }\r | |
546 | \r | |
547 | public LibraryClassIdentification getLcid() {\r | |
548 | return lcid;\r | |
549 | }\r | |
550 | \r | |
551 | public void setLcid(LibraryClassIdentification lcid) {\r | |
552 | this.lcid = lcid;\r | |
553 | }\r | |
554 | }\r |