3 The file is used to create, update BootModes of MSA/MBD file
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
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.
16 package org
.tianocore
.frameworkwizard
.module
.ui
.dialog
;
18 import java
.awt
.event
.ActionEvent
;
19 import java
.util
.Vector
;
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
;
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
;
41 The class is used to create, update BootModes of MSA/MBD file
47 public class BootModesDlg
extends IDialog
{
50 /// Define class Serial Version UID
52 private static final long serialVersionUID
= -3888558623432442561L;
55 //Define class members
57 private JPanel jContentPane
= null;
59 private JLabel jLabelBootModeName
= null;
61 private JComboBox jComboBoxBootModeName
= null;
63 private JLabel jLabelUsage
= null;
65 private JComboBox jComboBoxUsage
= null;
67 private StarLabel jStarLabel1
= null;
69 private StarLabel jStarLabel2
= null;
71 private JLabel jLabelFeatureFlag
= null;
73 private JTextField jTextFieldFeatureFlag
= null;
75 private JLabel jLabelArch
= null;
77 private JScrollPane jScrollPane
= null;
79 private JLabel jLabelHelpText
= null;
81 private JTextArea jTextAreaHelpText
= null;
83 private JScrollPane jScrollPaneHelpText
= null;
85 private ArchCheckBox jArchCheckBox
= null;
87 private JButton jButtonOk
= null;
89 private JButton jButtonCancel
= null;
94 private BootModesIdentification id
= null;
96 private EnumerationData ed
= new EnumerationData();
99 This method initializes jComboBoxBootModeName
101 @return javax.swing.JComboBox jComboBoxBootModeName
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>");
111 return jComboBoxBootModeName
;
115 This method initializes jComboBoxUsage
117 @return javax.swing.JComboBox jComboBoxUsage
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>");
127 return jComboBoxUsage
;
131 * This method initializes jTextFieldFeatureFlag
133 * @return javax.swing.JTextField
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));
141 return jTextFieldFeatureFlag
;
145 This method initializes jScrollPane
147 @return javax.swing.JScrollPane
149 private JScrollPane
getJScrollPane() {
150 if (jScrollPane
== null) {
151 jScrollPane
= new JScrollPane();
152 jScrollPane
.setViewportView(getJContentPane());
158 This method initializes jTextAreaHelpText
160 @return javax.swing.JTextArea
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));
171 return jTextAreaHelpText
;
175 This method initializes jScrollPaneHelpText
177 @return javax.swing.JScrollPane
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());
189 return jScrollPaneHelpText
;
193 This method initializes jButtonOk
195 @return javax.swing.JButton
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);
209 This method initializes jButtonCancel
211 @return javax.swing.JButton
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);
221 return jButtonCancel
;
224 public static void main(String
[] args
) {
228 This method initializes this
231 private void init() {
232 this.setSize(500, 230);
233 this.setContentPane(getJScrollPane());
234 this.setTitle("Boot Modes");
236 this.setViewMode(false);
241 This method initializes this
242 Fill values to all fields if these values are not empty
247 private void init(BootModesIdentification inBootModesId
) {
249 this.id
= inBootModesId
;
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());
261 This is the override edit constructor
263 @param inBootModesIdentification
267 public BootModesDlg(BootModesIdentification inBootModesIdentification
, IFrame iFrame
) {
269 init(inBootModesIdentification
);
273 Disable all components when the mode is view
275 @param isView true - The view mode; false - The non-view mode
278 public void setViewMode(boolean isView
) {
280 this.jComboBoxBootModeName
.setEnabled(!isView
);
281 this.jComboBoxUsage
.setEnabled(!isView
);
286 This method initializes jContentPane
288 @return javax.swing.JPanel jContentPane
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));
316 jContentPane
= new JPanel();
317 jContentPane
.setLayout(null);
318 jContentPane
.setPreferredSize(new java
.awt
.Dimension(485, 185));
320 jContentPane
.add(jLabelBootModeName
, null);
321 jContentPane
.add(getJComboBoxBootModeName(), null);
322 jContentPane
.add(jLabelUsage
, null);
323 jContentPane
.add(getJComboBoxUsage(), null);
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);
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);
341 This method initializes BootModeName groups and Usage type
344 private void initFrame() {
345 Tools
.generateComboBoxByVector(jComboBoxBootModeName
, ed
.getVBootModeNames());
346 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVPpiUsage());
350 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
352 * Override actionPerformed to listen all actions
355 public void actionPerformed(ActionEvent arg0
) {
356 if (arg0
.getSource() == jButtonOk
) {
358 getCurrentBootModes();
359 this.returnType
= DataType
.RETURN_TYPE_OK
;
360 this.setVisible(false);
364 if (arg0
.getSource() == jButtonCancel
) {
365 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
366 this.setVisible(false);
371 Data validation for all fields
373 @retval true - All datas are valid
374 @retval false - At least one data is invalid
377 public boolean checkAdd() {
379 // Check if all fields have correct data types
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");
395 private BootModesIdentification
getCurrentBootModes() {
396 String arg0
= this.jComboBoxBootModeName
.getSelectedItem().toString();
398 String arg1
= this.jComboBoxUsage
.getSelectedItem().toString();
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
);
407 public BootModesIdentification
getId() {
411 public void setId(BootModesIdentification id
) {