3 The file is used to create, update Formset 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.
15 package org
.tianocore
.frameworkwizard
.module
.ui
.dialog
;
17 import java
.awt
.event
.ActionEvent
;
18 import java
.util
.Vector
;
20 import javax
.swing
.JButton
;
21 import javax
.swing
.JComboBox
;
22 import javax
.swing
.JLabel
;
23 import javax
.swing
.JPanel
;
24 import javax
.swing
.JScrollPane
;
25 import javax
.swing
.JTextField
;
27 import org
.tianocore
.frameworkwizard
.common
.DataType
;
28 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
29 import org
.tianocore
.frameworkwizard
.common
.EnumerationData
;
30 import org
.tianocore
.frameworkwizard
.common
.Log
;
31 import org
.tianocore
.frameworkwizard
.common
.Tools
;
32 import org
.tianocore
.frameworkwizard
.common
.ui
.ArchCheckBox
;
33 import org
.tianocore
.frameworkwizard
.common
.ui
.IDialog
;
34 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
35 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
36 import org
.tianocore
.frameworkwizard
.module
.Identifications
.HiiPackages
.HiiPackagesIdentification
;
39 The class is used to create, update Formset of MSA/MBD file
40 It extends IInternalFrame
45 public class HiiPackagesDlg
extends IDialog
{
48 /// Define class Serial Version UID
50 private static final long serialVersionUID
= -6851574146786158116L;
53 //Define class members
55 private JPanel jContentPane
= null;
57 private JLabel jLabelName
= null;
59 private JTextField jTextFieldName
= null;
61 private JLabel jLabelUsage
= null;
63 private JComboBox jComboBoxUsage
= null;
65 private StarLabel jStarLabel1
= null;
67 private StarLabel jStarLabel2
= null;
69 private JLabel jLabelFeatureFlag
= null;
71 private JTextField jTextFieldFeatureFlag
= null;
73 private JLabel jLabelArch
= null;
75 private JScrollPane jScrollPane
= null;
77 private JLabel jLabelHelpText
= null;
79 private JTextField jTextFieldHelpText
= null;
81 private ArchCheckBox jArchCheckBox
= null;
83 private JButton jButtonOk
= null;
85 private JButton jButtonCancel
= null;
90 private HiiPackagesIdentification id
= null;
92 private EnumerationData ed
= new EnumerationData();
95 This method initializes jTextFieldName
97 @return javax.swing.JTextField jTextFieldName
100 private JTextField
getJTextFieldName() {
101 if (jTextFieldName
== null) {
102 jTextFieldName
= new JTextField();
103 jTextFieldName
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
104 jTextFieldName
.setPreferredSize(new java
.awt
.Dimension(320, 20));
105 jTextFieldName
.setToolTipText("Enter the C Name of the HII Package");
107 return jTextFieldName
;
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
) {
204 This method initializes this
207 private void init() {
208 this.setSize(500, 200);
209 this.setContentPane(getJScrollPane());
210 this.setTitle("Hii Packages");
212 this.setViewMode(false);
217 This method initializes this
218 Fill values to all fields if these values are not empty
220 @param inHiiPackagesId
223 private void init(HiiPackagesIdentification inHiiPackagesId
) {
225 this.id
= inHiiPackagesId
;
227 if (this.id
!= null) {
228 this.jTextFieldName
.setText(id
.getName());
229 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
230 this.jTextFieldHelpText
.setText(id
.getHelp());
231 this.jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
232 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
237 This is the override edit constructor
239 @param inHiiPackagesIdentification
243 public HiiPackagesDlg(HiiPackagesIdentification inHiiPackagesIdentification
, IFrame iFrame
) {
245 init(inHiiPackagesIdentification
);
249 Disable all components when the mode is view
251 @param isView true - The view mode; false - The non-view mode
254 public void setViewMode(boolean isView
) {
256 this.jTextFieldName
.setEnabled(!isView
);
257 this.jComboBoxUsage
.setEnabled(!isView
);
262 This method initializes jContentPane
264 @return javax.swing.JPanel jContentPane
267 private JPanel
getJContentPane() {
268 if (jContentPane
== null) {
269 jArchCheckBox
= new ArchCheckBox();
270 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(160, 110, 320, 20));
271 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
272 jLabelUsage
= new JLabel();
273 jLabelUsage
.setText("Usage");
274 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
275 jLabelName
= new JLabel();
276 jLabelName
.setText("Name");
277 jLabelName
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
278 jLabelArch
= new JLabel();
279 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 110, 140, 20));
280 jLabelArch
.setText("Arch");
281 jLabelFeatureFlag
= new JLabel();
282 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(15, 85, 140, 20));
283 jLabelFeatureFlag
.setText("Feature Flag");
284 jLabelHelpText
= new JLabel();
285 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(14, 60, 140, 20));
286 jLabelHelpText
.setText("Help Text");
288 jContentPane
= new JPanel();
289 jContentPane
.setLayout(null);
290 jContentPane
.setPreferredSize(new java
.awt
.Dimension(490, 165));
292 jContentPane
.add(jLabelName
, null);
293 jContentPane
.add(jLabelUsage
, null);
294 jContentPane
.add(getJTextFieldName(), null);
295 jContentPane
.add(getJComboBoxUsage(), null);
297 jContentPane
.add(jLabelFeatureFlag
, null);
298 jContentPane
.add(jLabelArch
, null);
299 jContentPane
.add(getJTextFieldFeatureFlag(), null);
301 jStarLabel1
= new StarLabel();
302 jStarLabel1
.setLocation(new java
.awt
.Point(0, 10));
303 jStarLabel2
= new StarLabel();
304 jStarLabel2
.setLocation(new java
.awt
.Point(0, 35));
306 jContentPane
.add(jStarLabel1
, null);
307 jContentPane
.add(jStarLabel2
, null);
309 jContentPane
.add(jLabelHelpText
, null);
310 jContentPane
.add(getJTextFieldHelpText(), null);
311 jContentPane
.add(jArchCheckBox
, null);
312 jContentPane
.add(getJButtonOk(), null);
313 jContentPane
.add(getJButtonCancel(), null);
319 This method initializes Usage type
322 private void initFrame() {
323 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVHiiPackageUsage());
327 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
329 * Override actionPerformed to listen all actions
332 public void actionPerformed(ActionEvent arg0
) {
333 if (arg0
.getSource() == jButtonOk
) {
335 getCurrentHiiPackages();
336 this.returnType
= DataType
.RETURN_TYPE_OK
;
337 this.setVisible(false);
341 if (arg0
.getSource() == jButtonCancel
) {
342 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
343 this.setVisible(false);
348 Data validation for all fields
350 @retval true - All datas are valid
351 @retval false - At least one data is invalid
354 public boolean checkAdd() {
356 // Check if all fields have correct data types
360 // Check Hii Package Name
362 if (isEmpty(this.jTextFieldName
.getText())) {
363 Log
.err("Hii Package Name Record couldn't be empty");
367 if (!isEmpty(this.jTextFieldName
.getText())) {
368 if (!DataValidation
.isC_NameType(this.jTextFieldName
.getText())) {
369 Log
.err("Incorrect data type for Hii Package Name");
377 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
378 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
379 Log
.err("Incorrect data type for Feature Flag");
387 private HiiPackagesIdentification
getCurrentHiiPackages() {
388 String arg0
= this.jTextFieldName
.getText();
389 String arg1
= this.jComboBoxUsage
.getSelectedItem().toString();
391 String arg2
= this.jTextFieldFeatureFlag
.getText();
392 Vector
<String
> arg3
= this.jArchCheckBox
.getSelectedItemsVector();
393 String arg4
= this.jTextFieldHelpText
.getText();
395 id
= new HiiPackagesIdentification(arg0
, arg1
, arg2
, arg3
, arg4
);
399 public HiiPackagesIdentification
getId() {
403 public void setId(HiiPackagesIdentification id
) {