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