3 The file is used to create, update Guids 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
.Guids
.GuidsIdentification
;
37 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
40 The class is used to create, update Guids of MSA/MBD file
41 It extends IInternalFrame
46 public class GuidsDlg
extends IDialog
{
49 /// Define class Serial Version UID
51 private static final long serialVersionUID
= 6710858997766979803L;
54 //Define class members
56 private JPanel jContentPane
= null;
58 private JLabel jLabelC_Name
= null;
60 private JComboBox jComboBoxCName
= 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 GuidsIdentification id
= null;
93 private EnumerationData ed
= new EnumerationData();
95 private WorkspaceTools wt
= new WorkspaceTools();
98 This method initializes jTextFieldC_Name
100 @return javax.swing.JTextField jTextFieldC_Name
103 private JComboBox
getJComboBoxCName() {
104 if (jComboBoxCName
== null) {
105 jComboBoxCName
= new JComboBox();
106 jComboBoxCName
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
107 jComboBoxCName
.setPreferredSize(new java
.awt
.Dimension(320, 20));
109 return jComboBoxCName
;
113 This method initializes jComboBoxUsage
115 @return javax.swing.JComboBox jComboBoxUsage
118 private JComboBox
getJComboBoxUsage() {
119 if (jComboBoxUsage
== null) {
120 jComboBoxUsage
= new JComboBox();
121 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
122 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
124 return jComboBoxUsage
;
128 This method initializes jTextFieldFeatureFlag
130 @return javax.swing.JTextField
133 private JTextField
getJTextFieldFeatureFlag() {
134 if (jTextFieldFeatureFlag
== null) {
135 jTextFieldFeatureFlag
= new JTextField();
136 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(160, 85, 320, 20));
137 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
139 return jTextFieldFeatureFlag
;
143 This method initializes jScrollPane
145 @return javax.swing.JScrollPane
147 private JScrollPane
getJScrollPane() {
148 if (jScrollPane
== null) {
149 jScrollPane
= new JScrollPane();
150 jScrollPane
.setViewportView(getJContentPane());
156 This method initializes jTextFieldHelpText
158 @return javax.swing.JTextField
161 private JTextField
getJTextFieldHelpText() {
162 if (jTextFieldHelpText
== null) {
163 jTextFieldHelpText
= new JTextField();
164 jTextFieldHelpText
.setBounds(new java
.awt
.Rectangle(160, 60, 320, 20));
165 jTextFieldHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 20));
167 return jTextFieldHelpText
;
171 This method initializes jButtonOk
173 @return javax.swing.JButton
176 private JButton
getJButtonOk() {
177 if (jButtonOk
== null) {
178 jButtonOk
= new JButton();
179 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 140, 90, 20));
180 jButtonOk
.setText("Ok");
181 jButtonOk
.addActionListener(this);
187 This method initializes jButtonCancel
189 @return javax.swing.JButton
192 private JButton
getJButtonCancel() {
193 if (jButtonCancel
== null) {
194 jButtonCancel
= new JButton();
195 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 140, 90, 20));
196 jButtonCancel
.setText("Cancel");
197 jButtonCancel
.addActionListener(this);
199 return jButtonCancel
;
202 public static void main(String
[] args
) {
207 This method initializes this
210 private void init() {
211 this.setSize(500, 200);
212 this.setContentPane(getJScrollPane());
213 this.setTitle("Guids");
215 this.setViewMode(false);
220 This method initializes this
221 Fill values to all fields if these values are not empty
226 private void init(GuidsIdentification inGuidsId
) {
230 if (this.id
!= null) {
231 this.jComboBoxCName
.setSelectedItem(id
.getName());
232 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
233 this.jTextFieldHelpText
.setText(id
.getHelp());
234 this.jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
235 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
240 This is the override edit constructor
242 @param inGuidsIdentification
246 public GuidsDlg(GuidsIdentification inGuidsIdentification
, IFrame iFrame
) {
248 init(inGuidsIdentification
);
252 Disable all components when the mode is view
254 @param isView true - The view mode; false - The non-view mode
257 public void setViewMode(boolean isView
) {
259 this.jComboBoxUsage
.setEnabled(!isView
);
264 This method initializes jContentPane
266 @return javax.swing.JPanel jContentPane
269 private JPanel
getJContentPane() {
270 if (jContentPane
== null) {
271 jArchCheckBox
= new ArchCheckBox();
272 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(160, 110, 320, 20));
273 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
274 jLabelUsage
= new JLabel();
275 jLabelUsage
.setText("Usage");
276 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
277 jLabelC_Name
= new JLabel();
278 jLabelC_Name
.setText("C_Name");
279 jLabelC_Name
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
280 jLabelArch
= new JLabel();
281 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 110, 140, 20));
282 jLabelArch
.setText("Arch");
283 jLabelFeatureFlag
= new JLabel();
284 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(15, 85, 140, 20));
285 jLabelFeatureFlag
.setText("Feature Flag");
286 jLabelHelpText
= new JLabel();
287 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(14, 60, 140, 20));
288 jLabelHelpText
.setText("Help Text");
290 jContentPane
= new JPanel();
291 jContentPane
.setLayout(null);
292 jContentPane
.setPreferredSize(new java
.awt
.Dimension(490, 165));
294 jContentPane
.add(jLabelC_Name
, null);
295 jContentPane
.add(getJComboBoxCName(), null);
296 jContentPane
.add(jLabelUsage
, null);
297 jContentPane
.add(getJComboBoxUsage(), null);
298 jContentPane
.add(jLabelFeatureFlag
, null);
299 jContentPane
.add(jLabelArch
, null);
300 jContentPane
.add(getJTextFieldFeatureFlag(), null);
302 jStarLabel1
= new StarLabel();
303 jStarLabel1
.setLocation(new java
.awt
.Point(0, 10));
304 jStarLabel2
= new StarLabel();
305 jStarLabel2
.setLocation(new java
.awt
.Point(0, 35));
307 jContentPane
.add(jStarLabel1
, null);
308 jContentPane
.add(jStarLabel2
, null);
310 jContentPane
.add(jLabelHelpText
, null);
311 jContentPane
.add(getJTextFieldHelpText(), null);
312 jContentPane
.add(jArchCheckBox
, null);
313 jContentPane
.add(getJButtonOk(), null);
314 jContentPane
.add(getJButtonCancel(), null);
320 This method initializes Usage type
323 private void initFrame() {
324 Tools
.generateComboBoxByVector(jComboBoxCName
, wt
.getAllGuidDeclarationsFromWorkspace());
325 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVGuidUsage());
329 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
331 * Override actionPerformed to listen all actions
334 public void actionPerformed(ActionEvent arg0
) {
335 if (arg0
.getSource() == jButtonOk
) {
338 this.returnType
= DataType
.RETURN_TYPE_OK
;
339 this.setVisible(false);
343 if (arg0
.getSource() == jButtonCancel
) {
344 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
345 this.setVisible(false);
350 Data validation for all fields
352 @retval true - All datas are valid
353 @retval false - At least one data is invalid
356 public boolean checkAdd() {
358 // Check if all fields have correct data types
364 if (!isEmpty(this.jComboBoxCName
.getSelectedItem().toString())) {
365 if (!DataValidation
.isC_NameType(this.jComboBoxCName
.getSelectedItem().toString())) {
366 Log
.err("Incorrect data type for Guid Name");
374 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
375 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
376 Log
.err("Incorrect data type for Feature Flag");
384 private GuidsIdentification
getCurrentGuids() {
385 String arg0
= this.jComboBoxCName
.getSelectedItem().toString();
386 String arg1
= this.jComboBoxUsage
.getSelectedItem().toString();
388 String arg2
= this.jTextFieldFeatureFlag
.getText();
389 Vector
<String
> arg3
= this.jArchCheckBox
.getSelectedItemsVector();
390 String arg4
= this.jTextFieldHelpText
.getText();
392 id
= new GuidsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
);
396 public GuidsIdentification
getId() {
400 public void setId(GuidsIdentification id
) {