3 The file is used to create, update SystemTable 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
.SystemTables
.SystemTablesIdentification
;
37 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
40 The class is used to create, update SystemTable of MSA/MBD file
41 It extends IInternalFrame
46 public class SystemTablesDlg
extends IDialog
{
49 /// Define class Serial Version UID
51 private static final long serialVersionUID
= 7488769180379442276L;
54 //Define class members
56 private JPanel jContentPane
= null;
58 private JLabel jLabelEntry
= null;
60 private JLabel jLabelUsage
= null;
62 private JComboBox jComboBoxUsage
= null;
64 private StarLabel jStarLabel1
= null;
66 private StarLabel jStarLabel2
= null;
68 private JComboBox jComboBoxGuidC_Name
= 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 SystemTablesIdentification id
= null;
93 private EnumerationData ed
= new EnumerationData();
95 private WorkspaceTools wt
= new WorkspaceTools();
98 This method initializes jComboBoxUsage
100 @return javax.swing.JComboBox jComboBoxUsage
103 private JComboBox
getJComboBoxUsage() {
104 if (jComboBoxUsage
== null) {
105 jComboBoxUsage
= new JComboBox();
106 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
107 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
109 return jComboBoxUsage
;
113 This method initializes jTextField
115 @return javax.swing.JTextField jTextFieldC_Name
118 private JComboBox
getJComboBoxGuidC_Name() {
119 if (jComboBoxGuidC_Name
== null) {
120 jComboBoxGuidC_Name
= new JComboBox();
121 jComboBoxGuidC_Name
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
122 jComboBoxGuidC_Name
.setPreferredSize(new java
.awt
.Dimension(320, 20));
123 jComboBoxGuidC_Name
.setToolTipText("Select the GUID C Name of the Hob");
125 return jComboBoxGuidC_Name
;
129 * This method initializes jTextFieldFeatureFlag
131 * @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("System Tables");
215 this.setViewMode(false);
220 This method initializes this
221 Fill values to all fields if these values are not empty
223 @param inSystemTablesId
226 private void init(SystemTablesIdentification inSystemTablesId
) {
228 this.id
= inSystemTablesId
;
230 if (this.id
!= null) {
231 this.jComboBoxGuidC_Name
.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 inBootModesIdentification
246 public SystemTablesDlg(SystemTablesIdentification inSystemTablesIdentification
, IFrame iFrame
) {
248 init(inSystemTablesIdentification
);
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 jLabelArch
= new JLabel();
272 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 110, 140, 20));
273 jLabelArch
.setText("Arch");
274 jArchCheckBox
= new ArchCheckBox();
275 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(160, 110, 320, 20));
276 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
277 jLabelFeatureFlag
= new JLabel();
278 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(15, 85, 140, 20));
279 jLabelFeatureFlag
.setText("Feature Flag");
280 jLabelUsage
= new JLabel();
281 jLabelUsage
.setText("Usage");
282 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
283 jLabelEntry
= new JLabel();
284 jLabelEntry
.setText("Guid C_Name");
285 jLabelEntry
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
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(jLabelEntry
, null);
295 jContentPane
.add(jLabelFeatureFlag
, null);
296 jContentPane
.add(getJTextFieldFeatureFlag(), null);
297 jContentPane
.add(getJComboBoxGuidC_Name(), null);
298 jContentPane
.add(jLabelArch
, null);
299 jContentPane
.add(jLabelUsage
, null);
300 jContentPane
.add(getJComboBoxUsage(), null);
301 jStarLabel1
= new StarLabel();
302 jStarLabel1
.setBounds(new java
.awt
.Rectangle(0, 10, 10, 20));
303 jStarLabel2
= new StarLabel();
304 jStarLabel2
.setBounds(new java
.awt
.Rectangle(0, 35, 10, 20));
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
.getVSystemTableUsage());
324 Tools
.generateComboBoxByVector(jComboBoxGuidC_Name
, wt
.getAllGuidDeclarationsFromWorkspace());
328 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
330 * Override actionPerformed to listen all actions
333 public void actionPerformed(ActionEvent arg0
) {
334 if (arg0
.getSource() == jButtonOk
) {
336 getCurrentSystemTables();
337 this.returnType
= DataType
.RETURN_TYPE_OK
;
338 this.setVisible(false);
342 if (arg0
.getSource() == jButtonCancel
) {
343 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
344 this.setVisible(false);
349 Data validation for all fields
351 @retval true - All datas are valid
352 @retval false - At least one data is invalid
355 public boolean checkAdd() {
357 // Check if all fields have correct data types
363 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
364 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
365 Log
.err("Incorrect data type for Feature Flag");
373 private SystemTablesIdentification
getCurrentSystemTables() {
374 String arg0
= this.jComboBoxGuidC_Name
.getSelectedItem().toString();
375 String arg1
= this.jComboBoxUsage
.getSelectedItem().toString();
377 String arg2
= this.jTextFieldFeatureFlag
.getText();
378 Vector
<String
> arg3
= this.jArchCheckBox
.getSelectedItemsVector();
379 String arg4
= this.jTextFieldHelpText
.getText();
381 id
= new SystemTablesIdentification(arg0
, arg1
, arg2
, arg3
, arg4
);
385 public SystemTablesIdentification
getId() {
389 public void setId(SystemTablesIdentification id
) {