]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | <<The file is used to create, update BootModes of MSA file>>\r | |
3 | \r | |
4 | <<The BootModesDlg is called to add or edit a Module's Boot Modes definitions.>>\r | |
5 | \r | |
6 | Copyright (c) 2006, Intel Corporation\r | |
7 | All rights reserved. This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | Package Name: Tools\r | |
16 | Module Name: FrameworkWizard\r | |
17 | \r | |
18 | **/\r | |
19 | \r | |
20 | package org.tianocore.frameworkwizard.module.ui.dialog;\r | |
21 | \r | |
22 | import java.awt.event.ActionEvent;\r | |
23 | import java.util.Vector;\r | |
24 | \r | |
25 | import javax.swing.JButton;\r | |
26 | import javax.swing.JComboBox;\r | |
27 | import javax.swing.JLabel;\r | |
28 | import javax.swing.JPanel;\r | |
29 | import javax.swing.JScrollPane;\r | |
30 | import javax.swing.JTextField;\r | |
31 | import javax.swing.JTextArea;\r | |
32 | \r | |
33 | import org.tianocore.frameworkwizard.common.DataType;\r | |
34 | import org.tianocore.frameworkwizard.common.DataValidation;\r | |
35 | import org.tianocore.frameworkwizard.common.EnumerationData;\r | |
36 | import org.tianocore.frameworkwizard.common.Log;\r | |
37 | import org.tianocore.frameworkwizard.common.Tools;\r | |
38 | import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;\r | |
39 | import org.tianocore.frameworkwizard.common.ui.IDialog;\r | |
40 | import org.tianocore.frameworkwizard.common.ui.IFrame;\r | |
41 | import org.tianocore.frameworkwizard.common.ui.StarLabel;\r | |
42 | import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r | |
43 | import org.tianocore.frameworkwizard.module.Identifications.BootModes.BootModesIdentification;\r | |
44 | import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r | |
45 | \r | |
46 | /**\r | |
47 | * The class is used to create, update BootModes of MSA/MBD file\r | |
48 | * \r | |
49 | * It extends IDialog\r | |
50 | * \r | |
51 | */\r | |
52 | public class BootModesDlg extends IDialog {\r | |
53 | \r | |
54 | // /\r | |
55 | // / Define class Serial Version UID\r | |
56 | // /\r | |
57 | private static final long serialVersionUID = -3888558623432442561L;\r | |
58 | \r | |
59 | //\r | |
60 | // Define class members\r | |
61 | //\r | |
62 | private JPanel jContentPane = null;\r | |
63 | \r | |
64 | private JLabel jLabelBootModeName = null;\r | |
65 | \r | |
66 | private JComboBox jComboBoxBootModeName = null;\r | |
67 | \r | |
68 | private JLabel jLabelUsage = null;\r | |
69 | \r | |
70 | private JComboBox jComboBoxUsage = null;\r | |
71 | \r | |
72 | private StarLabel jStarLabel1 = null;\r | |
73 | \r | |
74 | private StarLabel jStarLabel2 = null;\r | |
75 | \r | |
76 | private JLabel jLabelFeatureFlag = null;\r | |
77 | \r | |
78 | private JTextField jTextFieldFeatureFlag = null;\r | |
79 | \r | |
80 | private JLabel jLabelArch = null;\r | |
81 | \r | |
82 | private JScrollPane jScrollPane = null;\r | |
83 | \r | |
84 | private JLabel jLabelHelpText = null;\r | |
85 | \r | |
86 | private JTextArea jTextAreaHelpText = null;\r | |
87 | \r | |
88 | private JScrollPane jScrollPaneHelpText = null;\r | |
89 | \r | |
90 | private ArchCheckBox jArchCheckBox = null;\r | |
91 | \r | |
92 | private JButton jButtonOk = null;\r | |
93 | \r | |
94 | private JButton jButtonCancel = null;\r | |
95 | \r | |
96 | //\r | |
97 | // Not used by UI\r | |
98 | //\r | |
99 | private BootModesIdentification id = null;\r | |
100 | \r | |
101 | private EnumerationData ed = new EnumerationData();\r | |
102 | \r | |
103 | private WorkspaceTools wt = new WorkspaceTools();\r | |
104 | \r | |
105 | /**\r | |
106 | * This method initializes jComboBoxBootModeName\r | |
107 | * \r | |
108 | * @return javax.swing.JComboBox jComboBoxBootModeName\r | |
109 | * \r | |
110 | */\r | |
111 | private JComboBox getJComboBoxBootModeName() {\r | |
112 | if (jComboBoxBootModeName == null) {\r | |
113 | jComboBoxBootModeName = new JComboBox();\r | |
114 | jComboBoxBootModeName.setBounds(new java.awt.Rectangle(168, 12, 320, 20));\r | |
115 | jComboBoxBootModeName.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
116 | jComboBoxBootModeName\r | |
117 | .setToolTipText("<html><table>"\r | |
118 | + "<tr><td>FULL</td><td>Boot with full configuration</td></tr>"\r | |
119 | + "<tr><td>MINIMAL</td><td>Boot with minimal configuration</td></tr>"\r | |
120 | + "<tr><td>NO_CHANGE</td><td>Boot assuming no configuration changes</td></tr>"\r | |
121 | + "<tr><td>DIAGNOSTICS</td><td>Boot with full configuration plus diagnostics</td></tr>"\r | |
122 | + "<tr><td>DEFAULT</td><td>Boot with default settings</td></tr>"\r | |
123 | + "<tr><td>BOOT_ON_S#_RESUME</td><td>where # is 2, 3, 4 or 5</td></tr>"\r | |
124 | + "<tr><td>FLASH_UPDATE</td><td>Boot on flash update</td></tr>"\r | |
125 | + "<tr><td>RECOVERY</td><td>Boot in recovery mode</td></tr>"\r | |
126 | + "</table></html>");\r | |
127 | }\r | |
128 | return jComboBoxBootModeName;\r | |
129 | }\r | |
130 | \r | |
131 | /**\r | |
132 | * This method initializes jComboBoxUsage\r | |
133 | * \r | |
134 | * @return javax.swing.JComboBox jComboBoxUsage\r | |
135 | * \r | |
136 | */\r | |
137 | private JComboBox getJComboBoxUsage() {\r | |
138 | if (jComboBoxUsage == null) {\r | |
139 | jComboBoxUsage = new JComboBox();\r | |
140 | jComboBoxUsage.setBounds(new java.awt.Rectangle(168, 37, 320, 20));\r | |
141 | jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
142 | jComboBoxUsage\r | |
143 | .setToolTipText("<html><table>"\r | |
144 | + "<tr><td>ALWAYS_CONSUMED</td><td>Indicates Supports the specified boot mode</td></tr>"\r | |
145 | + "<tr><td>SOMETIMES_CONSUMED</td><td>Indicates Supports the specified boot mode on some execution paths</td></tr>"\r | |
146 | + "<tr><td>ALWAYS_PRODUCED</td><td>Always changes the boot mode</td></tr>"\r | |
147 | + "<tr><td>SOMETIMES_PRODUCED</td><td>Change the boot mode sometimes</td></tr>"\r | |
148 | + "</table></html>");\r | |
149 | }\r | |
150 | return jComboBoxUsage;\r | |
151 | }\r | |
152 | \r | |
153 | /**\r | |
154 | * This method initializes jTextFieldFeatureFlag\r | |
155 | * \r | |
156 | * @return javax.swing.JTextField\r | |
157 | */\r | |
158 | private JTextField getJTextFieldFeatureFlag() {\r | |
159 | if (jTextFieldFeatureFlag == null) {\r | |
160 | jTextFieldFeatureFlag = new JTextField();\r | |
161 | jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(168, 132, 320, 20));\r | |
162 | jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
163 | jTextFieldFeatureFlag.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");\r | |
164 | jTextFieldFeatureFlag.setEnabled(false);\r | |
165 | }\r | |
166 | return jTextFieldFeatureFlag;\r | |
167 | }\r | |
168 | \r | |
169 | /**\r | |
170 | * This method initializes jScrollPane\r | |
171 | * \r | |
172 | * @return javax.swing.JScrollPane\r | |
173 | */\r | |
174 | private JScrollPane getJScrollPane() {\r | |
175 | if (jScrollPane == null) {\r | |
176 | jScrollPane = new JScrollPane();\r | |
177 | jScrollPane.setViewportView(getJContentPane());\r | |
178 | }\r | |
179 | return jScrollPane;\r | |
180 | }\r | |
181 | \r | |
182 | /**\r | |
183 | * This method initializes jTextAreaHelpText\r | |
184 | * \r | |
185 | * @return javax.swing.JTextArea\r | |
186 | * \r | |
187 | */\r | |
188 | private JTextArea getJTextAreaHelpText() {\r | |
189 | if (jTextAreaHelpText == null) {\r | |
190 | jTextAreaHelpText = new JTextArea();\r | |
191 | jTextAreaHelpText.setLineWrap(true);\r | |
192 | jTextAreaHelpText.setWrapStyleWord(true);\r | |
193 | }\r | |
194 | return jTextAreaHelpText;\r | |
195 | }\r | |
196 | \r | |
197 | /**\r | |
198 | * This method initializes jScrollPaneHelpText\r | |
199 | * \r | |
200 | * @return javax.swing.JScrollPane\r | |
201 | * \r | |
202 | */\r | |
203 | private JScrollPane getJScrollPaneHelpText() {\r | |
204 | if (jScrollPaneHelpText == null) {\r | |
205 | jScrollPaneHelpText = new JScrollPane();\r | |
206 | jScrollPaneHelpText.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r | |
207 | jScrollPaneHelpText.setSize(new java.awt.Dimension(320, 40));\r | |
208 | jScrollPaneHelpText.setPreferredSize(new java.awt.Dimension(320, 40));\r | |
209 | jScrollPaneHelpText.setLocation(new java.awt.Point(168, 62));\r | |
210 | jScrollPaneHelpText.setViewportView(getJTextAreaHelpText());\r | |
211 | }\r | |
212 | return jScrollPaneHelpText;\r | |
213 | }\r | |
214 | \r | |
215 | /**\r | |
216 | * This method initializes jButtonOk\r | |
217 | * \r | |
218 | * @return javax.swing.JButton\r | |
219 | * \r | |
220 | */\r | |
221 | private JButton getJButtonOk() {\r | |
222 | if (jButtonOk == null) {\r | |
223 | jButtonOk = new JButton();\r | |
224 | jButtonOk.setBounds(new java.awt.Rectangle(290, 162, 90, 20));\r | |
225 | jButtonOk.setText("Ok");\r | |
226 | jButtonOk.addActionListener(this);\r | |
227 | }\r | |
228 | return jButtonOk;\r | |
229 | }\r | |
230 | \r | |
231 | /**\r | |
232 | * This method initializes jButtonCancel\r | |
233 | * \r | |
234 | * @return javax.swing.JButton\r | |
235 | * \r | |
236 | */\r | |
237 | private JButton getJButtonCancel() {\r | |
238 | if (jButtonCancel == null) {\r | |
239 | jButtonCancel = new JButton();\r | |
240 | jButtonCancel.setBounds(new java.awt.Rectangle(390, 162, 90, 20));\r | |
241 | jButtonCancel.setText("Cancel");\r | |
242 | jButtonCancel.addActionListener(this);\r | |
243 | }\r | |
244 | return jButtonCancel;\r | |
245 | }\r | |
246 | \r | |
247 | public static void main(String[] args) {\r | |
248 | }\r | |
249 | \r | |
250 | /**\r | |
251 | * This method initializes this\r | |
252 | * \r | |
253 | */\r | |
254 | private void init() {\r | |
255 | this.setSize(505, 235);\r | |
256 | this.setContentPane(getJScrollPane());\r | |
257 | this.setTitle("Boot Modes");\r | |
258 | initFrame();\r | |
259 | this.setViewMode(false);\r | |
260 | this.centerWindow();\r | |
261 | }\r | |
262 | \r | |
263 | /**\r | |
264 | * This method initializes this Fill values to all fields if these values are\r | |
265 | * not empty\r | |
266 | * \r | |
267 | * @param inBootModesId\r | |
268 | * \r | |
269 | */\r | |
270 | private void init(BootModesIdentification inBootModesId, ModuleIdentification mid) {\r | |
271 | init();\r | |
272 | this.id = inBootModesId;\r | |
273 | \r | |
274 | //\r | |
275 | // Init arch with module's arch\r | |
276 | //\r | |
277 | this.jArchCheckBox.setEnabledItems(wt.getModuleArch(mid));\r | |
278 | \r | |
279 | if (this.id != null) {\r | |
280 | this.jComboBoxBootModeName.setSelectedItem(id.getName());\r | |
281 | this.jComboBoxUsage.setSelectedItem(id.getUsage());\r | |
282 | this.jTextAreaHelpText.setText(id.getHelp());\r | |
283 | this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());\r | |
284 | this.jArchCheckBox.setSelectedItems(id.getSupArchList());\r | |
285 | }\r | |
286 | }\r | |
287 | \r | |
288 | /**\r | |
289 | * This is the override edit constructor\r | |
290 | * \r | |
291 | * @param inBootModesIdentification\r | |
292 | * @param iFrame\r | |
293 | * \r | |
294 | */\r | |
295 | public BootModesDlg(BootModesIdentification inBootModesIdentification, IFrame iFrame, ModuleIdentification mid) {\r | |
296 | super(iFrame, true);\r | |
297 | init(inBootModesIdentification, mid);\r | |
298 | }\r | |
299 | \r | |
300 | /**\r | |
301 | * Disable all components when the mode is view\r | |
302 | * \r | |
303 | * @param isView\r | |
304 | * true - The view mode; false - The non-view mode\r | |
305 | * \r | |
306 | */\r | |
307 | public void setViewMode(boolean isView) {\r | |
308 | if (isView) {\r | |
309 | this.jComboBoxBootModeName.setEnabled(!isView);\r | |
310 | this.jComboBoxUsage.setEnabled(!isView);\r | |
311 | }\r | |
312 | }\r | |
313 | \r | |
314 | /**\r | |
315 | * This method initializes jContentPane\r | |
316 | * \r | |
317 | * @return javax.swing.JPanel jContentPane\r | |
318 | * \r | |
319 | */\r | |
320 | private JPanel getJContentPane() {\r | |
321 | if (jContentPane == null) {\r | |
322 | jStarLabel1 = new StarLabel();\r | |
323 | jStarLabel1.setLocation(new java.awt.Point(2, 12));\r | |
324 | jLabelBootModeName = new JLabel();\r | |
325 | jLabelBootModeName.setText("Boot Mode Name");\r | |
326 | jLabelBootModeName.setBounds(new java.awt.Rectangle(12, 12, 155, 20));\r | |
327 | jStarLabel2 = new StarLabel();\r | |
328 | jStarLabel2.setLocation(new java.awt.Point(2, 37));\r | |
329 | jLabelUsage = new JLabel();\r | |
330 | jLabelUsage.setText("Usage");\r | |
331 | jLabelUsage.setBounds(new java.awt.Rectangle(12, 37, 155, 20));\r | |
332 | jLabelHelpText = new JLabel();\r | |
333 | jLabelHelpText.setBounds(new java.awt.Rectangle(12, 62, 155, 20));\r | |
334 | jLabelHelpText.setText("Help Text");\r | |
335 | jLabelFeatureFlag = new JLabel();\r | |
336 | jLabelFeatureFlag.setBounds(new java.awt.Rectangle(12, 132, 155, 20));\r | |
337 | jLabelFeatureFlag.setText("Feature Flag Expression");\r | |
338 | jLabelFeatureFlag.setEnabled(false);\r | |
339 | jLabelArch = new JLabel();\r | |
340 | jLabelArch.setBounds(new java.awt.Rectangle(12, 107, 155, 20));\r | |
341 | jLabelArch.setText("Supported Archectures");\r | |
342 | jArchCheckBox = new ArchCheckBox();\r | |
343 | jArchCheckBox.setBounds(new java.awt.Rectangle(168, 107, 320, 20));\r | |
344 | jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));\r | |
345 | \r | |
346 | jContentPane = new JPanel();\r | |
347 | jContentPane.setLayout(null);\r | |
348 | jContentPane.setPreferredSize(new java.awt.Dimension(480, 180));\r | |
349 | \r | |
350 | jContentPane.add(jLabelBootModeName, null);\r | |
351 | jContentPane.add(getJComboBoxBootModeName(), null);\r | |
352 | jContentPane.add(jLabelUsage, null);\r | |
353 | jContentPane.add(getJComboBoxUsage(), null);\r | |
354 | \r | |
355 | jContentPane.add(jStarLabel1, null);\r | |
356 | jContentPane.add(jStarLabel2, null);\r | |
357 | jContentPane.add(jLabelFeatureFlag, null);\r | |
358 | jContentPane.add(getJTextFieldFeatureFlag(), null);\r | |
359 | jContentPane.add(jLabelArch, null);\r | |
360 | \r | |
361 | jContentPane.add(jLabelHelpText, null);\r | |
362 | jContentPane.add(getJScrollPaneHelpText(), null);\r | |
363 | jContentPane.add(jArchCheckBox, null);\r | |
364 | jContentPane.add(getJButtonOk(), null);\r | |
365 | jContentPane.add(getJButtonCancel(), null);\r | |
366 | }\r | |
367 | return jContentPane;\r | |
368 | }\r | |
369 | \r | |
370 | /**\r | |
371 | * This method initializes BootModeName groups and Usage type\r | |
372 | * \r | |
373 | */\r | |
374 | private void initFrame() {\r | |
375 | Tools.generateComboBoxByVector(jComboBoxBootModeName, ed.getVBootModeNames());\r | |
376 | Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVPpiUsage());\r | |
377 | }\r | |
378 | \r | |
379 | /*\r | |
380 | * (non-Javadoc)\r | |
381 | * \r | |
382 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r | |
383 | * \r | |
384 | * Override actionPerformed to listen all actions\r | |
385 | * \r | |
386 | */\r | |
387 | public void actionPerformed(ActionEvent arg0) {\r | |
388 | if (arg0.getSource() == jButtonOk) {\r | |
389 | if (checkAdd()) {\r | |
390 | getCurrentBootModes();\r | |
391 | this.returnType = DataType.RETURN_TYPE_OK;\r | |
392 | this.setVisible(false);\r | |
393 | }\r | |
394 | }\r | |
395 | \r | |
396 | if (arg0.getSource() == jButtonCancel) {\r | |
397 | this.returnType = DataType.RETURN_TYPE_CANCEL;\r | |
398 | this.setVisible(false);\r | |
399 | }\r | |
400 | }\r | |
401 | \r | |
402 | /**\r | |
403 | * Data validation for all fields\r | |
404 | * \r | |
405 | * @retval true - All datas are valid\r | |
406 | * @retval false - At least one data is invalid\r | |
407 | * \r | |
408 | */\r | |
409 | public boolean checkAdd() {\r | |
410 | //\r | |
411 | // Check if all fields have correct data types\r | |
412 | //\r | |
413 | \r | |
414 | //\r | |
415 | // Check FeatureFlag\r | |
416 | //\r | |
417 | if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {\r | |
418 | if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {\r | |
419 | Log.wrn("Update Boot Modes", "Incorrect data type for Feature Flag");\r | |
420 | return false;\r | |
421 | }\r | |
422 | }\r | |
423 | \r | |
424 | return true;\r | |
425 | }\r | |
426 | \r | |
427 | private BootModesIdentification getCurrentBootModes() {\r | |
428 | String arg0 = this.jComboBoxBootModeName.getSelectedItem().toString();\r | |
429 | String arg1 = this.jComboBoxUsage.getSelectedItem().toString();\r | |
430 | \r | |
431 | String arg2 = this.jTextFieldFeatureFlag.getText();\r | |
432 | Vector<String> arg3 = this.jArchCheckBox.getSelectedItemsVector();\r | |
433 | String arg4 = this.jTextAreaHelpText.getText();\r | |
434 | id = new BootModesIdentification(arg0, arg1, arg2, arg3, arg4);\r | |
435 | return id;\r | |
436 | }\r | |
437 | \r | |
438 | public BootModesIdentification getId() {\r | |
439 | return id;\r | |
440 | }\r | |
441 | \r | |
442 | public void setId(BootModesIdentification id) {\r | |
443 | this.id = id;\r | |
444 | }\r | |
445 | }\r |