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