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