3 The file is used to create, update Hob 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
.Hobs
.HobsIdentification
;
37 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
40 The class is used to create, update Hob of MSA/MBD file
41 It extends IInternalFrame
44 public class HobsDlg
extends IDialog
{
47 /// Define class Serial Version UID
49 private static final long serialVersionUID
= -553473437579358325L;
52 //Define class members
54 private JPanel jContentPane
= null;
56 private JLabel jLabel
= null;
58 private JComboBox jComboBoxGuidC_Name
= null;
60 private JLabel jLabelUsage
= null;
62 private JLabel jLabelHobType
= null;
64 private JComboBox jComboBoxUsage
= null;
66 private JComboBox jComboBoxHobType
= null;
68 private StarLabel jStarLabel1
= null;
70 private JLabel jLabelArch
= null;
72 private JScrollPane jScrollPane
= null;
74 private JLabel jLabelFeatureFlag
= null;
76 private JTextField jTextFieldFeatureFlag
= 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 HobsIdentification id
= null;
93 private EnumerationData ed
= new EnumerationData();
95 private WorkspaceTools wt
= new WorkspaceTools();
98 This method initializes jTextField
100 @return javax.swing.JTextField jTextFieldC_Name
103 private JComboBox
getJComboBoxGuidC_Name() {
104 if (jComboBoxGuidC_Name
== null) {
105 jComboBoxGuidC_Name
= new JComboBox();
106 jComboBoxGuidC_Name
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
107 jComboBoxGuidC_Name
.setPreferredSize(new java
.awt
.Dimension(320, 20));
108 jComboBoxGuidC_Name
.setToolTipText("Select the GUID C Name of the Hob");
110 return jComboBoxGuidC_Name
;
114 This method initializes jComboBoxUsage
116 @return javax.swing.JComboBox jComboBoxUsage
119 private JComboBox
getJComboBoxUsage() {
120 if (jComboBoxUsage
== null) {
121 jComboBoxUsage
= new JComboBox();
122 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(160, 60, 320, 20));
123 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
125 return jComboBoxUsage
;
129 This method initializes jComboBoxHobType
131 @return javax.swing.JComboBox jComboBoxHobType
134 private JComboBox
getJComboBoxHobType() {
135 if (jComboBoxHobType
== null) {
136 jComboBoxHobType
= new JComboBox();
137 jComboBoxHobType
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
138 jComboBoxHobType
.setPreferredSize(new java
.awt
.Dimension(320, 20));
140 return jComboBoxHobType
;
144 This method initializes jScrollPane
146 @return javax.swing.JScrollPane
148 private JScrollPane
getJScrollPane() {
149 if (jScrollPane
== null) {
150 jScrollPane
= new JScrollPane();
151 jScrollPane
.setViewportView(getJContentPane());
157 * This method initializes jTextFieldFeatureFlag
159 * @return javax.swing.JTextField
161 private JTextField
getJTextFieldFeatureFlag() {
162 if (jTextFieldFeatureFlag
== null) {
163 jTextFieldFeatureFlag
= new JTextField();
164 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(160, 110, 320, 20));
165 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
167 return jTextFieldFeatureFlag
;
171 This method initializes jTextFieldHelpText
173 @return javax.swing.JTextField
176 private JTextField
getJTextFieldHelpText() {
177 if (jTextFieldHelpText
== null) {
178 jTextFieldHelpText
= new JTextField();
179 jTextFieldHelpText
.setBounds(new java
.awt
.Rectangle(160, 85, 320, 20));
180 jTextFieldHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 20));
182 return jTextFieldHelpText
;
186 This method initializes jButtonOk
188 @return javax.swing.JButton
191 private JButton
getJButtonOk() {
192 if (jButtonOk
== null) {
193 jButtonOk
= new JButton();
194 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 165, 90, 20));
195 jButtonOk
.setText("Ok");
196 jButtonOk
.addActionListener(this);
202 This method initializes jButtonCancel
204 @return javax.swing.JButton
207 private JButton
getJButtonCancel() {
208 if (jButtonCancel
== null) {
209 jButtonCancel
= new JButton();
210 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 165, 90, 20));
211 jButtonCancel
.setText("Cancel");
212 jButtonCancel
.addActionListener(this);
214 return jButtonCancel
;
217 public static void main(String
[] args
) {
222 This method initializes this
225 private void init() {
226 this.setSize(510, 240);
227 this.setContentPane(getJScrollPane());
228 this.setTitle("Hobs");
230 this.setViewMode(false);
235 This method initializes this
236 Fill values to all fields if these values are not empty
241 private void init(HobsIdentification inHobsId
) {
245 if (this.id
!= null) {
246 this.jComboBoxGuidC_Name
.setSelectedItem(id
.getName());
247 this.jComboBoxHobType
.setSelectedItem(id
.getType());
248 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
249 this.jTextFieldHelpText
.setText(id
.getHelp());
250 this.jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
251 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
256 This is the override edit constructor
258 @param inHobsIdentification
262 public HobsDlg(HobsIdentification inHobsIdentification
, IFrame iFrame
) {
264 init(inHobsIdentification
);
268 Disable all components when the mode is view
270 @param isView true - The view mode; false - The non-view mode
273 public void setViewMode(boolean isView
) {
275 this.jComboBoxGuidC_Name
.setEnabled(!isView
);
276 this.jComboBoxUsage
.setEnabled(!isView
);
277 this.jComboBoxHobType
.setEnabled(!isView
);
282 This method initializes jContentPane
284 @return javax.swing.JPanel jContentPane
287 public JPanel
getJContentPane() {
288 if (jContentPane
== null) {
289 jArchCheckBox
= new ArchCheckBox();
290 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(160, 135, 320, 20));
291 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
292 jLabelFeatureFlag
= new JLabel();
293 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(15, 110, 140, 20));
294 jLabelFeatureFlag
.setText("Feature Flag");
295 jLabelArch
= new JLabel();
296 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 135, 140, 20));
297 jLabelArch
.setText("Arch");
298 jLabelHobType
= new JLabel();
299 jLabelHobType
.setText("Hob Type");
300 jLabelHobType
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
301 jLabelUsage
= new JLabel();
302 jLabelUsage
.setText("Usage");
303 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 60, 140, 20));
304 jLabel
= new JLabel();
305 jLabel
.setText("Guid C Name");
306 jLabel
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
307 jLabelHelpText
= new JLabel();
308 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(14, 85, 140, 20));
309 jLabelHelpText
.setText("Help Text");
311 jContentPane
= new JPanel();
312 jContentPane
.setLayout(null);
313 jContentPane
.setPreferredSize(new java
.awt
.Dimension(490, 190));
315 jContentPane
.add(jLabel
, null);
316 jContentPane
.add(getJComboBoxGuidC_Name(), null);
317 jContentPane
.add(jLabelUsage
, null);
318 jContentPane
.add(jLabelHobType
, null);
319 jContentPane
.add(getJComboBoxUsage(), null);
320 jContentPane
.add(getJComboBoxHobType(), null);
321 jStarLabel1
= new StarLabel();
322 jStarLabel1
.setLocation(new java
.awt
.Point(0, 10));
323 jContentPane
.add(jStarLabel1
, null);
325 jContentPane
.add(jLabelArch
, null);
327 jContentPane
.add(jLabelFeatureFlag
, null);
328 jContentPane
.add(getJTextFieldFeatureFlag(), null);
329 jContentPane
.add(jLabelHelpText
, null);
330 jContentPane
.add(getJTextFieldHelpText(), null);
331 jContentPane
.add(jArchCheckBox
, null);
332 jContentPane
.add(getJButtonOk(), null);
333 jContentPane
.add(getJButtonCancel(), null);
339 This method initializes Usage type and Hob type
342 private void initFrame() {
343 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVHobUsage());
344 Tools
.generateComboBoxByVector(jComboBoxHobType
, ed
.getVHobType());
345 Tools
.generateComboBoxByVector(jComboBoxGuidC_Name
, wt
.getAllGuidDeclarationsFromWorkspace());
349 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
351 * Override actionPerformed to listen all actions
354 public void actionPerformed(ActionEvent arg0
) {
355 if (arg0
.getSource() == jButtonOk
) {
358 this.returnType
= DataType
.RETURN_TYPE_OK
;
359 this.setVisible(false);
363 if (arg0
.getSource() == jButtonCancel
) {
364 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
365 this.setVisible(false);
370 Data validation for all fields
372 @retval true - All datas are valid
373 @retval false - At least one data is invalid
376 public boolean checkAdd() {
378 // Check if all fields have correct data types
384 if (isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
385 Log
.wrn("Update Hobs", "Hob Name couldn't be empty");
389 if (!isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
390 if (!DataValidation
.isC_NameType(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
391 Log
.wrn("Update Hobs", "Incorrect data type for Hob Name");
399 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
400 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
401 Log
.wrn("Update Hobs", "Incorrect data type for Feature Flag");
409 private HobsIdentification
getCurrentHobs() {
410 String arg0
= this.jComboBoxGuidC_Name
.getSelectedItem().toString();
411 String arg1
= this.jComboBoxHobType
.getSelectedItem().toString();
412 String arg2
= this.jComboBoxUsage
.getSelectedItem().toString();
414 String arg3
= this.jTextFieldFeatureFlag
.getText();
415 Vector
<String
> arg4
= this.jArchCheckBox
.getSelectedItemsVector();
416 String arg5
= this.jTextFieldHelpText
.getText();
417 id
= new HobsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
);
421 public HobsIdentification
getId() {
425 public void setId(HobsIdentification id
) {