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
.IDialog
;
36 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
37 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
38 import org
.tianocore
.frameworkwizard
.module
.Identifications
.SystemTables
.SystemTablesIdentification
;
39 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
42 * The class is used to create, update SystemTable of MSA/MBD file
48 public class SystemTablesDlg
extends IDialog
{
51 // / Define class Serial Version UID
53 private static final long serialVersionUID
= 7488769180379442276L;
56 // Define class members
58 private JPanel jContentPane
= null;
60 private JLabel jLabelEntry
= null;
62 private JLabel jLabelUsage
= null;
64 private JComboBox jComboBoxUsage
= null;
66 private StarLabel jStarLabel1
= null;
68 private StarLabel jStarLabel2
= null;
70 private JComboBox jComboBoxGuidC_Name
= null;
72 private JLabel jLabelFeatureFlag
= null;
74 private JTextField jTextFieldFeatureFlag
= null;
76 private JLabel jLabelArch
= null;
78 private JScrollPane jScrollPane
= null;
80 private JLabel jLabelHelpText
= null;
82 private JTextArea jTextAreaHelpText
= null;
84 private JScrollPane jScrollPaneHelpText
= null;
86 private ArchCheckBox jArchCheckBox
= null;
88 private JButton jButtonOk
= null;
90 private JButton jButtonCancel
= null;
95 private SystemTablesIdentification id
= null;
97 private EnumerationData ed
= new EnumerationData();
99 private WorkspaceTools wt
= new WorkspaceTools();
102 * This method initializes jComboBoxGuidC_Name
104 * @return javax.swing.JComboBox jComboBoxGuidC_Name
107 private JComboBox
getJComboBoxGuidC_Name() {
108 if (jComboBoxGuidC_Name
== null) {
109 jComboBoxGuidC_Name
= new JComboBox();
110 jComboBoxGuidC_Name
.setBounds(new java
.awt
.Rectangle(168, 12, 320, 20));
111 jComboBoxGuidC_Name
.setPreferredSize(new java
.awt
.Dimension(320, 20));
112 jComboBoxGuidC_Name
.setToolTipText("Select the GUID C Name of the System Table");
114 return jComboBoxGuidC_Name
;
118 * This method initializes jComboBoxUsage
120 * @return javax.swing.JComboBox jComboBoxUsage
123 private JComboBox
getJComboBoxUsage() {
124 if (jComboBoxUsage
== null) {
125 jComboBoxUsage
= new JComboBox();
126 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(168, 37, 320, 20));
127 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
129 .setToolTipText("<html><table>"
130 + "<tr><td>ALWAYS_CONSUMED</td><td>Module requires a GUIDed entry in the system table</td></tr>"
131 + "<tr><td>SOMETIMES_CONSUMED</td><td>Module consumes a GUIDed entry in the system<br>table if it is present</td>"
132 + "</tr><tr><td>ALWAYS_PRODUCED</td><td>Module always produces a GUIDed entry in the system table</td></tr>"
133 + "<tr><td>SOMETIMES_PRODUCED</td><td>Module produces a GUIDed entry in the system table<br>for some of its execution flows.</td></tr>"
134 + "</table></html>");
136 return jComboBoxUsage
;
140 * This method initializes jTextFieldFeatureFlag
142 * @return javax.swing.JTextField
144 private JTextField
getJTextFieldFeatureFlag() {
145 if (jTextFieldFeatureFlag
== null) {
146 jTextFieldFeatureFlag
= new JTextField();
147 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(168, 107, 320, 20));
148 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
149 jTextFieldFeatureFlag
.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");
151 return jTextFieldFeatureFlag
;
155 * This method initializes jScrollPane
157 * @return javax.swing.JScrollPane
159 private JScrollPane
getJScrollPane() {
160 if (jScrollPane
== null) {
161 jScrollPane
= new JScrollPane();
162 jScrollPane
.setViewportView(getJContentPane());
168 * This method initializes jTextAreaHelpText
170 * @return javax.swing.JTextArea
173 private JTextArea
getJTextAreaHelpText() {
174 if (jTextAreaHelpText
== null) {
175 jTextAreaHelpText
= new JTextArea();
176 jTextAreaHelpText
.setLineWrap(true);
177 jTextAreaHelpText
.setWrapStyleWord(true);
179 return jTextAreaHelpText
;
183 * This method initializes jScrollPaneHelpText
185 * @returns javax.swing.JScrollPane jScrollPaneHelpText
187 private JScrollPane
getJScrollPaneHelpText() {
188 if (jScrollPaneHelpText
== null) {
189 jScrollPaneHelpText
= new JScrollPane();
190 jScrollPaneHelpText
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
191 jScrollPaneHelpText
.setSize(new java
.awt
.Dimension(320, 40));
192 jScrollPaneHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 40));
193 jScrollPaneHelpText
.setLocation(new java
.awt
.Point(168, 62));
194 jScrollPaneHelpText
.setViewportView(getJTextAreaHelpText());
196 return jScrollPaneHelpText
;
200 * This method initializes jButtonOk
202 * @return javax.swing.JButton
205 private JButton
getJButtonOk() {
206 if (jButtonOk
== null) {
207 jButtonOk
= new JButton();
208 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 162, 90, 20));
209 jButtonOk
.setText("Ok");
210 jButtonOk
.addActionListener(this);
216 * This method initializes jButtonCancel
218 * @return javax.swing.JButton
221 private JButton
getJButtonCancel() {
222 if (jButtonCancel
== null) {
223 jButtonCancel
= new JButton();
224 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 162, 90, 20));
225 jButtonCancel
.setText("Cancel");
226 jButtonCancel
.addActionListener(this);
228 return jButtonCancel
;
231 public static void main(String
[] args
) {
236 * This method initializes this
239 private void init() {
240 this.setSize(505, 235);
241 this.setContentPane(getJScrollPane());
242 this.setTitle("System Tables");
244 this.setViewMode(false);
249 * This method initializes this Fill values to all fields if these values are
252 * @param inSystemTablesId
255 private void init(SystemTablesIdentification inSystemTablesId
) {
257 this.id
= inSystemTablesId
;
259 if (this.id
!= null) {
260 this.jComboBoxGuidC_Name
.setSelectedItem(id
.getName());
261 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
262 this.jTextAreaHelpText
.setText(id
.getHelp());
263 this.jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
264 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
269 * This is the override edit constructor
271 * @param inBootModesIdentification
275 public SystemTablesDlg(SystemTablesIdentification inSystemTablesIdentification
, IFrame iFrame
) {
277 init(inSystemTablesIdentification
);
281 * Disable all components when the mode is view
284 * true - The view mode; false - The non-view mode
287 public void setViewMode(boolean isView
) {
289 this.jComboBoxUsage
.setEnabled(!isView
);
294 * This method initializes jContentPane
296 * @return javax.swing.JPanel jContentPane
299 private JPanel
getJContentPane() {
300 if (jContentPane
== null) {
301 jStarLabel1
= new StarLabel();
302 jStarLabel1
.setLocation(new java
.awt
.Point(2, 12));
303 jLabelEntry
= new JLabel();
304 jLabelEntry
.setText("Table's GUID C Name");
305 jLabelEntry
.setBounds(new java
.awt
.Rectangle(12, 12, 155, 20));
306 jStarLabel2
= new StarLabel();
307 jStarLabel2
.setLocation(new java
.awt
.Point(2, 37));
308 jLabelUsage
= new JLabel();
309 jLabelUsage
.setText("Usage");
310 jLabelUsage
.setBounds(new java
.awt
.Rectangle(12, 37, 155, 20));
311 jLabelHelpText
= new JLabel();
312 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(12, 62, 155, 20));
313 jLabelHelpText
.setText("Help Text");
314 jLabelFeatureFlag
= new JLabel();
315 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(12, 107, 155, 20));
316 jLabelFeatureFlag
.setText("Feature Flag Expression");
317 jLabelArch
= new JLabel();
318 jLabelArch
.setBounds(new java
.awt
.Rectangle(12, 130, 155, 20));
319 jLabelArch
.setText("Supported Architectures");
320 jArchCheckBox
= new ArchCheckBox();
321 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(168, 130, 320, 20));
322 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
324 jContentPane
= new JPanel();
325 jContentPane
.setLayout(null);
326 jContentPane
.setPreferredSize(new java
.awt
.Dimension(480, 180));
328 jContentPane
.add(jLabelEntry
, null);
329 jContentPane
.add(jLabelFeatureFlag
, null);
330 jContentPane
.add(getJTextFieldFeatureFlag(), null);
331 jContentPane
.add(getJComboBoxGuidC_Name(), null);
332 jContentPane
.add(jLabelArch
, null);
333 jContentPane
.add(jLabelUsage
, null);
334 jContentPane
.add(getJComboBoxUsage(), null);
336 jContentPane
.add(jStarLabel1
, null);
337 jContentPane
.add(jStarLabel2
, null);
339 jContentPane
.add(jLabelHelpText
, null);
340 jContentPane
.add(getJScrollPaneHelpText(), null);
341 jContentPane
.add(jArchCheckBox
, null);
342 jContentPane
.add(getJButtonOk(), null);
343 jContentPane
.add(getJButtonCancel(), null);
349 * This method initializes Usage type
352 private void initFrame() {
353 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVSystemTableUsage());
354 Tools
.generateComboBoxByVector(jComboBoxGuidC_Name
, wt
.getAllGuidDeclarationsFromWorkspace());
360 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
362 * Override actionPerformed to listen all actions
365 public void actionPerformed(ActionEvent arg0
) {
366 if (arg0
.getSource() == jButtonOk
) {
368 getCurrentSystemTables();
369 this.returnType
= DataType
.RETURN_TYPE_OK
;
370 this.setVisible(false);
374 if (arg0
.getSource() == jButtonCancel
) {
375 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
376 this.setVisible(false);
381 * Data validation for all fields
383 * @retval true - All datas are valid
384 * @retval false - At least one data is invalid
387 public boolean checkAdd() {
389 // Check if all fields have correct data types
395 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
396 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
397 Log
.wrn("Update System Tables", "Incorrect data type for Feature Flag");
405 private SystemTablesIdentification
getCurrentSystemTables() {
406 String arg0
= this.jComboBoxGuidC_Name
.getSelectedItem().toString();
407 String arg1
= this.jComboBoxUsage
.getSelectedItem().toString();
409 String arg2
= this.jTextFieldFeatureFlag
.getText();
410 Vector
<String
> arg3
= this.jArchCheckBox
.getSelectedItemsVector();
411 String arg4
= this.jTextAreaHelpText
.getText();
413 id
= new SystemTablesIdentification(arg0
, arg1
, arg2
, arg3
, arg4
);
417 public SystemTablesIdentification
getId() {
421 public void setId(SystemTablesIdentification id
) {