]>
Commit | Line | Data |
---|---|---|
878ddf1f | 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.packaging.module.ui;\r | |
16 | \r | |
17 | import java.awt.event.ActionEvent;\r | |
18 | \r | |
19 | import javax.swing.DefaultListModel;\r | |
20 | import javax.swing.JButton;\r | |
21 | import javax.swing.JComboBox;\r | |
22 | import javax.swing.JLabel;\r | |
23 | import javax.swing.JList;\r | |
24 | import javax.swing.JPanel;\r | |
25 | import javax.swing.JRadioButton;\r | |
26 | import javax.swing.JScrollPane;\r | |
27 | import javax.swing.JTextField;\r | |
28 | \r | |
29 | import org.tianocore.LibraryClassDefinitionsDocument;\r | |
30 | import org.tianocore.LibraryClassDocument;\r | |
31 | import org.tianocore.LibraryUsage;\r | |
32 | import org.tianocore.common.DataValidation;\r | |
33 | import org.tianocore.common.Log;\r | |
34 | import org.tianocore.packaging.common.ui.IInternalFrame;\r | |
35 | \r | |
36 | /**\r | |
37 | The class is used to create, update Library Class Definition of MSA/MBD file\r | |
38 | It extends IInternalFrame\r | |
39 | \r | |
40 | @since ModuleEditor 1.0\r | |
41 | \r | |
42 | **/\r | |
43 | public class ModuleLibraryClassDefinitions extends IInternalFrame {\r | |
44 | \r | |
45 | ///\r | |
46 | /// Define class Serial Version UID\r | |
47 | ///\r | |
48 | private static final long serialVersionUID = -1743248695411382857L;\r | |
49 | \r | |
50 | //\r | |
51 | //Define class members\r | |
52 | //\r | |
53 | private static String Separator = "::";\r | |
54 | \r | |
55 | private DefaultListModel listItem = new DefaultListModel();\r | |
56 | \r | |
57 | private LibraryClassDefinitionsDocument.LibraryClassDefinitions libraryClassDefinitions = null;\r | |
58 | \r | |
59 | private JPanel jContentPane = null;\r | |
60 | \r | |
61 | private JRadioButton jRadioButtonAdd = null;\r | |
62 | \r | |
63 | private JRadioButton jRadioButtonSelect = null;\r | |
64 | \r | |
65 | private JTextField jTextFieldAdd = null;\r | |
66 | \r | |
67 | private JComboBox jComboBoxSelect = null;\r | |
68 | \r | |
69 | private JLabel jLabelUsage = null;\r | |
70 | \r | |
71 | private JComboBox jComboBoxUsage = null;\r | |
72 | \r | |
73 | private JScrollPane jScrollPane = null;\r | |
74 | \r | |
75 | private JList jListLibraryClassDefinitions = null;\r | |
76 | \r | |
77 | private JButton jButtonAdd = null;\r | |
78 | \r | |
79 | private JButton jButtonRemove = null;\r | |
80 | \r | |
81 | private JButton jButtonClearAll = null;\r | |
82 | \r | |
83 | private JButton jButtonCancel = null;\r | |
84 | \r | |
85 | private JButton jButtonOk = null;\r | |
86 | \r | |
87 | /**\r | |
88 | This method initializes jRadioButtonAdd \r | |
89 | \r | |
90 | @return javax.swing.JRadioButton jRadioButtonAdd\r | |
91 | \r | |
92 | **/\r | |
93 | private JRadioButton getJRadioButtonAdd() {\r | |
94 | if (jRadioButtonAdd == null) {\r | |
95 | jRadioButtonAdd = new JRadioButton();\r | |
96 | jRadioButtonAdd.setBounds(new java.awt.Rectangle(15, 35, 205, 20));\r | |
97 | jRadioButtonAdd.setText("Add a new Library Class");\r | |
98 | jRadioButtonAdd.addActionListener(this);\r | |
99 | jRadioButtonAdd.setSelected(false);\r | |
100 | }\r | |
101 | return jRadioButtonAdd;\r | |
102 | }\r | |
103 | \r | |
104 | /**\r | |
105 | This method initializes jRadioButtonSelect \r | |
106 | \r | |
107 | @return javax.swing.JRadioButton jRadioButtonSelect\r | |
108 | \r | |
109 | **/\r | |
110 | private JRadioButton getJRadioButtonSelect() {\r | |
111 | if (jRadioButtonSelect == null) {\r | |
112 | jRadioButtonSelect = new JRadioButton();\r | |
113 | jRadioButtonSelect.setBounds(new java.awt.Rectangle(15, 10, 205, 20));\r | |
2a8b1c0a | 114 | jRadioButtonSelect.setText("Select an existing Library Class");\r |
878ddf1f | 115 | jRadioButtonSelect.addActionListener(this);\r |
116 | jRadioButtonSelect.setSelected(true);\r | |
117 | }\r | |
118 | return jRadioButtonSelect;\r | |
119 | }\r | |
120 | \r | |
121 | /**\r | |
122 | This method initializes jTextFieldAdd \r | |
123 | \r | |
124 | @return javax.swing.JTextField jTextFieldAdd\r | |
125 | \r | |
126 | **/\r | |
127 | private JTextField getJTextFieldAdd() {\r | |
128 | if (jTextFieldAdd == null) {\r | |
129 | jTextFieldAdd = new JTextField();\r | |
130 | jTextFieldAdd.setBounds(new java.awt.Rectangle(220, 35, 260, 20));\r | |
131 | jTextFieldAdd.setEnabled(false);\r | |
132 | }\r | |
133 | return jTextFieldAdd;\r | |
134 | }\r | |
135 | \r | |
136 | /**\r | |
137 | This method initializes jComboBoxSelect \r | |
138 | \r | |
139 | @return javax.swing.JComboBox jComboBoxSelect\r | |
140 | \r | |
141 | **/\r | |
142 | private JComboBox getJComboBoxSelect() {\r | |
143 | if (jComboBoxSelect == null) {\r | |
144 | jComboBoxSelect = new JComboBox();\r | |
145 | jComboBoxSelect.setBounds(new java.awt.Rectangle(220, 10, 260, 20));\r | |
146 | jComboBoxSelect.setEnabled(true);\r | |
147 | }\r | |
148 | return jComboBoxSelect;\r | |
149 | }\r | |
150 | \r | |
151 | /**\r | |
152 | This method initializes jComboBoxUsage \r | |
153 | \r | |
154 | @return javax.swing.JComboBox jComboBoxUsage\r | |
155 | \r | |
156 | **/\r | |
157 | private JComboBox getJComboBoxUsage() {\r | |
158 | if (jComboBoxUsage == null) {\r | |
159 | jComboBoxUsage = new JComboBox();\r | |
160 | jComboBoxUsage.setBounds(new java.awt.Rectangle(220, 60, 260, 20));\r | |
161 | }\r | |
162 | return jComboBoxUsage;\r | |
163 | }\r | |
164 | \r | |
165 | /**\r | |
166 | This method initializes jScrollPane \r | |
167 | \r | |
168 | @return javax.swing.JScrollPane jScrollPane\r | |
169 | \r | |
170 | **/\r | |
171 | private JScrollPane getJScrollPane() {\r | |
172 | if (jScrollPane == null) {\r | |
173 | jScrollPane = new JScrollPane();\r | |
174 | jScrollPane.setBounds(new java.awt.Rectangle(15, 95, 350, 200));\r | |
175 | jScrollPane.setViewportView(getJListLibraryClassDefinitions());\r | |
176 | }\r | |
177 | return jScrollPane;\r | |
178 | }\r | |
179 | \r | |
180 | /**\r | |
181 | This method initializes jListLibraryClassDefinitions \r | |
182 | \r | |
183 | @return javax.swing.JList jListLibraryClassDefinitions\r | |
184 | \r | |
185 | **/\r | |
186 | private JList getJListLibraryClassDefinitions() {\r | |
187 | if (jListLibraryClassDefinitions == null) {\r | |
188 | jListLibraryClassDefinitions = new JList(listItem);\r | |
189 | }\r | |
190 | return jListLibraryClassDefinitions;\r | |
191 | }\r | |
192 | \r | |
193 | /**\r | |
194 | This method initializes jButtonAdd \r | |
195 | \r | |
196 | @return javax.swing.JButton jButtonAdd\r | |
197 | \r | |
198 | **/\r | |
199 | private JButton getJButtonAdd() {\r | |
200 | if (jButtonAdd == null) {\r | |
201 | jButtonAdd = new JButton();\r | |
202 | jButtonAdd.setBounds(new java.awt.Rectangle(380, 115, 90, 20));\r | |
203 | jButtonAdd.setText("Add");\r | |
204 | jButtonAdd.addActionListener(this);\r | |
205 | }\r | |
206 | return jButtonAdd;\r | |
207 | }\r | |
208 | \r | |
209 | /**\r | |
210 | This method initializes jButtonRemove\r | |
211 | \r | |
212 | @return javax.swing.JButton jButtonRemove \r | |
213 | \r | |
214 | **/\r | |
215 | private JButton getJButtonRemove() {\r | |
216 | if (jButtonRemove == null) {\r | |
217 | jButtonRemove = new JButton();\r | |
218 | jButtonRemove.setBounds(new java.awt.Rectangle(380, 230, 90, 20));\r | |
219 | jButtonRemove.setText("Remove");\r | |
220 | jButtonRemove.addActionListener(this);\r | |
221 | }\r | |
222 | return jButtonRemove;\r | |
223 | }\r | |
224 | \r | |
225 | /**\r | |
226 | This method initializes jButtonRemoveAll \r | |
227 | \r | |
228 | @return javax.swing.JButton jButtonClearAll\r | |
229 | \r | |
230 | **/\r | |
231 | private JButton getJButtonClearAll() {\r | |
232 | if (jButtonClearAll == null) {\r | |
233 | jButtonClearAll = new JButton();\r | |
234 | jButtonClearAll.setBounds(new java.awt.Rectangle(380, 260, 90, 20));\r | |
235 | jButtonClearAll.setText("Clear All");\r | |
236 | jButtonClearAll.addActionListener(this);\r | |
237 | }\r | |
238 | return jButtonClearAll;\r | |
239 | }\r | |
240 | \r | |
241 | /**\r | |
242 | This method initializes jButtonCancel \r | |
243 | \r | |
244 | @return javax.swing.JButton jButtonCancel\r | |
245 | \r | |
246 | **/\r | |
247 | private JButton getJButtonCancel() {\r | |
248 | if (jButtonCancel == null) {\r | |
249 | jButtonCancel = new JButton();\r | |
250 | jButtonCancel.setPreferredSize(new java.awt.Dimension(90, 20));\r | |
251 | jButtonCancel.setLocation(new java.awt.Point(390, 305));\r | |
252 | jButtonCancel.setText("Cancel");\r | |
253 | jButtonCancel.setSize(new java.awt.Dimension(90, 20));\r | |
254 | jButtonCancel.addActionListener(this);\r | |
255 | }\r | |
256 | return jButtonCancel;\r | |
257 | }\r | |
258 | \r | |
259 | /**\r | |
260 | This method initializes jButtonOk \r | |
261 | \r | |
262 | @return javax.swing.JButton jButtonOk\r | |
263 | \r | |
264 | **/\r | |
265 | private JButton getJButtonOk() {\r | |
266 | if (jButtonOk == null) {\r | |
267 | jButtonOk = new JButton();\r | |
268 | jButtonOk.setSize(new java.awt.Dimension(90, 20));\r | |
269 | jButtonOk.setText("OK");\r | |
270 | jButtonOk.setLocation(new java.awt.Point(290, 305));\r | |
271 | jButtonOk.addActionListener(this);\r | |
272 | }\r | |
273 | return jButtonOk;\r | |
274 | }\r | |
275 | \r | |
276 | public static void main(String[] args) {\r | |
277 | \r | |
278 | }\r | |
279 | \r | |
280 | /**\r | |
281 | This is the default constructor\r | |
282 | \r | |
283 | **/\r | |
284 | public ModuleLibraryClassDefinitions() {\r | |
285 | super();\r | |
286 | init();\r | |
287 | this.setVisible(true);\r | |
288 | }\r | |
289 | \r | |
290 | /**\r | |
291 | This is the override edit constructor\r | |
292 | \r | |
293 | @param inLibraryClassDefinitions The input data of LibraryClassDefinitionsDocument.LibraryClassDefinitions\r | |
294 | \r | |
295 | **/\r | |
296 | public ModuleLibraryClassDefinitions(\r | |
297 | LibraryClassDefinitionsDocument.LibraryClassDefinitions inLibraryClassDefinitions) {\r | |
298 | super();\r | |
299 | init(inLibraryClassDefinitions);\r | |
300 | this.setVisible(true);\r | |
301 | }\r | |
302 | \r | |
303 | /**\r | |
304 | This method initializes this\r | |
305 | Fill values to all fields if these values are not empty\r | |
306 | \r | |
307 | @param inLibraryClassDefinitions The input data of LibraryClassDefinitionsDocument.LibraryClassDefinitions\r | |
308 | \r | |
309 | **/\r | |
310 | private void init(LibraryClassDefinitionsDocument.LibraryClassDefinitions inLibraryClassDefinitions) {\r | |
311 | init();\r | |
312 | this.setLibraryClassDefinitions(inLibraryClassDefinitions);\r | |
313 | if (this.libraryClassDefinitions != null) {\r | |
314 | if (this.libraryClassDefinitions.getLibraryClassList().size() > 0) {\r | |
315 | for (int index = 0; index < this.libraryClassDefinitions.getLibraryClassList().size(); index++) {\r | |
316 | listItem.addElement(this.libraryClassDefinitions.getLibraryClassArray(index).getUsage().toString()\r | |
317 | + ModuleLibraryClassDefinitions.Separator\r | |
318 | + this.libraryClassDefinitions.getLibraryClassArray(index).getStringValue());\r | |
319 | this.libraryClassDefinitions.getLibraryClassList();\r | |
320 | }\r | |
321 | }\r | |
322 | }\r | |
323 | }\r | |
324 | \r | |
325 | /**\r | |
326 | This method initializes this\r | |
327 | \r | |
328 | **/\r | |
329 | private void init() {\r | |
330 | this.setContentPane(getJContentPane());\r | |
331 | this.setTitle("Library Class Definitions");\r | |
332 | this.setBounds(new java.awt.Rectangle(0, 0, 500, 515));\r | |
333 | //this.centerWindow();\r | |
334 | initFrame();\r | |
335 | this.setViewMode(false);\r | |
336 | }\r | |
337 | \r | |
338 | /**\r | |
339 | Disable all components when the mode is view\r | |
340 | \r | |
341 | @param isView true - The view mode; false - The non-view mode\r | |
342 | \r | |
343 | **/\r | |
344 | public void setViewMode(boolean isView) {\r | |
345 | this.jButtonOk.setVisible(false);\r | |
346 | this.jButtonCancel.setVisible(false);\r | |
347 | if (isView) {\r | |
348 | this.jRadioButtonAdd.setEnabled(!isView);\r | |
349 | this.jRadioButtonSelect.setEnabled(!isView);\r | |
350 | this.jTextFieldAdd.setEnabled(!isView);\r | |
351 | this.jComboBoxSelect.setEnabled(!isView);\r | |
352 | this.jComboBoxUsage.setEnabled(!isView);\r | |
353 | this.jButtonAdd.setEnabled(!isView);\r | |
354 | this.jButtonRemove.setEnabled(!isView);\r | |
355 | this.jButtonClearAll.setEnabled(!isView);\r | |
356 | this.jButtonCancel.setEnabled(!isView);\r | |
357 | this.jButtonOk.setEnabled(!isView);\r | |
358 | }\r | |
359 | }\r | |
360 | \r | |
361 | /**\r | |
362 | This method initializes jContentPane\r | |
363 | \r | |
364 | @return javax.swing.JPanel jContentPane\r | |
365 | \r | |
366 | **/\r | |
367 | private JPanel getJContentPane() {\r | |
368 | if (jContentPane == null) {\r | |
369 | jLabelUsage = new JLabel();\r | |
370 | jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 205, 20));\r | |
371 | jLabelUsage.setText("Usage");\r | |
372 | jContentPane = new JPanel();\r | |
373 | jContentPane.setLayout(null);\r | |
374 | jContentPane.add(getJRadioButtonAdd(), null);\r | |
375 | jContentPane.add(getJRadioButtonSelect(), null);\r | |
376 | jContentPane.add(getJTextFieldAdd(), null);\r | |
377 | jContentPane.add(getJComboBoxSelect(), null);\r | |
378 | jContentPane.add(jLabelUsage, null);\r | |
379 | jContentPane.add(getJComboBoxUsage(), null);\r | |
380 | jContentPane.add(getJScrollPane(), null);\r | |
381 | jContentPane.add(getJButtonAdd(), null);\r | |
382 | jContentPane.add(getJButtonRemove(), null);\r | |
383 | jContentPane.add(getJButtonClearAll(), null);\r | |
384 | jContentPane.add(getJButtonCancel(), null);\r | |
385 | jContentPane.add(getJButtonOk(), null);\r | |
386 | }\r | |
387 | return jContentPane;\r | |
388 | }\r | |
389 | \r | |
390 | /**\r | |
391 | This method initializes all existing libraries and usage types\r | |
392 | \r | |
393 | **/\r | |
394 | private void initFrame() {\r | |
395 | jComboBoxSelect.addItem("BaseCpuICacheFlush");\r | |
396 | jComboBoxSelect.addItem("BaseDebugLibNull");\r | |
397 | jComboBoxSelect.addItem("BaseDebugLibReportStatusCode");\r | |
398 | jComboBoxSelect.addItem("BaseIoLibIntrinsic");\r | |
399 | jComboBoxSelect.addItem("BaseLib");\r | |
400 | jComboBoxSelect.addItem("BaseMemoryLib");\r | |
401 | jComboBoxSelect.addItem("BaseMemoryLibMmx");\r | |
402 | jComboBoxSelect.addItem("BaseMemoryLibSse2");\r | |
403 | jComboBoxSelect.addItem("BasePeCoffGetEntryPointLib");\r | |
404 | jComboBoxSelect.addItem("BasePeCoffLib");\r | |
405 | jComboBoxSelect.addItem("BasePrintLib");\r | |
406 | jComboBoxSelect.addItem("BaseReportStatusCodeLibNull");\r | |
407 | jComboBoxSelect.addItem("CommonPciCf8Lib");\r | |
408 | jComboBoxSelect.addItem("CommonPciExpressLib");\r | |
409 | jComboBoxSelect.addItem("CommonPciLibCf8");\r | |
410 | jComboBoxSelect.addItem("CommonPciLibPciExpress");\r | |
411 | jComboBoxSelect.addItem("DxeCoreEntryPoint");\r | |
412 | jComboBoxSelect.addItem("DxeHobLib");\r | |
413 | jComboBoxSelect.addItem("DxeIoLibCpuIo");\r | |
414 | jComboBoxSelect.addItem("DxeLib");\r | |
415 | jComboBoxSelect.addItem("DxePcdLib");\r | |
416 | jComboBoxSelect.addItem("DxeReportStatusCodeLib");\r | |
417 | jComboBoxSelect.addItem("DxeServicesTableLib");\r | |
418 | jComboBoxSelect.addItem("PeiCoreEntryPoint");\r | |
419 | jComboBoxSelect.addItem("PeiMemoryLib");\r | |
420 | jComboBoxSelect.addItem("PeimEntryPoint");\r | |
421 | jComboBoxSelect.addItem("PeiReportStatusCodeLib");\r | |
422 | jComboBoxSelect.addItem("PeiServicesTablePointerLib");\r | |
423 | jComboBoxSelect.addItem("PeiServicesTablePointerLibMm7");\r | |
424 | jComboBoxSelect.addItem("UefiDebugLibConOut");\r | |
425 | jComboBoxSelect.addItem("UefiDebugLibStdErr");\r | |
426 | jComboBoxSelect.addItem("UefiDriverEntryPointMultiple");\r | |
427 | jComboBoxSelect.addItem("UefiDriverEntryPointSingle");\r | |
428 | jComboBoxSelect.addItem("UefiDriverEntryPointSingleUnload");\r | |
429 | jComboBoxSelect.addItem("UefiDriverModelLib");\r | |
430 | jComboBoxSelect.addItem("UefiDriverModelLibNoConfigNoDiag");\r | |
431 | jComboBoxSelect.addItem("UefiLib");\r | |
432 | jComboBoxSelect.addItem("UefiMemoryLib");\r | |
433 | \r | |
434 | jComboBoxUsage.addItem("ALWAYS_CONSUMED");\r | |
435 | jComboBoxUsage.addItem("SOMETIMES_CONSUMED");\r | |
436 | jComboBoxUsage.addItem("ALWAYS_PRODUCED");\r | |
437 | jComboBoxUsage.addItem("SOMETIMES_PRODUCED");\r | |
438 | jComboBoxUsage.addItem("DEFAULT");\r | |
439 | jComboBoxUsage.addItem("PRIVATE");\r | |
440 | }\r | |
441 | \r | |
442 | /* (non-Javadoc)\r | |
443 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r | |
444 | *\r | |
445 | * Override actionPerformed to listen all actions\r | |
446 | * \r | |
447 | */\r | |
448 | public void actionPerformed(ActionEvent arg0) {\r | |
449 | if (arg0.getSource() == jButtonOk) {\r | |
450 | this.dispose();\r | |
451 | this.setEdited(true);\r | |
452 | this.save();\r | |
453 | }\r | |
454 | if (arg0.getSource() == jButtonCancel) {\r | |
455 | this.dispose();\r | |
456 | this.setEdited(false);\r | |
457 | }\r | |
458 | \r | |
459 | //\r | |
460 | // Add current Library and its usage to the list\r | |
461 | //\r | |
462 | if (arg0.getSource() == jButtonAdd) {\r | |
463 | if (!checkAdd()) {\r | |
464 | return;\r | |
465 | }\r | |
466 | String strLibClass = "";\r | |
467 | String strUsage = "";\r | |
468 | if (jRadioButtonAdd.isSelected()) {\r | |
469 | strLibClass = jTextFieldAdd.getText();\r | |
470 | }\r | |
471 | if (jRadioButtonSelect.isSelected()) {\r | |
472 | strLibClass = jComboBoxSelect.getSelectedItem().toString();\r | |
473 | }\r | |
474 | strUsage = jComboBoxUsage.getSelectedItem().toString();\r | |
475 | listItem.addElement(strUsage + ModuleLibraryClassDefinitions.Separator + strLibClass);\r | |
476 | }\r | |
477 | \r | |
478 | //\r | |
479 | // Remove current Library and its usage of the list\r | |
480 | //\r | |
481 | if (arg0.getSource() == jButtonRemove) {\r | |
482 | int intSelected[] = jListLibraryClassDefinitions.getSelectedIndices();\r | |
483 | if (intSelected.length > 0) {\r | |
484 | for (int index = intSelected.length - 1; index > -1; index--) {\r | |
485 | listItem.removeElementAt(intSelected[index]);\r | |
486 | }\r | |
487 | }\r | |
488 | jListLibraryClassDefinitions.getSelectionModel().clearSelection();\r | |
489 | }\r | |
490 | \r | |
491 | if (arg0.getSource() == jButtonClearAll) {\r | |
492 | listItem.removeAllElements();\r | |
493 | }\r | |
494 | \r | |
495 | //\r | |
496 | // Contorl the selected status when click RadionButton\r | |
497 | // Do not use Radio Button Group\r | |
498 | //\r | |
499 | if (arg0.getSource() == jRadioButtonAdd) {\r | |
500 | if (jRadioButtonAdd.isSelected()) {\r | |
501 | jRadioButtonSelect.setSelected(false);\r | |
502 | jTextFieldAdd.setEnabled(true);\r | |
503 | jComboBoxSelect.setEnabled(false);\r | |
504 | }\r | |
505 | if (!jRadioButtonSelect.isSelected() && !jRadioButtonAdd.isSelected()) {\r | |
506 | jRadioButtonAdd.setSelected(true);\r | |
507 | jTextFieldAdd.setEnabled(true);\r | |
508 | jComboBoxSelect.setEnabled(false);\r | |
509 | }\r | |
510 | }\r | |
511 | \r | |
512 | if (arg0.getSource() == jRadioButtonSelect) {\r | |
513 | if (jRadioButtonSelect.isSelected()) {\r | |
514 | jRadioButtonAdd.setSelected(false);\r | |
515 | jTextFieldAdd.setEnabled(false);\r | |
516 | jComboBoxSelect.setEnabled(true);\r | |
517 | }\r | |
518 | if (!jRadioButtonSelect.isSelected() && !jRadioButtonAdd.isSelected()) {\r | |
519 | jRadioButtonSelect.setSelected(true);\r | |
520 | jTextFieldAdd.setEnabled(false);\r | |
521 | jComboBoxSelect.setEnabled(true);\r | |
522 | }\r | |
523 | }\r | |
524 | }\r | |
525 | \r | |
526 | /**\r | |
527 | Data validation for all fields\r | |
528 | \r | |
529 | @retval true - All datas are valid\r | |
530 | @retval false - At least one data is invalid\r | |
531 | \r | |
532 | **/\r | |
533 | public boolean check() {\r | |
534 | if (listItem.getSize() < 1) {\r | |
535 | Log.err("Must have one Library Class at least!");\r | |
536 | return false;\r | |
537 | }\r | |
538 | return true;\r | |
539 | }\r | |
540 | \r | |
541 | /**\r | |
542 | Data validation for all fields\r | |
543 | \r | |
544 | @retval true - All datas are valid\r | |
545 | @retval false - At least one data is invalid\r | |
546 | \r | |
547 | **/\r | |
548 | public boolean checkAdd() {\r | |
549 | //\r | |
550 | // Check if all required fields are not empty\r | |
551 | //\r | |
552 | if (this.jRadioButtonAdd.isSelected() && isEmpty(this.jTextFieldAdd.getText())) {\r | |
553 | Log.err("Library Class couldn't be empty");\r | |
554 | return false;\r | |
555 | }\r | |
556 | \r | |
557 | //\r | |
558 | // Check if all fields have correct data types \r | |
559 | //\r | |
560 | if (this.jRadioButtonAdd.isSelected() && !DataValidation.isLibraryClass(this.jTextFieldAdd.getText())) {\r | |
561 | Log.err("Incorrect data type for Library Class");\r | |
562 | return false;\r | |
563 | }\r | |
564 | return true;\r | |
565 | }\r | |
566 | \r | |
567 | /**\r | |
568 | Save all components of Mbd Header\r | |
569 | if exists mbdHeader, set the value directly\r | |
570 | if not exists mbdHeader, new an instance first\r | |
571 | \r | |
572 | **/\r | |
573 | public void save() {\r | |
574 | try {\r | |
575 | int intLibraryCount = listItem.getSize();\r | |
576 | \r | |
577 | if (this.libraryClassDefinitions == null) {\r | |
578 | libraryClassDefinitions = LibraryClassDefinitionsDocument.LibraryClassDefinitions.Factory.newInstance();\r | |
579 | }\r | |
580 | \r | |
581 | if (intLibraryCount > 0) {\r | |
582 | LibraryClassDocument.LibraryClass mLibraryClass = LibraryClassDocument.LibraryClass.Factory\r | |
583 | .newInstance();\r | |
584 | for (int index = this.libraryClassDefinitions.getLibraryClassList().size() - 1; index > -1; index--) {\r | |
585 | this.libraryClassDefinitions.removeLibraryClass(index);\r | |
586 | }\r | |
587 | for (int index = 0; index < intLibraryCount; index++) {\r | |
588 | String strAll = listItem.get(index).toString();\r | |
589 | String strUsage = strAll.substring(0, strAll.indexOf(ModuleLibraryClassDefinitions.Separator));\r | |
590 | String strLibraryClass = strAll.substring(strAll.indexOf(ModuleLibraryClassDefinitions.Separator)\r | |
591 | + ModuleLibraryClassDefinitions.Separator.length());\r | |
592 | mLibraryClass.setStringValue(strLibraryClass);\r | |
593 | mLibraryClass.setUsage(LibraryUsage.Enum.forString(strUsage));\r | |
594 | this.libraryClassDefinitions.addNewLibraryClass();\r | |
595 | this.libraryClassDefinitions.setLibraryClassArray(index, mLibraryClass);\r | |
596 | }\r | |
597 | } else {\r | |
598 | this.libraryClassDefinitions.setNil();\r | |
599 | }\r | |
600 | } catch (Exception e) {\r | |
601 | Log.err("Update Library Class Definitions", e.getMessage());\r | |
602 | }\r | |
603 | }\r | |
604 | \r | |
605 | /**\r | |
606 | Get LibraryClassDefinitionsDocument.LibraryClassDefinitions\r | |
607 | \r | |
2a8b1c0a | 608 | @return LibraryClassDefinitionsDocument.LibraryClassDefinitions\r |
878ddf1f | 609 | \r |
610 | **/\r | |
611 | public LibraryClassDefinitionsDocument.LibraryClassDefinitions getLibraryClassDefinitions() {\r | |
612 | return libraryClassDefinitions;\r | |
613 | }\r | |
614 | \r | |
615 | /**\r | |
616 | Set LibraryClassDefinitionsDocument.LibraryClassDefinitions\r | |
617 | \r | |
618 | @param libraryClassDefinitions The input data of LibraryClassDefinitionsDocument.LibraryClassDefinitions\r | |
619 | \r | |
620 | **/\r | |
621 | public void setLibraryClassDefinitions(\r | |
622 | LibraryClassDefinitionsDocument.LibraryClassDefinitions libraryClassDefinitions) {\r | |
623 | this.libraryClassDefinitions = libraryClassDefinitions;\r | |
624 | }\r | |
625 | }\r |