]>
Commit | Line | Data |
---|---|---|
a13899c5 | 1 | /** @file\r |
2 | \r | |
3 | The file is used to create, update BootModes 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 | \r | |
16 | package org.tianocore.frameworkwizard.module.ui;\r | |
17 | \r | |
18 | import java.awt.event.ActionEvent;\r | |
19 | import java.awt.event.ComponentEvent;\r | |
20 | import java.awt.event.ItemEvent;\r | |
21 | import java.util.Vector;\r | |
22 | \r | |
23 | import javax.swing.JButton;\r | |
24 | import javax.swing.JComboBox;\r | |
25 | import javax.swing.JLabel;\r | |
26 | import javax.swing.JPanel;\r | |
27 | import javax.swing.JScrollPane;\r | |
28 | import javax.swing.JTextArea;\r | |
29 | import javax.swing.JTextField;\r | |
30 | \r | |
31 | import org.tianocore.BootModeNames;\r | |
32 | import org.tianocore.BootModeUsage;\r | |
33 | import org.tianocore.BootModesDocument;\r | |
34 | import org.tianocore.BootModesDocument.BootModes;\r | |
35 | import org.tianocore.BootModesDocument.BootModes.BootMode;\r | |
36 | import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r | |
37 | import org.tianocore.frameworkwizard.common.DataType;\r | |
38 | import org.tianocore.frameworkwizard.common.DataValidation;\r | |
39 | import org.tianocore.frameworkwizard.common.EnumerationData;\r | |
40 | import org.tianocore.frameworkwizard.common.Log;\r | |
a13899c5 | 41 | import org.tianocore.frameworkwizard.common.Tools;\r |
79cb6fdb | 42 | import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;\r |
a13899c5 | 43 | import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r |
44 | import org.tianocore.frameworkwizard.common.ui.StarLabel;\r | |
45 | import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r | |
79cb6fdb | 46 | import org.tianocore.frameworkwizard.module.Identifications.BootModes.BootModesIdentification;\r |
47 | import org.tianocore.frameworkwizard.module.Identifications.BootModes.BootModesVector;\r | |
a13899c5 | 48 | \r |
49 | /**\r | |
50 | The class is used to create, update BootModes of MSA/MBD file\r | |
51 | It extends IInternalFrame\r | |
52 | \r | |
53 | \r | |
54 | \r | |
55 | **/\r | |
56 | public class ModuleBootModes extends IInternalFrame {\r | |
57 | \r | |
58 | ///\r | |
59 | /// Define class Serial Version UID\r | |
60 | ///\r | |
61 | private static final long serialVersionUID = -3888558623432442561L;\r | |
62 | \r | |
63 | //\r | |
64 | //Define class members\r | |
65 | //\r | |
66 | private JPanel jContentPane = null;\r | |
67 | \r | |
68 | private JLabel jLabelBootModeName = null;\r | |
69 | \r | |
70 | private JComboBox jComboBoxBootModeName = null;\r | |
71 | \r | |
72 | private JLabel jLabelUsage = null;\r | |
73 | \r | |
74 | private JComboBox jComboBoxUsage = null;\r | |
75 | \r | |
76 | private StarLabel jStarLabel1 = null;\r | |
77 | \r | |
78 | private StarLabel jStarLabel2 = null;\r | |
79 | \r | |
80 | private JLabel jLabelFeatureFlag = null;\r | |
81 | \r | |
82 | private JTextField jTextFieldFeatureFlag = null;\r | |
83 | \r | |
84 | private JLabel jLabelArch = null;\r | |
85 | \r | |
86 | private JTextArea jTextAreaList = null;\r | |
87 | \r | |
88 | private JComboBox jComboBoxList = null;\r | |
89 | \r | |
90 | private JButton jButtonAdd = null;\r | |
91 | \r | |
92 | private JButton jButtonRemove = null;\r | |
93 | \r | |
94 | private JButton jButtonUpdate = null;\r | |
95 | \r | |
96 | private JScrollPane jScrollPane = null;\r | |
97 | \r | |
98 | private JScrollPane jScrollPaneList = null;\r | |
99 | \r | |
100 | private ICheckBoxList iCheckBoxListArch = null;\r | |
101 | \r | |
102 | private JScrollPane jScrollPaneArch = null;\r | |
103 | \r | |
104 | private JLabel jLabelHelpText = null;\r | |
105 | \r | |
106 | private JTextField jTextFieldHelpText = null;\r | |
107 | \r | |
108 | //\r | |
109 | // Not used by UI\r | |
110 | //\r | |
111 | private int intSelectedItemId = 0;\r | |
112 | \r | |
113 | private OpeningModuleType omt = null;\r | |
114 | \r | |
115 | private ModuleSurfaceArea msa = null;\r | |
116 | \r | |
117 | private BootModesDocument.BootModes bootModes = null;\r | |
118 | \r | |
119 | private BootModesIdentification id = null;\r | |
120 | \r | |
121 | private BootModesVector vid = new BootModesVector();\r | |
122 | \r | |
123 | private EnumerationData ed = new EnumerationData();\r | |
124 | \r | |
125 | /**\r | |
126 | This method initializes jComboBoxBootModeName \r | |
127 | \r | |
128 | @return javax.swing.JComboBox jComboBoxBootModeName\r | |
129 | \r | |
130 | **/\r | |
131 | private JComboBox getJComboBoxBootModeName() {\r | |
132 | if (jComboBoxBootModeName == null) {\r | |
133 | jComboBoxBootModeName = new JComboBox();\r | |
134 | jComboBoxBootModeName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));\r | |
135 | jComboBoxBootModeName.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
136 | }\r | |
137 | return jComboBoxBootModeName;\r | |
138 | }\r | |
139 | \r | |
140 | /**\r | |
141 | This method initializes jComboBoxUsage \r | |
142 | \r | |
143 | @return javax.swing.JComboBox jComboBoxUsage\r | |
144 | \r | |
145 | **/\r | |
146 | private JComboBox getJComboBoxUsage() {\r | |
147 | if (jComboBoxUsage == null) {\r | |
148 | jComboBoxUsage = new JComboBox();\r | |
149 | jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));\r | |
150 | jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
151 | }\r | |
152 | return jComboBoxUsage;\r | |
153 | }\r | |
154 | \r | |
155 | /**\r | |
156 | * This method initializes jTextFieldFeatureFlag \r | |
157 | * \r | |
158 | * @return javax.swing.JTextField \r | |
159 | */\r | |
160 | private JTextField getJTextFieldFeatureFlag() {\r | |
161 | if (jTextFieldFeatureFlag == null) {\r | |
162 | jTextFieldFeatureFlag = new JTextField();\r | |
163 | jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));\r | |
164 | jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
165 | }\r | |
166 | return jTextFieldFeatureFlag;\r | |
167 | }\r | |
168 | \r | |
169 | /**\r | |
170 | This method initializes jComboBoxFileList \r | |
171 | \r | |
172 | @return javax.swing.JComboBox jComboBoxFileList\r | |
173 | \r | |
174 | **/\r | |
175 | private JComboBox getJComboBoxList() {\r | |
176 | if (jComboBoxList == null) {\r | |
177 | jComboBoxList = new JComboBox();\r | |
178 | jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));\r | |
179 | jComboBoxList.addItemListener(this);\r | |
180 | jComboBoxList.addActionListener(this);\r | |
181 | jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));\r | |
182 | }\r | |
183 | return jComboBoxList;\r | |
184 | }\r | |
185 | \r | |
186 | /**\r | |
187 | This method initializes jButtonAdd \r | |
188 | \r | |
189 | @return javax.swing.JButton jButtonAdd\r | |
190 | \r | |
191 | **/\r | |
192 | private JButton getJButtonAdd() {\r | |
193 | if (jButtonAdd == null) {\r | |
194 | jButtonAdd = new JButton();\r | |
195 | jButtonAdd.setBounds(new java.awt.Rectangle(230, 195, 80, 20));\r | |
196 | jButtonAdd.setText("Add");\r | |
197 | jButtonAdd.addActionListener(this);\r | |
198 | jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));\r | |
199 | }\r | |
200 | return jButtonAdd;\r | |
201 | }\r | |
202 | \r | |
203 | /**\r | |
204 | This method initializes jButtonRemove \r | |
205 | \r | |
206 | @return javax.swing.JButton jButtonRemove\r | |
207 | \r | |
208 | **/\r | |
209 | private JButton getJButtonRemove() {\r | |
210 | if (jButtonRemove == null) {\r | |
211 | jButtonRemove = new JButton();\r | |
212 | jButtonRemove.setBounds(new java.awt.Rectangle(400, 195, 80, 20));\r | |
213 | jButtonRemove.setText("Remove");\r | |
214 | jButtonRemove.addActionListener(this);\r | |
215 | jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));\r | |
216 | }\r | |
217 | return jButtonRemove;\r | |
218 | }\r | |
219 | \r | |
220 | /**\r | |
221 | This method initializes jButtonUpdate \r | |
222 | \r | |
223 | @return javax.swing.JButton jButtonUpdate\r | |
224 | \r | |
225 | **/\r | |
226 | private JButton getJButtonUpdate() {\r | |
227 | if (jButtonUpdate == null) {\r | |
228 | jButtonUpdate = new JButton();\r | |
229 | jButtonUpdate.setBounds(new java.awt.Rectangle(315, 195, 80, 20));\r | |
230 | jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));\r | |
231 | jButtonUpdate.setText("Update");\r | |
232 | jButtonUpdate.addActionListener(this);\r | |
233 | }\r | |
234 | return jButtonUpdate;\r | |
235 | }\r | |
236 | \r | |
237 | /**\r | |
238 | * This method initializes jScrollPaneFileList \r | |
239 | * \r | |
240 | * @return javax.swing.JScrollPane \r | |
241 | */\r | |
242 | private JScrollPane getJScrollPaneList() {\r | |
243 | if (jScrollPaneList == null) {\r | |
244 | jScrollPaneList = new JScrollPane();\r | |
245 | jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));\r | |
246 | jScrollPaneList.setViewportView(getJTextAreaList());\r | |
247 | jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));\r | |
248 | }\r | |
249 | return jScrollPaneList;\r | |
250 | }\r | |
251 | \r | |
252 | /**\r | |
253 | This method initializes jScrollPane \r | |
254 | \r | |
255 | @return javax.swing.JScrollPane \r | |
256 | */\r | |
257 | private JScrollPane getJScrollPane() {\r | |
258 | if (jScrollPane == null) {\r | |
259 | jScrollPane = new JScrollPane();\r | |
260 | jScrollPane.setViewportView(getJContentPane());\r | |
261 | }\r | |
262 | return jScrollPane;\r | |
263 | }\r | |
264 | \r | |
265 | /**\r | |
266 | * This method initializes jTextAreaFileList \r | |
267 | * \r | |
268 | * @return javax.swing.JTextArea \r | |
269 | */\r | |
270 | private JTextArea getJTextAreaList() {\r | |
271 | if (jTextAreaList == null) {\r | |
272 | jTextAreaList = new JTextArea();\r | |
273 | jTextAreaList.setEditable(false);\r | |
274 | \r | |
275 | }\r | |
276 | return jTextAreaList;\r | |
277 | }\r | |
278 | \r | |
279 | /**\r | |
280 | This method initializes iCheckBoxListArch \r | |
281 | \r | |
282 | @return ICheckBoxList \r | |
283 | **/\r | |
284 | private ICheckBoxList getICheckBoxListSupportedArchitectures() {\r | |
285 | if (iCheckBoxListArch == null) {\r | |
286 | iCheckBoxListArch = new ICheckBoxList();\r | |
287 | iCheckBoxListArch.addFocusListener(this);\r | |
288 | iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);\r | |
289 | }\r | |
290 | return iCheckBoxListArch;\r | |
291 | }\r | |
292 | \r | |
293 | /**\r | |
294 | This method initializes jScrollPaneArch \r | |
295 | \r | |
296 | @return javax.swing.JScrollPane \r | |
297 | \r | |
298 | **/\r | |
299 | private JScrollPane getJScrollPaneArch() {\r | |
300 | if (jScrollPaneArch == null) {\r | |
301 | jScrollPaneArch = new JScrollPane();\r | |
302 | jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));\r | |
303 | jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));\r | |
304 | jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());\r | |
305 | }\r | |
306 | return jScrollPaneArch;\r | |
307 | }\r | |
308 | \r | |
309 | /**\r | |
310 | This method initializes jTextFieldHelpText \r | |
311 | \r | |
312 | @return javax.swing.JTextField \r | |
313 | \r | |
314 | **/\r | |
315 | private JTextField getJTextFieldHelpText() {\r | |
316 | if (jTextFieldHelpText == null) {\r | |
317 | jTextFieldHelpText = new JTextField();\r | |
318 | jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));\r | |
319 | jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
320 | }\r | |
321 | return jTextFieldHelpText;\r | |
322 | }\r | |
323 | \r | |
324 | public static void main(String[] args) {\r | |
325 | }\r | |
326 | \r | |
327 | /**\r | |
328 | This method initializes this\r | |
329 | \r | |
330 | **/\r | |
331 | private void init() {\r | |
332 | this.setSize(500, 515);\r | |
333 | this.setContentPane(getJScrollPane());\r | |
334 | this.setTitle("Boot Modes");\r | |
335 | initFrame();\r | |
336 | this.setViewMode(false);\r | |
337 | }\r | |
338 | \r | |
339 | /**\r | |
340 | This method initializes this\r | |
341 | Fill values to all fields if these values are not empty\r | |
342 | \r | |
343 | @param inPackageDependencies\r | |
344 | \r | |
345 | **/\r | |
346 | private void init(BootModes inBootModes) {\r | |
347 | init();\r | |
348 | this.bootModes = inBootModes;\r | |
349 | \r | |
350 | if (this.bootModes != null) {\r | |
351 | if (this.bootModes.getBootModeList().size() > 0) {\r | |
352 | for (int index = 0; index < this.bootModes.getBootModeList().size(); index++) {\r | |
353 | String arg0 = null;\r | |
354 | if (bootModes.getBootModeList().get(index).getBootModeName() != null) {\r | |
355 | arg0 = bootModes.getBootModeList().get(index).getBootModeName().toString();\r | |
356 | }\r | |
357 | String arg1 = null;\r | |
358 | if (bootModes.getBootModeList().get(index).getUsage() != null) {\r | |
359 | arg1 = bootModes.getBootModeList().get(index).getUsage().toString(); \r | |
360 | }\r | |
361 | \r | |
362 | String arg2 = bootModes.getBootModeList().get(index).getFeatureFlag();\r | |
363 | Vector<String> arg3 = Tools.convertListToVector(bootModes.getBootModeList().get(index).getSupArchList());\r | |
364 | String arg4 = bootModes.getBootModeList().get(index).getHelpText();\r | |
365 | \r | |
366 | id = new BootModesIdentification(arg0, arg1, arg2, arg3, arg4);\r | |
367 | vid.addBootModes(id);\r | |
368 | }\r | |
369 | }\r | |
370 | }\r | |
371 | //\r | |
372 | // Update the list\r | |
373 | //\r | |
374 | Tools.generateComboBoxByVector(jComboBoxList, vid.getBootModesName());\r | |
375 | reloadListArea();\r | |
376 | }\r | |
377 | \r | |
378 | /**\r | |
379 | This is the default constructor\r | |
380 | \r | |
381 | **/\r | |
382 | public ModuleBootModes() {\r | |
383 | super();\r | |
384 | init();\r | |
385 | this.setVisible(true);\r | |
386 | }\r | |
387 | \r | |
388 | /**\r | |
389 | This is the override edit constructor\r | |
390 | \r | |
391 | @param inBootModes The input BootModesDocument.BootModes\r | |
392 | \r | |
393 | **/\r | |
394 | public ModuleBootModes(OpeningModuleType inOmt) {\r | |
395 | super();\r | |
396 | this.omt = inOmt;\r | |
397 | this.msa = omt.getXmlMsa();\r | |
398 | init(msa.getBootModes());\r | |
399 | this.setVisible(true);\r | |
400 | }\r | |
401 | \r | |
402 | \r | |
403 | /**\r | |
404 | Disable all components when the mode is view\r | |
405 | \r | |
406 | @param isView true - The view mode; false - The non-view mode\r | |
407 | \r | |
408 | **/\r | |
409 | public void setViewMode(boolean isView) {\r | |
410 | if (isView) {\r | |
411 | this.jComboBoxBootModeName.setEnabled(!isView);\r | |
412 | this.jComboBoxUsage.setEnabled(!isView);\r | |
413 | }\r | |
414 | }\r | |
415 | \r | |
416 | /**\r | |
417 | This method initializes jContentPane\r | |
418 | \r | |
419 | @return javax.swing.JPanel jContentPane\r | |
420 | \r | |
421 | **/\r | |
422 | private JPanel getJContentPane() {\r | |
423 | if (jContentPane == null) {\r | |
424 | jLabelArch = new JLabel();\r | |
425 | jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));\r | |
426 | jLabelArch.setText("Arch");\r | |
427 | jLabelFeatureFlag = new JLabel();\r | |
428 | jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));\r | |
429 | jLabelFeatureFlag.setText("Feature Flag");\r | |
430 | jLabelUsage = new JLabel();\r | |
431 | jLabelUsage.setText("Usage");\r | |
432 | jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));\r | |
433 | jLabelBootModeName = new JLabel();\r | |
434 | jLabelBootModeName.setText("Boot Mode Name");\r | |
435 | jLabelBootModeName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));\r | |
436 | jLabelHelpText = new JLabel();\r | |
437 | jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));\r | |
438 | jLabelHelpText.setText("Help Text");\r | |
439 | \r | |
440 | jContentPane = new JPanel();\r | |
441 | jContentPane.setLayout(null);\r | |
442 | jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));\r | |
443 | \r | |
444 | jContentPane.add(jLabelBootModeName, null);\r | |
445 | jContentPane.add(getJComboBoxBootModeName(), null);\r | |
446 | jContentPane.add(jLabelUsage, null);\r | |
447 | jContentPane.add(getJComboBoxUsage(), null);\r | |
448 | jStarLabel1 = new StarLabel();\r | |
449 | jStarLabel1.setLocation(new java.awt.Point(0, 10));\r | |
450 | jStarLabel2 = new StarLabel();\r | |
451 | jStarLabel2.setLocation(new java.awt.Point(0, 35));\r | |
452 | \r | |
453 | jContentPane.add(jStarLabel1, null);\r | |
454 | jContentPane.add(jStarLabel2, null);\r | |
455 | jContentPane.add(jLabelFeatureFlag, null);\r | |
456 | jContentPane.add(getJTextFieldFeatureFlag(), null);\r | |
457 | jContentPane.add(jLabelArch, null);\r | |
458 | \r | |
459 | jContentPane.add(getJComboBoxList(), null);\r | |
460 | jContentPane.add(getJButtonAdd(), null);\r | |
461 | jContentPane.add(getJButtonRemove(), null);\r | |
462 | jContentPane.add(getJButtonUpdate(), null);\r | |
463 | jContentPane.add(getJScrollPaneList(), null);\r | |
464 | jContentPane.add(getJScrollPaneArch(), null);\r | |
465 | jContentPane.add(jLabelHelpText, null);\r | |
466 | jContentPane.add(getJTextFieldHelpText(), null);\r | |
467 | }\r | |
468 | return jContentPane;\r | |
469 | }\r | |
470 | \r | |
471 | /**\r | |
472 | This method initializes BootModeName groups and Usage type\r | |
473 | \r | |
474 | **/\r | |
475 | private void initFrame() {\r | |
476 | Tools.generateComboBoxByVector(jComboBoxBootModeName, ed.getVBootModeNames());\r | |
477 | Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVPpiUsage());\r | |
478 | \r | |
479 | this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());\r | |
480 | }\r | |
481 | \r | |
482 | /* (non-Javadoc)\r | |
483 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r | |
484 | *\r | |
485 | * Override actionPerformed to listen all actions\r | |
486 | * \r | |
487 | */\r | |
488 | public void actionPerformed(ActionEvent arg0) {\r | |
489 | if (arg0.getSource() == jButtonAdd) {\r | |
490 | if (!checkAdd()) {\r | |
491 | return;\r | |
492 | }\r | |
493 | addToList();\r | |
494 | }\r | |
495 | if (arg0.getSource() == jButtonRemove) {\r | |
496 | removeFromList();\r | |
497 | }\r | |
498 | if (arg0.getSource() == jButtonUpdate) {\r | |
499 | if (!checkAdd()) {\r | |
500 | return;\r | |
501 | }\r | |
502 | updateForList();\r | |
503 | }\r | |
504 | }\r | |
505 | \r | |
506 | /**\r | |
507 | Data validation for all fields\r | |
508 | \r | |
509 | @retval true - All datas are valid\r | |
510 | @retval false - At least one data is invalid\r | |
511 | \r | |
512 | **/\r | |
513 | public boolean checkAdd() {\r | |
514 | //\r | |
515 | // Check if all fields have correct data types \r | |
516 | //\r | |
517 | \r | |
518 | //\r | |
519 | // Check FeatureFlag\r | |
520 | //\r | |
521 | if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {\r | |
522 | if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {\r | |
523 | Log.err("Incorrect data type for Feature Flag");\r | |
524 | return false;\r | |
525 | }\r | |
526 | }\r | |
527 | \r | |
528 | return true;\r | |
529 | }\r | |
530 | \r | |
531 | /**\r | |
532 | Save all components of Mbd Header\r | |
533 | if exists bootModes, set the value directly\r | |
534 | if not exists bootModes, new an instance first\r | |
535 | \r | |
536 | **/\r | |
537 | public void save() {\r | |
538 | try {\r | |
539 | int count = this.vid.size();\r | |
540 | \r | |
541 | this.bootModes = BootModes.Factory.newInstance();\r | |
542 | if (count > 0) {\r | |
543 | for (int index = 0; index < count; index++) {\r | |
544 | BootMode p = BootMode.Factory.newInstance();\r | |
545 | if (!isEmpty(vid.getBootModes(index).getName())) {\r | |
546 | p.setBootModeName(BootModeNames.Enum.forString(vid.getBootModes(index).getName()));\r | |
547 | }\r | |
548 | if (!isEmpty(vid.getBootModes(index).getUsage())) {\r | |
549 | p.setUsage(BootModeUsage.Enum.forString(vid.getBootModes(index).getUsage()));\r | |
550 | }\r | |
551 | if (!isEmpty(vid.getBootModes(index).getFeatureFlag())) {\r | |
552 | p.setFeatureFlag(vid.getBootModes(index).getFeatureFlag());\r | |
553 | }\r | |
554 | if (vid.getBootModes(index).getSupArchList() != null && vid.getBootModes(index).getSupArchList().size() > 0) {\r | |
555 | p.setSupArchList(vid.getBootModes(index).getSupArchList());\r | |
556 | }\r | |
557 | if (!isEmpty(vid.getBootModes(index).getHelp())) {\r | |
558 | p.setHelpText(vid.getBootModes(index).getHelp());\r | |
559 | }\r | |
560 | this.bootModes.addNewBootMode();\r | |
561 | this.bootModes.setBootModeArray(bootModes.getBootModeList().size() - 1, p);\r | |
562 | }\r | |
563 | }\r | |
564 | \r | |
565 | this.msa.setBootModes(bootModes);\r | |
566 | this.omt.setSaved(false);\r | |
567 | } catch (Exception e) {\r | |
568 | Log.err("Update Boot Modes", e.getMessage());\r | |
569 | }\r | |
570 | }\r | |
571 | \r | |
572 | /* (non-Javadoc)\r | |
573 | * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)\r | |
574 | * \r | |
575 | * Override componentResized to resize all components when frame's size is changed\r | |
576 | */\r | |
577 | public void componentResized(ComponentEvent arg0) {\r | |
578 | int intCurrentWidth = this.getJContentPane().getWidth();\r | |
579 | int intCurrentHeight = this.getJContentPane().getHeight();\r | |
580 | int intPreferredWidth = this.getJContentPane().getPreferredSize().width;\r | |
581 | int intPreferredHeight = this.getJContentPane().getPreferredSize().height;\r | |
582 | \r | |
583 | resizeComponentWidth(jComboBoxBootModeName, intCurrentWidth, intPreferredWidth);\r | |
584 | resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);\r | |
585 | resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);\r | |
586 | resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);\r | |
587 | resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);\r | |
588 | \r | |
589 | resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);\r | |
590 | resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);\r | |
591 | \r | |
592 | relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);\r | |
593 | relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);\r | |
594 | relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);\r | |
595 | }\r | |
596 | \r | |
597 | private BootModesIdentification getCurrentBootModes() {\r | |
598 | String arg0 = this.jComboBoxBootModeName.getSelectedItem().toString();\r | |
599 | \r | |
600 | String arg1 = this.jComboBoxUsage.getSelectedItem().toString();\r | |
601 | \r | |
602 | String arg2 = this.jTextFieldFeatureFlag.getText();\r | |
603 | Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();\r | |
604 | String arg4 = this.jTextFieldHelpText.getText();\r | |
605 | id = new BootModesIdentification(arg0, arg1, arg2, arg3, arg4);\r | |
606 | return id;\r | |
607 | }\r | |
608 | \r | |
609 | /**\r | |
610 | Add current item to Vector\r | |
611 | \r | |
612 | **/\r | |
613 | private void addToList() {\r | |
614 | intSelectedItemId = vid.size();\r | |
615 | \r | |
616 | vid.addBootModes(getCurrentBootModes());\r | |
617 | \r | |
618 | jComboBoxList.addItem(id.getName());\r | |
619 | jComboBoxList.setSelectedItem(id.getName());\r | |
620 | \r | |
621 | //\r | |
622 | // Reset select item index\r | |
623 | //\r | |
624 | intSelectedItemId = vid.size();\r | |
625 | \r | |
626 | //\r | |
627 | // Reload all fields of selected item\r | |
628 | //\r | |
629 | reloadFromList();\r | |
630 | \r | |
631 | // \r | |
632 | // Save to memory\r | |
633 | //\r | |
634 | save();\r | |
635 | }\r | |
636 | \r | |
637 | /**\r | |
638 | Remove current item from Vector\r | |
639 | \r | |
640 | **/\r | |
641 | private void removeFromList() {\r | |
642 | //\r | |
643 | // Check if exist items\r | |
644 | //\r | |
645 | if (this.vid.size() < 1) {\r | |
646 | return;\r | |
647 | }\r | |
648 | \r | |
649 | int intTempIndex = intSelectedItemId;\r | |
650 | \r | |
651 | jComboBoxList.removeItemAt(intSelectedItemId);\r | |
652 | \r | |
653 | vid.removeBootModes(intTempIndex);\r | |
654 | \r | |
655 | //\r | |
656 | // Reload all fields of selected item\r | |
657 | //\r | |
658 | reloadFromList();\r | |
659 | \r | |
660 | // \r | |
661 | // Save to memory\r | |
662 | //\r | |
663 | save();\r | |
664 | }\r | |
665 | \r | |
666 | /**\r | |
667 | Update current item of Vector\r | |
668 | \r | |
669 | **/\r | |
670 | private void updateForList() {\r | |
671 | //\r | |
672 | // Check if exist items\r | |
673 | //\r | |
674 | if (this.vid.size() < 1) {\r | |
675 | return;\r | |
676 | }\r | |
677 | \r | |
678 | //\r | |
679 | // Backup selected item index\r | |
680 | //\r | |
681 | int intTempIndex = intSelectedItemId;\r | |
682 | \r | |
683 | vid.updateBootModes(getCurrentBootModes(), intTempIndex);\r | |
684 | \r | |
685 | jComboBoxList.removeAllItems();\r | |
686 | for (int index = 0; index < vid.size(); index++) {\r | |
687 | jComboBoxList.addItem(vid.getBootModes(index).getName());\r | |
688 | }\r | |
689 | \r | |
690 | //\r | |
691 | // Restore selected item index\r | |
692 | //\r | |
693 | intSelectedItemId = intTempIndex;\r | |
694 | \r | |
695 | //\r | |
696 | // Reset select item index\r | |
697 | //\r | |
698 | jComboBoxList.setSelectedIndex(intSelectedItemId);\r | |
699 | \r | |
700 | //\r | |
701 | // Reload all fields of selected item\r | |
702 | //\r | |
703 | reloadFromList();\r | |
704 | \r | |
705 | // \r | |
706 | // Save to memory\r | |
707 | //\r | |
708 | save();\r | |
709 | }\r | |
710 | \r | |
711 | /**\r | |
712 | Refresh all fields' values of selected item of Vector\r | |
713 | \r | |
714 | **/\r | |
715 | private void reloadFromList() {\r | |
716 | if (vid.size() > 0) {\r | |
717 | //\r | |
718 | // Get selected item index\r | |
719 | //\r | |
720 | intSelectedItemId = jComboBoxList.getSelectedIndex();\r | |
721 | \r | |
722 | this.jComboBoxBootModeName.setSelectedItem(vid.getBootModes(intSelectedItemId).getName());\r | |
723 | this.jComboBoxUsage.setSelectedItem(vid.getBootModes(intSelectedItemId).getUsage());\r | |
724 | this.jTextFieldHelpText.setText(vid.getBootModes(intSelectedItemId).getHelp());\r | |
725 | \r | |
726 | jTextFieldFeatureFlag.setText(vid.getBootModes(intSelectedItemId).getFeatureFlag());\r | |
727 | iCheckBoxListArch.setAllItemsUnchecked();\r | |
728 | iCheckBoxListArch.initCheckedItem(true, vid.getBootModes(intSelectedItemId).getSupArchList());\r | |
729 | \r | |
730 | } else {\r | |
731 | }\r | |
732 | \r | |
733 | reloadListArea();\r | |
734 | }\r | |
735 | \r | |
736 | /**\r | |
737 | Update list area pane via the elements of Vector\r | |
738 | \r | |
739 | **/\r | |
740 | private void reloadListArea() {\r | |
741 | String strListItem = "";\r | |
742 | for (int index = 0; index < vid.size(); index++) {\r | |
743 | strListItem = strListItem + vid.getBootModes(index).getName() + DataType.UNIX_LINE_SEPARATOR;\r | |
744 | }\r | |
745 | this.jTextAreaList.setText(strListItem);\r | |
746 | }\r | |
747 | \r | |
748 | /* (non-Javadoc)\r | |
749 | * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)\r | |
750 | *\r | |
751 | * Reflesh the frame when selected item changed\r | |
752 | * \r | |
753 | */\r | |
754 | public void itemStateChanged(ItemEvent arg0) {\r | |
755 | if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {\r | |
756 | reloadFromList();\r | |
757 | }\r | |
758 | }\r | |
759 | }\r |