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