3 The file is used to create, update Event 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
.Events
.EventsIdentification
;
37 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
40 The class is used to create, update Event of MSA/MBD file
41 It extends IInternalFrame
43 @since ModuleEditor 1.0
46 public class EventsDlg
extends IDialog
{
49 /// Define class Serial Version UID
51 private static final long serialVersionUID
= -4396143706422842331L;
54 //Define class members
56 private JPanel jContentPane
= null;
58 private JLabel jLabelEventType
= null;
60 private JLabel jLabelC_Name
= null;
62 private JComboBox jComboBoxGuidC_Name
= null;
64 private JLabel jLabelUsage
= null;
66 private JComboBox jComboBoxUsage
= null;
68 private StarLabel jStarLabel1
= null;
70 private StarLabel jStarLabel2
= null;
72 private JComboBox jComboBoxEventsType
= null;
74 private JScrollPane jScrollPane
= null;
76 private JLabel jLabelArch
= null;
78 private JLabel jLabelHelpText
= null;
80 private JTextField jTextFieldHelpText
= null;
82 private JLabel jLabelFeatureFlag
= null;
84 private JTextField jTextFieldFeatureFlag
= null;
86 private ArchCheckBox jArchCheckBox
= null;
88 private JButton jButtonOk
= null;
90 private JButton jButtonCancel
= null;
95 private EventsIdentification id
= null;
97 private EnumerationData ed
= new EnumerationData();
99 private WorkspaceTools wt
= new WorkspaceTools();
102 This method initializes jTextFieldC_Name
104 @return javax.swing.JTextField jTextFieldC_Name
107 private JComboBox
getJComboBoxGuidC_Name() {
108 if (jComboBoxGuidC_Name
== null) {
109 jComboBoxGuidC_Name
= new JComboBox();
110 jComboBoxGuidC_Name
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
111 jComboBoxGuidC_Name
.setPreferredSize(new java
.awt
.Dimension(320, 20));
112 jComboBoxGuidC_Name
.setToolTipText("Select the GUID C Name of the Event");
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(160, 60, 320, 20));
127 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
129 return jComboBoxUsage
;
133 * This method initializes jComboBoxEventsType
135 * @return javax.swing.JComboBox
137 private JComboBox
getJComboBoxEventsType() {
138 if (jComboBoxEventsType
== null) {
139 jComboBoxEventsType
= new JComboBox();
140 jComboBoxEventsType
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
141 jComboBoxEventsType
.setPreferredSize(new java
.awt
.Dimension(320, 20));
143 .setToolTipText("Select Create event if the Module has an event that is waiting to be signaled. Select Signal if the Module will signal all events in an event group. Signal Event The events are named by GUID.");
145 return jComboBoxEventsType
;
149 This method initializes jScrollPane
151 @return javax.swing.JScrollPane
153 private JScrollPane
getJScrollPane() {
154 if (jScrollPane
== null) {
155 jScrollPane
= new JScrollPane();
156 jScrollPane
.setViewportView(getJContentPane());
162 * This method initializes jTextFieldFeatureFlag
164 * @return javax.swing.JTextField
166 private JTextField
getJTextFieldFeatureFlag() {
167 if (jTextFieldFeatureFlag
== null) {
168 jTextFieldFeatureFlag
= new JTextField();
169 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(160, 110, 320, 20));
170 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
172 return jTextFieldFeatureFlag
;
176 This method initializes jTextFieldHelpText
178 @return javax.swing.JTextField
181 private JTextField
getJTextFieldHelpText() {
182 if (jTextFieldHelpText
== null) {
183 jTextFieldHelpText
= new JTextField();
184 jTextFieldHelpText
.setBounds(new java
.awt
.Rectangle(160, 85, 320, 20));
185 jTextFieldHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 20));
187 return jTextFieldHelpText
;
191 This method initializes jButtonOk
193 @return javax.swing.JButton
196 private JButton
getJButtonOk() {
197 if (jButtonOk
== null) {
198 jButtonOk
= new JButton();
199 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 165, 90, 20));
200 jButtonOk
.setText("Ok");
201 jButtonOk
.addActionListener(this);
207 This method initializes jButtonCancel
209 @return javax.swing.JButton
212 private JButton
getJButtonCancel() {
213 if (jButtonCancel
== null) {
214 jButtonCancel
= new JButton();
215 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 165, 90, 20));
216 jButtonCancel
.setText("Cancel");
217 jButtonCancel
.addActionListener(this);
219 return jButtonCancel
;
222 public static void main(String
[] args
) {
227 This method initializes this
230 private void init() {
231 this.setSize(500, 225);
232 this.setContentPane(getJScrollPane());
233 this.setTitle("Events");
235 this.setViewMode(false);
240 This method initializes this
241 Fill values to all fields if these values are not empty
246 private void init(EventsIdentification inEventsId
) {
248 this.id
= inEventsId
;
250 if (this.id
!= null) {
251 this.jComboBoxGuidC_Name
.setSelectedItem(id
.getName());
252 this.jComboBoxEventsType
.setSelectedItem(id
.getType());
253 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
254 this.jTextFieldHelpText
.setText(id
.getHelp());
256 jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
257 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
262 This is the override edit constructor
264 @param inEventsIdentification
268 public EventsDlg(EventsIdentification inEventsIdentification
, IFrame iFrame
) {
270 init(inEventsIdentification
);
274 Disable all components when the mode is view
276 @param isView true - The view mode; false - The non-view mode
279 public void setViewMode(boolean isView
) {
281 this.jComboBoxGuidC_Name
.setEnabled(!isView
);
282 this.jComboBoxUsage
.setEnabled(!isView
);
287 This method initializes jContentPane
289 @return javax.swing.JPanel jContentPane
292 private JPanel
getJContentPane() {
293 if (jContentPane
== null) {
294 jArchCheckBox
= new ArchCheckBox();
295 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(160, 135, 320, 20));
296 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
297 jLabelFeatureFlag
= new JLabel();
298 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(15, 110, 140, 20));
299 jLabelFeatureFlag
.setText("Feature Flag");
300 jLabelArch
= new JLabel();
301 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 135, 140, 20));
302 jLabelArch
.setText("Arch");
303 jLabelUsage
= new JLabel();
304 jLabelUsage
.setText("Usage");
305 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 60, 140, 20));
306 jLabelC_Name
= new JLabel();
307 jLabelC_Name
.setText("Guid C_Name");
308 jLabelC_Name
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
309 jLabelEventType
= new JLabel();
310 jLabelEventType
.setText("Event Type");
311 jLabelEventType
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
312 jLabelHelpText
= new JLabel();
313 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(14, 85, 140, 20));
314 jLabelHelpText
.setText("Help Text");
316 jContentPane
= new JPanel();
317 jContentPane
.setLayout(null);
318 jContentPane
.setPreferredSize(new java
.awt
.Dimension(490, 190));
320 jContentPane
.add(jLabelEventType
, null);
321 jContentPane
.add(jLabelC_Name
, null);
322 jContentPane
.add(getJComboBoxGuidC_Name(), null);
323 jContentPane
.add(jLabelUsage
, null);
324 jContentPane
.add(getJComboBoxUsage(), null);
325 jStarLabel1
= new StarLabel();
326 jStarLabel1
.setBounds(new java
.awt
.Rectangle(0, 10, 10, 20));
327 jStarLabel2
= new StarLabel();
328 jStarLabel2
.setBounds(new java
.awt
.Rectangle(0, 35, 10, 20));
330 jContentPane
.add(jStarLabel1
, null);
331 jContentPane
.add(jStarLabel2
, null);
332 jContentPane
.add(getJComboBoxEventsType(), null);
334 jContentPane
.add(jLabelArch
, null);
335 jContentPane
.add(jLabelFeatureFlag
, null);
336 jContentPane
.add(getJTextFieldFeatureFlag(), null);
337 jContentPane
.add(jLabelHelpText
, null);
338 jContentPane
.add(getJTextFieldHelpText(), null);
339 jContentPane
.add(jArchCheckBox
, null);
340 jContentPane
.add(getJButtonOk(), null);
341 jContentPane
.add(getJButtonCancel(), null);
347 This method initializes events groups and usage type
350 private void initFrame() {
351 Tools
.generateComboBoxByVector(jComboBoxEventsType
, ed
.getVEventType());
352 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVEventUsage());
353 Tools
.generateComboBoxByVector(jComboBoxGuidC_Name
, wt
.getAllGuidDeclarationsFromWorkspace());
357 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
359 * Override actionPerformed to listen all actions
362 public void actionPerformed(ActionEvent arg0
) {
363 if (arg0
.getSource() == jButtonOk
) {
366 this.returnType
= DataType
.RETURN_TYPE_OK
;
367 this.setVisible(false);
371 if (arg0
.getSource() == jButtonCancel
) {
372 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
373 this.setVisible(false);
378 Data validation for all fields
380 @retval true - All datas are valid
381 @retval false - At least one data is invalid
384 public boolean checkAdd() {
386 // Check if all fields have correct data types
392 if (isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
393 Log
.err("Event Name couldn't be empty");
397 if (!isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
398 if (!DataValidation
.isC_NameType(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
399 Log
.err("Incorrect data type for Event Name");
407 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
408 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
409 Log
.err("Incorrect data type for Feature Flag");
417 private EventsIdentification
getCurrentEvents() {
418 String arg0
= this.jComboBoxGuidC_Name
.getSelectedItem().toString();
419 String arg1
= this.jComboBoxEventsType
.getSelectedItem().toString();
420 String arg2
= this.jComboBoxUsage
.getSelectedItem().toString();
422 String arg3
= this.jTextFieldFeatureFlag
.getText();
423 Vector
<String
> arg4
= this.jArchCheckBox
.getSelectedItemsVector();
424 String arg5
= this.jTextFieldHelpText
.getText();
425 id
= new EventsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
);
429 public EventsIdentification
getId() {
433 public void setId(EventsIdentification id
) {