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