2 <<The file is used to create, update BootModes of MSA file>>
4 <<The BootModesDlg is called to add or edit a Module's Boot Modes definitions.>>
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 Module Name: FrameworkWizard
20 package org
.tianocore
.frameworkwizard
.module
.ui
.dialog
;
22 import java
.awt
.event
.ActionEvent
;
23 import java
.util
.Vector
;
25 import javax
.swing
.JButton
;
26 import javax
.swing
.JComboBox
;
27 import javax
.swing
.JLabel
;
28 import javax
.swing
.JPanel
;
29 import javax
.swing
.JScrollPane
;
30 import javax
.swing
.JTextField
;
31 import javax
.swing
.JTextArea
;
33 import org
.tianocore
.frameworkwizard
.common
.DataType
;
34 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
35 import org
.tianocore
.frameworkwizard
.common
.EnumerationData
;
36 import org
.tianocore
.frameworkwizard
.common
.Log
;
37 import org
.tianocore
.frameworkwizard
.common
.Tools
;
38 import org
.tianocore
.frameworkwizard
.common
.ui
.ArchCheckBox
;
39 import org
.tianocore
.frameworkwizard
.common
.ui
.IDialog
;
40 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
41 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
42 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
43 import org
.tianocore
.frameworkwizard
.module
.Identifications
.BootModes
.BootModesIdentification
;
44 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
47 * The class is used to create, update BootModes of MSA/MBD file
52 public class BootModesDlg
extends IDialog
{
55 // / Define class Serial Version UID
57 private static final long serialVersionUID
= -3888558623432442561L;
60 // Define class members
62 private JPanel jContentPane
= null;
64 private JLabel jLabelBootModeName
= null;
66 private JComboBox jComboBoxBootModeName
= null;
68 private JLabel jLabelUsage
= null;
70 private JComboBox jComboBoxUsage
= null;
72 private StarLabel jStarLabel1
= null;
74 private StarLabel jStarLabel2
= null;
76 private JLabel jLabelFeatureFlag
= null;
78 private JTextField jTextFieldFeatureFlag
= null;
80 private JLabel jLabelArch
= null;
82 private JScrollPane jScrollPane
= null;
84 private JLabel jLabelHelpText
= null;
86 private JTextArea jTextAreaHelpText
= null;
88 private JScrollPane jScrollPaneHelpText
= null;
90 private ArchCheckBox jArchCheckBox
= null;
92 private JButton jButtonOk
= null;
94 private JButton jButtonCancel
= null;
99 private BootModesIdentification id
= null;
101 private EnumerationData ed
= new EnumerationData();
103 private WorkspaceTools wt
= new WorkspaceTools();
106 * This method initializes jComboBoxBootModeName
108 * @return javax.swing.JComboBox jComboBoxBootModeName
111 private JComboBox
getJComboBoxBootModeName() {
112 if (jComboBoxBootModeName
== null) {
113 jComboBoxBootModeName
= new JComboBox();
114 jComboBoxBootModeName
.setBounds(new java
.awt
.Rectangle(168, 12, 320, 20));
115 jComboBoxBootModeName
.setPreferredSize(new java
.awt
.Dimension(320, 20));
116 jComboBoxBootModeName
117 .setToolTipText("<html><table>"
118 + "<tr><td>FULL</td><td>Boot with full configuration</td></tr>"
119 + "<tr><td>MINIMAL</td><td>Boot with minimal configuration</td></tr>"
120 + "<tr><td>NO_CHANGE</td><td>Boot assuming no configuration changes</td></tr>"
121 + "<tr><td>DIAGNOSTICS</td><td>Boot with full configuration plus diagnostics</td></tr>"
122 + "<tr><td>DEFAULT</td><td>Boot with default settings</td></tr>"
123 + "<tr><td>BOOT_ON_S#_RESUME</td><td>where # is 2, 3, 4 or 5</td></tr>"
124 + "<tr><td>FLASH_UPDATE</td><td>Boot on flash update</td></tr>"
125 + "<tr><td>RECOVERY</td><td>Boot in recovery mode</td></tr>"
126 + "</table></html>");
128 return jComboBoxBootModeName
;
132 * This method initializes jComboBoxUsage
134 * @return javax.swing.JComboBox jComboBoxUsage
137 private JComboBox
getJComboBoxUsage() {
138 if (jComboBoxUsage
== null) {
139 jComboBoxUsage
= new JComboBox();
140 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(168, 37, 320, 20));
141 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
143 .setToolTipText("<html><table>"
144 + "<tr><td>ALWAYS_CONSUMED</td><td>Indicates Supports the specified boot mode</td></tr>"
145 + "<tr><td>SOMETIMES_CONSUMED</td><td>Indicates Supports the specified boot mode on some execution paths</td></tr>"
146 + "<tr><td>ALWAYS_PRODUCED</td><td>Always changes the boot mode</td></tr>"
147 + "<tr><td>SOMETIMES_PRODUCED</td><td>Change the boot mode sometimes</td></tr>"
148 + "</table></html>");
150 return jComboBoxUsage
;
154 * This method initializes jTextFieldFeatureFlag
156 * @return javax.swing.JTextField
158 private JTextField
getJTextFieldFeatureFlag() {
159 if (jTextFieldFeatureFlag
== null) {
160 jTextFieldFeatureFlag
= new JTextField();
161 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(168, 132, 320, 20));
162 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
163 jTextFieldFeatureFlag
.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");
164 jTextFieldFeatureFlag
.setEnabled(false);
166 return jTextFieldFeatureFlag
;
170 * This method initializes jScrollPane
172 * @return javax.swing.JScrollPane
174 private JScrollPane
getJScrollPane() {
175 if (jScrollPane
== null) {
176 jScrollPane
= new JScrollPane();
177 jScrollPane
.setViewportView(getJContentPane());
183 * This method initializes jTextAreaHelpText
185 * @return javax.swing.JTextArea
188 private JTextArea
getJTextAreaHelpText() {
189 if (jTextAreaHelpText
== null) {
190 jTextAreaHelpText
= new JTextArea();
191 jTextAreaHelpText
.setLineWrap(true);
192 jTextAreaHelpText
.setWrapStyleWord(true);
194 return jTextAreaHelpText
;
198 * This method initializes jScrollPaneHelpText
200 * @return javax.swing.JScrollPane
203 private JScrollPane
getJScrollPaneHelpText() {
204 if (jScrollPaneHelpText
== null) {
205 jScrollPaneHelpText
= new JScrollPane();
206 jScrollPaneHelpText
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
207 jScrollPaneHelpText
.setSize(new java
.awt
.Dimension(320, 40));
208 jScrollPaneHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 40));
209 jScrollPaneHelpText
.setLocation(new java
.awt
.Point(168, 62));
210 jScrollPaneHelpText
.setViewportView(getJTextAreaHelpText());
212 return jScrollPaneHelpText
;
216 * This method initializes jButtonOk
218 * @return javax.swing.JButton
221 private JButton
getJButtonOk() {
222 if (jButtonOk
== null) {
223 jButtonOk
= new JButton();
224 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 162, 90, 20));
225 jButtonOk
.setText("Ok");
226 jButtonOk
.addActionListener(this);
232 * This method initializes jButtonCancel
234 * @return javax.swing.JButton
237 private JButton
getJButtonCancel() {
238 if (jButtonCancel
== null) {
239 jButtonCancel
= new JButton();
240 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 162, 90, 20));
241 jButtonCancel
.setText("Cancel");
242 jButtonCancel
.addActionListener(this);
244 return jButtonCancel
;
247 public static void main(String
[] args
) {
251 * This method initializes this
254 private void init() {
255 this.setSize(505, 235);
256 this.setContentPane(getJScrollPane());
257 this.setTitle("Boot Modes");
259 this.setViewMode(false);
264 * This method initializes this Fill values to all fields if these values are
267 * @param inBootModesId
270 private void init(BootModesIdentification inBootModesId
, ModuleIdentification mid
) {
272 this.id
= inBootModesId
;
275 // Init arch with module's arch
277 this.jArchCheckBox
.setEnabledItems(wt
.getModuleArch(mid
));
279 if (this.id
!= null) {
280 this.jComboBoxBootModeName
.setSelectedItem(id
.getName());
281 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
282 this.jTextAreaHelpText
.setText(id
.getHelp());
283 this.jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
284 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
289 * This is the override edit constructor
291 * @param inBootModesIdentification
295 public BootModesDlg(BootModesIdentification inBootModesIdentification
, IFrame iFrame
, ModuleIdentification mid
) {
297 init(inBootModesIdentification
, mid
);
301 * Disable all components when the mode is view
304 * true - The view mode; false - The non-view mode
307 public void setViewMode(boolean isView
) {
309 this.jComboBoxBootModeName
.setEnabled(!isView
);
310 this.jComboBoxUsage
.setEnabled(!isView
);
315 * This method initializes jContentPane
317 * @return javax.swing.JPanel jContentPane
320 private JPanel
getJContentPane() {
321 if (jContentPane
== null) {
322 jStarLabel1
= new StarLabel();
323 jStarLabel1
.setLocation(new java
.awt
.Point(2, 12));
324 jLabelBootModeName
= new JLabel();
325 jLabelBootModeName
.setText("Boot Mode Name");
326 jLabelBootModeName
.setBounds(new java
.awt
.Rectangle(12, 12, 155, 20));
327 jStarLabel2
= new StarLabel();
328 jStarLabel2
.setLocation(new java
.awt
.Point(2, 37));
329 jLabelUsage
= new JLabel();
330 jLabelUsage
.setText("Usage");
331 jLabelUsage
.setBounds(new java
.awt
.Rectangle(12, 37, 155, 20));
332 jLabelHelpText
= new JLabel();
333 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(12, 62, 155, 20));
334 jLabelHelpText
.setText("Help Text");
335 jLabelFeatureFlag
= new JLabel();
336 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(12, 132, 155, 20));
337 jLabelFeatureFlag
.setText("Feature Flag Expression");
338 jLabelFeatureFlag
.setEnabled(false);
339 jLabelArch
= new JLabel();
340 jLabelArch
.setBounds(new java
.awt
.Rectangle(12, 107, 155, 20));
341 jLabelArch
.setText("Supported Archectures");
342 jArchCheckBox
= new ArchCheckBox();
343 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(168, 107, 320, 20));
344 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
346 jContentPane
= new JPanel();
347 jContentPane
.setLayout(null);
348 jContentPane
.setPreferredSize(new java
.awt
.Dimension(480, 180));
350 jContentPane
.add(jLabelBootModeName
, null);
351 jContentPane
.add(getJComboBoxBootModeName(), null);
352 jContentPane
.add(jLabelUsage
, null);
353 jContentPane
.add(getJComboBoxUsage(), null);
355 jContentPane
.add(jStarLabel1
, null);
356 jContentPane
.add(jStarLabel2
, null);
357 jContentPane
.add(jLabelFeatureFlag
, null);
358 jContentPane
.add(getJTextFieldFeatureFlag(), null);
359 jContentPane
.add(jLabelArch
, null);
361 jContentPane
.add(jLabelHelpText
, null);
362 jContentPane
.add(getJScrollPaneHelpText(), null);
363 jContentPane
.add(jArchCheckBox
, null);
364 jContentPane
.add(getJButtonOk(), null);
365 jContentPane
.add(getJButtonCancel(), null);
371 * This method initializes BootModeName groups and Usage type
374 private void initFrame() {
375 Tools
.generateComboBoxByVector(jComboBoxBootModeName
, ed
.getVBootModeNames());
376 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVBootModeUsage());
382 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
384 * Override actionPerformed to listen all actions
387 public void actionPerformed(ActionEvent arg0
) {
388 if (arg0
.getSource() == jButtonOk
) {
390 getCurrentBootModes();
391 this.returnType
= DataType
.RETURN_TYPE_OK
;
392 this.setVisible(false);
396 if (arg0
.getSource() == jButtonCancel
) {
397 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
398 this.setVisible(false);
403 * Data validation for all fields
405 * @retval true - All datas are valid
406 * @retval false - At least one data is invalid
409 public boolean checkAdd() {
411 // Check if all fields have correct data types
417 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
418 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
419 Log
.wrn("Update Boot Modes", "Incorrect data type for Feature Flag");
427 private BootModesIdentification
getCurrentBootModes() {
428 String arg0
= this.jComboBoxBootModeName
.getSelectedItem().toString();
429 String arg1
= this.jComboBoxUsage
.getSelectedItem().toString();
431 String arg2
= this.jTextFieldFeatureFlag
.getText();
432 Vector
<String
> arg3
= this.jArchCheckBox
.getSelectedItemsVector();
433 String arg4
= this.jTextAreaHelpText
.getText();
434 id
= new BootModesIdentification(arg0
, arg1
, arg2
, arg3
, arg4
);
438 public BootModesIdentification
getId() {
442 public void setId(BootModesIdentification id
) {