]>
Commit | Line | Data |
---|---|---|
06a19cee | 1 | /** @file\r |
5b38b75b | 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 | |
06a19cee | 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 | |
5b38b75b | 15 | Package Name: Tools\r |
16 | Module Name: FrameworkWizard\r | |
17 | \r | |
06a19cee | 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 | |
5262e237 | 31 | import javax.swing.JTextArea;\r |
06a19cee | 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 | |
e08433ef | 42 | import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r |
06a19cee | 43 | import org.tianocore.frameworkwizard.module.Identifications.BootModes.BootModesIdentification;\r |
e08433ef | 44 | import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r |
06a19cee | 45 | \r |
46 | /**\r | |
9e857952 | 47 | * The class is used to create, update BootModes of MSA/MBD file\r |
48 | * \r | |
49 | * It extends IDialog\r | |
5b38b75b | 50 | * \r |
51 | */\r | |
06a19cee | 52 | public class BootModesDlg extends IDialog {\r |
53 | \r | |
a929458e | 54 | // /\r |
55 | // / Define class Serial Version UID\r | |
56 | // /\r | |
57 | private static final long serialVersionUID = -3888558623432442561L;\r | |
06a19cee | 58 | \r |
a929458e | 59 | //\r |
60 | // Define class members\r | |
61 | //\r | |
62 | private JPanel jContentPane = null;\r | |
9e857952 | 63 | \r |
a929458e | 64 | private JLabel jLabelBootModeName = null;\r |
06a19cee | 65 | \r |
a929458e | 66 | private JComboBox jComboBoxBootModeName = null;\r |
06a19cee | 67 | \r |
a929458e | 68 | private JLabel jLabelUsage = null;\r |
06a19cee | 69 | \r |
a929458e | 70 | private JComboBox jComboBoxUsage = null;\r |
06a19cee | 71 | \r |
a929458e | 72 | private StarLabel jStarLabel1 = null;\r |
06a19cee | 73 | \r |
a929458e | 74 | private StarLabel jStarLabel2 = null;\r |
06a19cee | 75 | \r |
a929458e | 76 | private JLabel jLabelFeatureFlag = null;\r |
06a19cee | 77 | \r |
a929458e | 78 | private JTextField jTextFieldFeatureFlag = null;\r |
06a19cee | 79 | \r |
a929458e | 80 | private JLabel jLabelArch = null;\r |
5262e237 | 81 | \r |
a929458e | 82 | private JScrollPane jScrollPane = null;\r |
06a19cee | 83 | \r |
a929458e | 84 | private JLabel jLabelHelpText = null;\r |
06a19cee | 85 | \r |
a929458e | 86 | private JTextArea jTextAreaHelpText = null;\r |
06a19cee | 87 | \r |
a929458e | 88 | private JScrollPane jScrollPaneHelpText = null;\r |
06a19cee | 89 | \r |
a929458e | 90 | private ArchCheckBox jArchCheckBox = null;\r |
06a19cee | 91 | \r |
a929458e | 92 | private JButton jButtonOk = null;\r |
06a19cee | 93 | \r |
a929458e | 94 | private JButton jButtonCancel = null;\r |
06a19cee | 95 | \r |
a929458e | 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 | |
e08433ef | 102 | \r |
103 | private WorkspaceTools wt = new WorkspaceTools();\r | |
a929458e | 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 | |
3f62225f | 114 | jComboBoxBootModeName.setBounds(new java.awt.Rectangle(168, 12, 320, 20));\r |
a929458e | 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 | |
06a19cee | 130 | \r |
a929458e | 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 | |
3f62225f | 140 | jComboBoxUsage.setBounds(new java.awt.Rectangle(168, 37, 320, 20));\r |
a929458e | 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 | |
5262e237 | 152 | \r |
a929458e | 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 | |
21b42c66 | 161 | jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(168, 132, 320, 20));\r |
a929458e | 162 | jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));\r |
163 | jTextFieldFeatureFlag.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");\r | |
21b42c66 | 164 | jTextFieldFeatureFlag.setEnabled(false);\r |
a929458e | 165 | }\r |
166 | return jTextFieldFeatureFlag;\r | |
06a19cee | 167 | }\r |
a929458e | 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 | |
06a19cee | 180 | }\r |
a929458e | 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 | |
06a19cee | 195 | }\r |
a929458e | 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 | |
3f62225f | 209 | jScrollPaneHelpText.setLocation(new java.awt.Point(168, 62));\r |
a929458e | 210 | jScrollPaneHelpText.setViewportView(getJTextAreaHelpText());\r |
211 | }\r | |
212 | return jScrollPaneHelpText;\r | |
06a19cee | 213 | }\r |
a929458e | 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 | |
3f62225f | 224 | jButtonOk.setBounds(new java.awt.Rectangle(290, 162, 90, 20));\r |
a929458e | 225 | jButtonOk.setText("Ok");\r |
226 | jButtonOk.addActionListener(this);\r | |
227 | }\r | |
228 | return jButtonOk;\r | |
06a19cee | 229 | }\r |
a929458e | 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 | |
3f62225f | 240 | jButtonCancel.setBounds(new java.awt.Rectangle(390, 162, 90, 20));\r |
a929458e | 241 | jButtonCancel.setText("Cancel");\r |
242 | jButtonCancel.addActionListener(this);\r | |
243 | }\r | |
244 | return jButtonCancel;\r | |
06a19cee | 245 | }\r |
a929458e | 246 | \r |
247 | public static void main(String[] args) {\r | |
06a19cee | 248 | }\r |
a929458e | 249 | \r |
250 | /**\r | |
251 | * This method initializes this\r | |
252 | * \r | |
253 | */\r | |
254 | private void init() {\r | |
3f62225f | 255 | this.setSize(505, 235);\r |
a929458e | 256 | this.setContentPane(getJScrollPane());\r |
257 | this.setTitle("Boot Modes");\r | |
258 | initFrame();\r | |
259 | this.setViewMode(false);\r | |
260 | this.centerWindow();\r | |
06a19cee | 261 | }\r |
a929458e | 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 | |
e08433ef | 270 | private void init(BootModesIdentification inBootModesId, ModuleIdentification mid) {\r |
a929458e | 271 | init();\r |
272 | this.id = inBootModesId;\r | |
e08433ef | 273 | \r |
274 | //\r | |
275 | // Init arch with module's arch\r | |
276 | //\r | |
277 | this.jArchCheckBox.setEnabledItems(wt.getModuleArch(mid));\r | |
278 | \r | |
a929458e | 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 | |
06a19cee | 286 | }\r |
a929458e | 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 | |
e08433ef | 295 | public BootModesDlg(BootModesIdentification inBootModesIdentification, IFrame iFrame, ModuleIdentification mid) {\r |
a929458e | 296 | super(iFrame, true);\r |
e08433ef | 297 | init(inBootModesIdentification, mid);\r |
06a19cee | 298 | }\r |
a929458e | 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 | |
06a19cee | 312 | }\r |
a929458e | 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 | |
3f62225f | 323 | jStarLabel1.setLocation(new java.awt.Point(2, 12));\r |
a929458e | 324 | jLabelBootModeName = new JLabel();\r |
325 | jLabelBootModeName.setText("Boot Mode Name");\r | |
3f62225f | 326 | jLabelBootModeName.setBounds(new java.awt.Rectangle(12, 12, 155, 20));\r |
a929458e | 327 | jStarLabel2 = new StarLabel();\r |
3f62225f | 328 | jStarLabel2.setLocation(new java.awt.Point(2, 37));\r |
a929458e | 329 | jLabelUsage = new JLabel();\r |
330 | jLabelUsage.setText("Usage");\r | |
3f62225f | 331 | jLabelUsage.setBounds(new java.awt.Rectangle(12, 37, 155, 20));\r |
a929458e | 332 | jLabelHelpText = new JLabel();\r |
3f62225f | 333 | jLabelHelpText.setBounds(new java.awt.Rectangle(12, 62, 155, 20));\r |
a929458e | 334 | jLabelHelpText.setText("Help Text");\r |
335 | jLabelFeatureFlag = new JLabel();\r | |
21b42c66 | 336 | jLabelFeatureFlag.setBounds(new java.awt.Rectangle(12, 132, 155, 20));\r |
a929458e | 337 | jLabelFeatureFlag.setText("Feature Flag Expression");\r |
21b42c66 | 338 | jLabelFeatureFlag.setEnabled(false);\r |
a929458e | 339 | jLabelArch = new JLabel();\r |
21b42c66 | 340 | jLabelArch.setBounds(new java.awt.Rectangle(12, 107, 155, 20));\r |
a929458e | 341 | jLabelArch.setText("Supported Archectures");\r |
342 | jArchCheckBox = new ArchCheckBox();\r | |
21b42c66 | 343 | jArchCheckBox.setBounds(new java.awt.Rectangle(168, 107, 320, 20));\r |
a929458e | 344 | jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));\r |
345 | \r | |
346 | jContentPane = new JPanel();\r | |
347 | jContentPane.setLayout(null);\r | |
3f62225f | 348 | jContentPane.setPreferredSize(new java.awt.Dimension(480, 180));\r |
a929458e | 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 | |
06a19cee | 368 | }\r |
369 | \r | |
a929458e | 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 | |
06a19cee | 377 | }\r |
378 | \r | |
a929458e | 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 | |
06a19cee | 436 | }\r |
437 | \r | |
a929458e | 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 | |
06a19cee | 445 | }\r |