2 <<The file is used to create, update SystemTable in the MSA file>>
4 <<This dialog is used to add or edit a System Table entry in the MSA file.>>
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 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
;
27 import javax
.swing
.JTextArea
;
29 import org
.tianocore
.frameworkwizard
.common
.DataType
;
30 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
31 import org
.tianocore
.frameworkwizard
.common
.EnumerationData
;
32 import org
.tianocore
.frameworkwizard
.common
.Log
;
33 import org
.tianocore
.frameworkwizard
.common
.Tools
;
34 import org
.tianocore
.frameworkwizard
.common
.ui
.ArchCheckBox
;
35 import org
.tianocore
.frameworkwizard
.common
.ui
.IComboBox
;
36 import org
.tianocore
.frameworkwizard
.common
.ui
.IDialog
;
37 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
38 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
39 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
40 import org
.tianocore
.frameworkwizard
.module
.Identifications
.SystemTables
.SystemTablesIdentification
;
41 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
42 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
45 * The class is used to create, update SystemTables section of the MSA file
50 public class SystemTablesDlg
extends IDialog
{
53 // / Define class Serial Version UID
55 private static final long serialVersionUID
= 7488769180379442276L;
58 // Define class members
60 private JPanel jContentPane
= null;
62 private JLabel jLabelEntry
= null;
64 private JLabel jLabelUsage
= null;
66 private JComboBox jComboBoxUsage
= null;
68 private StarLabel jStarLabel1
= null;
70 private StarLabel jStarLabel2
= null;
72 private IComboBox iComboBoxGuidC_Name
= null;
74 private JLabel jLabelFeatureFlag
= null;
76 private JTextField jTextFieldFeatureFlag
= null;
78 private JLabel jLabelArch
= null;
80 private JScrollPane jScrollPane
= null;
82 private JLabel jLabelHelpText
= null;
84 private JTextArea jTextAreaHelpText
= null;
86 private JScrollPane jScrollPaneHelpText
= null;
88 private ArchCheckBox jArchCheckBox
= null;
90 private JButton jButtonOk
= null;
92 private JButton jButtonCancel
= null;
97 private SystemTablesIdentification id
= null;
99 private EnumerationData ed
= new EnumerationData();
101 private WorkspaceTools wt
= new WorkspaceTools();
104 * This method initializes iComboBoxGuidC_Name
106 * @return javax.swing.JComboBox iComboBoxGuidC_Name
109 private IComboBox
getIComboBoxGuidC_Name() {
110 if (iComboBoxGuidC_Name
== null) {
111 iComboBoxGuidC_Name
= new IComboBox();
112 iComboBoxGuidC_Name
.setBounds(new java
.awt
.Rectangle(168, 12, 320, 20));
113 iComboBoxGuidC_Name
.setPreferredSize(new java
.awt
.Dimension(320, 20));
114 iComboBoxGuidC_Name
.setToolTipText("Select the GUID C Name of the System Table");
116 return iComboBoxGuidC_Name
;
120 * This method initializes jComboBoxUsage
122 * @return javax.swing.JComboBox jComboBoxUsage
125 private JComboBox
getJComboBoxUsage() {
126 if (jComboBoxUsage
== null) {
127 jComboBoxUsage
= new JComboBox();
128 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(168, 37, 320, 20));
129 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
131 .setToolTipText("<html><table>"
132 + "<tr><td>ALWAYS_CONSUMED</td><td>Module requires a GUIDed entry in the system table</td></tr>"
133 + "<tr><td>SOMETIMES_CONSUMED</td><td>Module consumes a GUIDed entry in the system<br>table if it is present</td>"
134 + "</tr><tr><td>ALWAYS_PRODUCED</td><td>Module always produces a GUIDed entry in the system table</td></tr>"
135 + "<tr><td>SOMETIMES_PRODUCED</td><td>Module produces a GUIDed entry in the system table<br>for some of its execution flows.</td></tr>"
136 + "</table></html>");
138 return jComboBoxUsage
;
142 * This method initializes jTextFieldFeatureFlag
144 * @return javax.swing.JTextField
146 private JTextField
getJTextFieldFeatureFlag() {
147 if (jTextFieldFeatureFlag
== null) {
148 jTextFieldFeatureFlag
= new JTextField();
149 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(168, 132, 320, 20));
150 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
151 jTextFieldFeatureFlag
.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");
152 jTextFieldFeatureFlag
.setEnabled(false);
154 return jTextFieldFeatureFlag
;
158 * This method initializes jScrollPane
160 * @return javax.swing.JScrollPane
162 private JScrollPane
getJScrollPane() {
163 if (jScrollPane
== null) {
164 jScrollPane
= new JScrollPane();
165 jScrollPane
.setViewportView(getJContentPane());
171 * This method initializes jTextAreaHelpText
173 * @return javax.swing.JTextArea
176 private JTextArea
getJTextAreaHelpText() {
177 if (jTextAreaHelpText
== null) {
178 jTextAreaHelpText
= new JTextArea();
179 jTextAreaHelpText
.setLineWrap(true);
180 jTextAreaHelpText
.setWrapStyleWord(true);
182 return jTextAreaHelpText
;
186 * This method initializes jScrollPaneHelpText
188 * @returns javax.swing.JScrollPane jScrollPaneHelpText
190 private JScrollPane
getJScrollPaneHelpText() {
191 if (jScrollPaneHelpText
== null) {
192 jScrollPaneHelpText
= new JScrollPane();
193 jScrollPaneHelpText
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
194 jScrollPaneHelpText
.setSize(new java
.awt
.Dimension(320, 40));
195 jScrollPaneHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 40));
196 jScrollPaneHelpText
.setLocation(new java
.awt
.Point(168, 62));
197 jScrollPaneHelpText
.setViewportView(getJTextAreaHelpText());
199 return jScrollPaneHelpText
;
203 * This method initializes jButtonOk
205 * @return javax.swing.JButton
208 private JButton
getJButtonOk() {
209 if (jButtonOk
== null) {
210 jButtonOk
= new JButton();
211 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 162, 90, 20));
212 jButtonOk
.setText("Ok");
213 jButtonOk
.addActionListener(this);
219 * This method initializes jButtonCancel
221 * @return javax.swing.JButton
224 private JButton
getJButtonCancel() {
225 if (jButtonCancel
== null) {
226 jButtonCancel
= new JButton();
227 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 162, 90, 20));
228 jButtonCancel
.setText("Cancel");
229 jButtonCancel
.addActionListener(this);
231 return jButtonCancel
;
234 public static void main(String
[] args
) {
239 * This method initializes this
242 private void init() {
243 this.setSize(505, 235);
244 this.setContentPane(getJScrollPane());
245 this.setTitle("System Tables");
247 this.setViewMode(false);
252 * This method initializes this Fill values to all fields if these values are
255 * @param inSystemTablesId
258 private void init(SystemTablesIdentification inSystemTablesId
, ModuleIdentification mid
) {
260 this.id
= inSystemTablesId
;
263 // Init arch with module's arch
265 this.jArchCheckBox
.setEnabledItems(wt
.getModuleArch(mid
));
268 // Get defined guids from dependent packages
270 Vector
<PackageIdentification
> vpid
= wt
.getPackageDependenciesOfModule(mid
);
271 if (vpid
.size() <= 0) {
274 "This module hasn't defined any package dependency, so there is no guid value can be added for system table");
277 // Init guids drop down list
280 .generateComboBoxByVector(iComboBoxGuidC_Name
,
281 wt
.getAllGuidDeclarationsFromPackages(vpid
, EnumerationData
.GUID_TYPE_EFI_SYSTEM_CONFIGURATION_TABLE
));
284 if (this.id
!= null) {
285 this.iComboBoxGuidC_Name
.setSelectedItem(id
.getName());
286 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
287 this.jTextAreaHelpText
.setText(id
.getHelp());
288 this.jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
289 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
294 * This is the override edit constructor
296 * @param inBootModesIdentification
300 public SystemTablesDlg(SystemTablesIdentification inSystemTablesIdentification
, IFrame iFrame
,
301 ModuleIdentification mid
) {
303 init(inSystemTablesIdentification
, mid
);
307 * Disable all components when the mode is view
310 * true - The view mode; false - The non-view mode
313 public void setViewMode(boolean isView
) {
315 this.jComboBoxUsage
.setEnabled(!isView
);
320 * This method initializes jContentPane
322 * @return javax.swing.JPanel jContentPane
325 private JPanel
getJContentPane() {
326 if (jContentPane
== null) {
327 jStarLabel1
= new StarLabel();
328 jStarLabel1
.setLocation(new java
.awt
.Point(2, 12));
329 jLabelEntry
= new JLabel();
330 jLabelEntry
.setText("Table's GUID C Name");
331 jLabelEntry
.setBounds(new java
.awt
.Rectangle(12, 12, 155, 20));
332 jStarLabel2
= new StarLabel();
333 jStarLabel2
.setLocation(new java
.awt
.Point(2, 37));
334 jLabelUsage
= new JLabel();
335 jLabelUsage
.setText("Usage");
336 jLabelUsage
.setBounds(new java
.awt
.Rectangle(12, 37, 155, 20));
337 jLabelHelpText
= new JLabel();
338 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(12, 62, 155, 20));
339 jLabelHelpText
.setText("Help Text");
340 jLabelFeatureFlag
= new JLabel();
341 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(12, 132, 155, 20));
342 jLabelFeatureFlag
.setText("Feature Flag Expression");
343 jLabelFeatureFlag
.setEnabled(false);
344 jLabelArch
= new JLabel();
345 jLabelArch
.setBounds(new java
.awt
.Rectangle(12, 107, 155, 20));
346 jLabelArch
.setText("Supported Architectures");
347 jArchCheckBox
= new ArchCheckBox();
348 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(168, 107, 320, 20));
349 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
351 jContentPane
= new JPanel();
352 jContentPane
.setLayout(null);
353 jContentPane
.setPreferredSize(new java
.awt
.Dimension(480, 180));
355 jContentPane
.add(jLabelEntry
, null);
356 jContentPane
.add(jLabelFeatureFlag
, null);
357 jContentPane
.add(getJTextFieldFeatureFlag(), null);
358 jContentPane
.add(getIComboBoxGuidC_Name(), null);
359 jContentPane
.add(jLabelArch
, null);
360 jContentPane
.add(jLabelUsage
, null);
361 jContentPane
.add(getJComboBoxUsage(), null);
363 jContentPane
.add(jStarLabel1
, null);
364 jContentPane
.add(jStarLabel2
, null);
366 jContentPane
.add(jLabelHelpText
, null);
367 jContentPane
.add(getJScrollPaneHelpText(), null);
368 jContentPane
.add(jArchCheckBox
, null);
369 jContentPane
.add(getJButtonOk(), null);
370 jContentPane
.add(getJButtonCancel(), null);
376 * This method initializes Usage type
379 private void initFrame() {
380 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVSystemTableUsage());
386 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
388 * Override actionPerformed to listen all actions
391 public void actionPerformed(ActionEvent arg0
) {
392 if (arg0
.getSource() == jButtonOk
) {
394 getCurrentSystemTables();
395 this.returnType
= DataType
.RETURN_TYPE_OK
;
396 this.setVisible(false);
400 if (arg0
.getSource() == jButtonCancel
) {
401 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
402 this.setVisible(false);
407 * Data validation for all fields
409 * @retval true - All datas are valid
410 * @retval false - At least one data is invalid
413 public boolean checkAdd() {
415 // Check if all fields have correct data types
421 if (this.iComboBoxGuidC_Name
.getSelectedItem() == null) {
422 Log
.wrn("Update Guids", "Please select one System Table Name");
429 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
430 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
431 Log
.wrn("Update System Tables", "Incorrect data type for Feature Flag");
439 private SystemTablesIdentification
getCurrentSystemTables() {
440 String arg0
= this.iComboBoxGuidC_Name
.getSelectedItem().toString();
441 String arg1
= this.jComboBoxUsage
.getSelectedItem().toString();
443 String arg2
= this.jTextFieldFeatureFlag
.getText();
444 Vector
<String
> arg3
= this.jArchCheckBox
.getSelectedItemsVector();
445 String arg4
= this.jTextAreaHelpText
.getText();
447 id
= new SystemTablesIdentification(arg0
, arg1
, arg2
, arg3
, arg4
);
451 public SystemTablesIdentification
getId() {
455 public void setId(SystemTablesIdentification id
) {