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
;
28 import org
.tianocore
.frameworkwizard
.common
.DataType
;
29 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
30 import org
.tianocore
.frameworkwizard
.common
.EnumerationData
;
31 import org
.tianocore
.frameworkwizard
.common
.Log
;
32 import org
.tianocore
.frameworkwizard
.common
.Tools
;
33 import org
.tianocore
.frameworkwizard
.common
.ui
.ArchCheckBox
;
34 import org
.tianocore
.frameworkwizard
.common
.ui
.IDialog
;
35 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
36 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
37 import org
.tianocore
.frameworkwizard
.module
.Identifications
.BootModes
.BootModesIdentification
;
40 The class is used to create, update BootModes of MSA/MBD file
46 public class BootModesDlg
extends IDialog
{
49 /// Define class Serial Version UID
51 private static final long serialVersionUID
= -3888558623432442561L;
54 //Define class members
56 private JPanel jContentPane
= null;
58 private JLabel jLabelBootModeName
= null;
60 private JComboBox jComboBoxBootModeName
= null;
62 private JLabel jLabelUsage
= null;
64 private JComboBox jComboBoxUsage
= null;
66 private StarLabel jStarLabel1
= null;
68 private StarLabel jStarLabel2
= null;
70 private JLabel jLabelFeatureFlag
= null;
72 private JTextField jTextFieldFeatureFlag
= null;
74 private JLabel jLabelArch
= null;
76 private JScrollPane jScrollPane
= null;
78 private JLabel jLabelHelpText
= null;
80 private JTextField jTextFieldHelpText
= null;
82 private ArchCheckBox jArchCheckBox
= null;
84 private JButton jButtonOk
= null;
86 private JButton jButtonCancel
= null;
91 private BootModesIdentification id
= null;
93 private EnumerationData ed
= new EnumerationData();
96 This method initializes jComboBoxBootModeName
98 @return javax.swing.JComboBox jComboBoxBootModeName
101 private JComboBox
getJComboBoxBootModeName() {
102 if (jComboBoxBootModeName
== null) {
103 jComboBoxBootModeName
= new JComboBox();
104 jComboBoxBootModeName
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
105 jComboBoxBootModeName
.setPreferredSize(new java
.awt
.Dimension(320, 20));
107 return jComboBoxBootModeName
;
111 This method initializes jComboBoxUsage
113 @return javax.swing.JComboBox jComboBoxUsage
116 private JComboBox
getJComboBoxUsage() {
117 if (jComboBoxUsage
== null) {
118 jComboBoxUsage
= new JComboBox();
119 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
120 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
122 return jComboBoxUsage
;
126 * This method initializes jTextFieldFeatureFlag
128 * @return javax.swing.JTextField
130 private JTextField
getJTextFieldFeatureFlag() {
131 if (jTextFieldFeatureFlag
== null) {
132 jTextFieldFeatureFlag
= new JTextField();
133 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(160, 85, 320, 20));
134 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
136 return jTextFieldFeatureFlag
;
140 This method initializes jScrollPane
142 @return javax.swing.JScrollPane
144 private JScrollPane
getJScrollPane() {
145 if (jScrollPane
== null) {
146 jScrollPane
= new JScrollPane();
147 jScrollPane
.setViewportView(getJContentPane());
153 This method initializes jTextFieldHelpText
155 @return javax.swing.JTextField
158 private JTextField
getJTextFieldHelpText() {
159 if (jTextFieldHelpText
== null) {
160 jTextFieldHelpText
= new JTextField();
161 jTextFieldHelpText
.setBounds(new java
.awt
.Rectangle(160, 60, 320, 20));
162 jTextFieldHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 20));
164 return jTextFieldHelpText
;
168 This method initializes jButtonOk
170 @return javax.swing.JButton
173 private JButton
getJButtonOk() {
174 if (jButtonOk
== null) {
175 jButtonOk
= new JButton();
176 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 140, 90, 20));
177 jButtonOk
.setText("Ok");
178 jButtonOk
.addActionListener(this);
184 This method initializes jButtonCancel
186 @return javax.swing.JButton
189 private JButton
getJButtonCancel() {
190 if (jButtonCancel
== null) {
191 jButtonCancel
= new JButton();
192 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 140, 90, 20));
193 jButtonCancel
.setText("Cancel");
194 jButtonCancel
.addActionListener(this);
196 return jButtonCancel
;
199 public static void main(String
[] args
) {
203 This method initializes this
206 private void init() {
207 this.setSize(508, 220);
208 this.setContentPane(getJScrollPane());
209 this.setTitle("Boot Modes");
211 this.setViewMode(false);
216 This method initializes this
217 Fill values to all fields if these values are not empty
222 private void init(BootModesIdentification inBootModesId
) {
224 this.id
= inBootModesId
;
226 if (this.id
!= null) {
227 this.jComboBoxBootModeName
.setSelectedItem(id
.getName());
228 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
229 this.jTextFieldHelpText
.setText(id
.getHelp());
230 this.jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
231 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
236 This is the override edit constructor
238 @param inBootModesIdentification
242 public BootModesDlg(BootModesIdentification inBootModesIdentification
, IFrame iFrame
) {
244 init(inBootModesIdentification
);
248 Disable all components when the mode is view
250 @param isView true - The view mode; false - The non-view mode
253 public void setViewMode(boolean isView
) {
255 this.jComboBoxBootModeName
.setEnabled(!isView
);
256 this.jComboBoxUsage
.setEnabled(!isView
);
261 This method initializes jContentPane
263 @return javax.swing.JPanel jContentPane
266 private JPanel
getJContentPane() {
267 if (jContentPane
== null) {
268 jArchCheckBox
= new ArchCheckBox();
269 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(160, 110, 320, 20));
270 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
271 jLabelArch
= new JLabel();
272 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 110, 140, 20));
273 jLabelArch
.setText("Arch");
274 jLabelFeatureFlag
= new JLabel();
275 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(15, 85, 140, 20));
276 jLabelFeatureFlag
.setText("Feature Flag");
277 jLabelUsage
= new JLabel();
278 jLabelUsage
.setText("Usage");
279 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
280 jLabelBootModeName
= new JLabel();
281 jLabelBootModeName
.setText("Boot Mode Name");
282 jLabelBootModeName
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
283 jLabelHelpText
= new JLabel();
284 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(14, 60, 140, 20));
285 jLabelHelpText
.setText("Help Text");
287 jContentPane
= new JPanel();
288 jContentPane
.setLayout(null);
289 jContentPane
.setPreferredSize(new java
.awt
.Dimension(490, 165));
291 jContentPane
.add(jLabelBootModeName
, null);
292 jContentPane
.add(getJComboBoxBootModeName(), null);
293 jContentPane
.add(jLabelUsage
, null);
294 jContentPane
.add(getJComboBoxUsage(), null);
295 jStarLabel1
= new StarLabel();
296 jStarLabel1
.setLocation(new java
.awt
.Point(0, 10));
297 jStarLabel2
= new StarLabel();
298 jStarLabel2
.setLocation(new java
.awt
.Point(0, 35));
300 jContentPane
.add(jStarLabel1
, null);
301 jContentPane
.add(jStarLabel2
, null);
302 jContentPane
.add(jLabelFeatureFlag
, null);
303 jContentPane
.add(getJTextFieldFeatureFlag(), null);
304 jContentPane
.add(jLabelArch
, null);
306 jContentPane
.add(jLabelHelpText
, null);
307 jContentPane
.add(getJTextFieldHelpText(), null);
308 jContentPane
.add(jArchCheckBox
, null);
309 jContentPane
.add(getJButtonOk(), null);
310 jContentPane
.add(getJButtonCancel(), null);
316 This method initializes BootModeName groups and Usage type
319 private void initFrame() {
320 Tools
.generateComboBoxByVector(jComboBoxBootModeName
, ed
.getVBootModeNames());
321 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVPpiUsage());
325 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
327 * Override actionPerformed to listen all actions
330 public void actionPerformed(ActionEvent arg0
) {
331 if (arg0
.getSource() == jButtonOk
) {
333 getCurrentBootModes();
334 this.returnType
= DataType
.RETURN_TYPE_OK
;
335 this.setVisible(false);
339 if (arg0
.getSource() == jButtonCancel
) {
340 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
341 this.setVisible(false);
346 Data validation for all fields
348 @retval true - All datas are valid
349 @retval false - At least one data is invalid
352 public boolean checkAdd() {
354 // Check if all fields have correct data types
360 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
361 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
362 Log
.wrn("Update Boot Modes", "Incorrect data type for Feature Flag");
370 private BootModesIdentification
getCurrentBootModes() {
371 String arg0
= this.jComboBoxBootModeName
.getSelectedItem().toString();
373 String arg1
= this.jComboBoxUsage
.getSelectedItem().toString();
375 String arg2
= this.jTextFieldFeatureFlag
.getText();
376 Vector
<String
> arg3
= this.jArchCheckBox
.getSelectedItemsVector();
377 String arg4
= this.jTextFieldHelpText
.getText();
378 id
= new BootModesIdentification(arg0
, arg1
, arg2
, arg3
, arg4
);
382 public BootModesIdentification
getId() {
386 public void setId(BootModesIdentification id
) {