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
;
26 import javax
.swing
.JTextArea
;
28 import org
.tianocore
.frameworkwizard
.common
.DataType
;
29 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
30 import org
.tianocore
.frameworkwizard
.common
.EnumerationData
;
31 import org
.tianocore
.frameworkwizard
.common
.Log
;
32 import org
.tianocore
.frameworkwizard
.common
.Tools
;
33 import org
.tianocore
.frameworkwizard
.common
.ui
.ArchCheckBox
;
34 import org
.tianocore
.frameworkwizard
.common
.ui
.IDialog
;
35 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
36 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
37 import org
.tianocore
.frameworkwizard
.module
.Identifications
.Events
.EventsIdentification
;
38 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
41 * The class is used to create, update Event of MSA/MBD file It extends
44 * @since ModuleEditor 1.0
47 public class EventsDlg
extends IDialog
{
50 // / Define class Serial Version UID
52 private static final long serialVersionUID
= -4396143706422842331L;
55 // Define class members
57 private JPanel jContentPane
= null;
59 private JLabel jLabelEventType
= null;
61 private JLabel jLabelC_Name
= null;
63 private JComboBox jComboBoxGuidC_Name
= null;
65 private JLabel jLabelUsage
= null;
67 private JLabel jLabelGroup
= null;
69 private JComboBox jComboBoxUsage
= null;
71 private JComboBox jComboBoxEventGroup
= null;
73 private StarLabel jStarLabel1
= null;
75 private StarLabel jStarLabel2
= null;
77 private StarLabel jStarLabel3
= null;
79 private StarLabel jStarLabel4
= null;
81 private JComboBox jComboBoxEventsType
= null;
83 private JScrollPane jScrollPane
= null;
85 private JLabel jLabelArch
= null;
87 private JLabel jLabelHelpText
= null;
89 private JTextArea jTextAreaHelpText
= null;
91 private JScrollPane jScrollPaneHelpText
= null;
93 private JLabel jLabelFeatureFlag
= null;
95 private JTextField jTextFieldFeatureFlag
= null;
97 private ArchCheckBox jArchCheckBox
= null;
99 private JButton jButtonOk
= null;
101 private JButton jButtonCancel
= null;
106 private EventsIdentification id
= null;
108 private EnumerationData ed
= new EnumerationData();
110 private WorkspaceTools wt
= new WorkspaceTools();
113 * This method initializes jComboBoxType
115 * @return javax.swing.JComboBox jComboBoxType
118 private JComboBox
getJComboBoxEventsType() {
119 if (jComboBoxEventsType
== null) {
120 jComboBoxEventsType
= new JComboBox();
121 jComboBoxEventsType
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
122 jComboBoxEventsType
.setPreferredSize(new java
.awt
.Dimension(320, 20));
124 .setToolTipText("<html>Select CreateEvents if the Module has an event that is waiting to be signaled.<br>Select SignalEvents if the Module will signal all events in an event group.<br>NOTE: Signal events are named by GUID.</html>");
126 return jComboBoxEventsType
;
130 * This method initializes jTextFieldC_Name
132 * @return javax.swing.JTextField jTextFieldC_Name
135 private JComboBox
getJComboBoxGuidC_Name() {
136 if (jComboBoxGuidC_Name
== null) {
137 jComboBoxGuidC_Name
= new JComboBox();
138 jComboBoxGuidC_Name
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
139 jComboBoxGuidC_Name
.setPreferredSize(new java
.awt
.Dimension(320, 20));
140 jComboBoxGuidC_Name
.setToolTipText("Select the GUID C Name of the Event");
142 return jComboBoxGuidC_Name
;
146 * This method initializes jComboBoxEventsType
148 * @return javax.swing.JComboBox
150 private JComboBox
getJComboBoxEventGroup() {
151 if (jComboBoxEventGroup
== null) {
152 jComboBoxEventGroup
= new JComboBox();
153 jComboBoxEventGroup
.setBounds(new java
.awt
.Rectangle(160, 60, 320, 20));
154 jComboBoxEventGroup
.setPreferredSize(new java
.awt
.Dimension(320, 20));
156 .setToolTipText("Select Type of Event: Guid or Timer.");
159 return jComboBoxEventGroup
;
163 * This method initializes jComboBoxUsage
165 * @return javax.swing.JComboBox jComboBoxUsage
168 private JComboBox
getJComboBoxUsage() {
169 if (jComboBoxUsage
== null) {
170 jComboBoxUsage
= new JComboBox();
171 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(160, 85, 320, 20));
172 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
174 .setToolTipText("<html><table><tr><td colspan=2 align=center><b>Create Events</b></td></tr><tr><td>ALWAYS_CONSUMED</td><td>Module registers a notification function and REQUIRES that it be<br>executed for the module to fully function.</td></tr><tr><td>SOMETIMES_CONSUMED</td><td>Module registers a notification function and calls the function<br>when it is signaled</td></tr><tr><td colspan=2 align=center><b>Signal Events</b></td></tr><tr><td>ALWAYS_PRODUCED</td><td>Module will Always signal the event</td></tr><tr><td>SOMETIMES_PRODUCED</td><td>Module will sometimes signal the event</td></tr></table></html>");
176 return jComboBoxUsage
;
180 * This method initializes jScrollPane
182 * @return javax.swing.JScrollPane
184 private JScrollPane
getJScrollPane() {
185 if (jScrollPane
== null) {
186 jScrollPane
= new JScrollPane();
187 jScrollPane
.setViewportView(getJContentPane());
193 * This method initializes jTextFieldFeatureFlag
195 * @return javax.swing.JTextField
197 private JTextField
getJTextFieldFeatureFlag() {
198 if (jTextFieldFeatureFlag
== null) {
199 jTextFieldFeatureFlag
= new JTextField();
200 jTextFieldFeatureFlag
201 .setBounds(new java
.awt
.Rectangle(160, 155, 320, 20));
202 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
203 jTextFieldFeatureFlag
204 .setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");
206 return jTextFieldFeatureFlag
;
210 * This method initializes jTextAreaHelpText
212 * @return javax.swing.JTextArea
215 private JTextArea
getJTextAreaHelpText() {
216 if (jTextAreaHelpText
== null) {
217 jTextAreaHelpText
= new JTextArea();
218 jTextAreaHelpText
.setLineWrap(true);
219 jTextAreaHelpText
.setWrapStyleWord(true);
221 return jTextAreaHelpText
;
225 * This method initializes jScrollPaneHelpText
227 * @return javax.swing.JScrollPane
230 private JScrollPane
getJScrollPaneHelpText() {
231 if (jScrollPaneHelpText
== null) {
232 jScrollPaneHelpText
= new JScrollPane();
233 jScrollPaneHelpText
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
234 jScrollPaneHelpText
.setSize(new java
.awt
.Dimension(320,40));
235 jScrollPaneHelpText
.setPreferredSize(new java
.awt
.Dimension(320,40));
236 jScrollPaneHelpText
.setLocation(new java
.awt
.Point(160,110));
237 jScrollPaneHelpText
.setViewportView(getJTextAreaHelpText());
239 return jScrollPaneHelpText
;
243 * This method initializes jButtonOk
245 * @return javax.swing.JButton
248 private JButton
getJButtonOk() {
249 if (jButtonOk
== null) {
250 jButtonOk
= new JButton();
251 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 202, 90, 20));
252 jButtonOk
.setText("Ok");
253 jButtonOk
.addActionListener(this);
259 * This method initializes jButtonCancel
261 * @return javax.swing.JButton
264 private JButton
getJButtonCancel() {
265 if (jButtonCancel
== null) {
266 jButtonCancel
= new JButton();
267 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 202, 90, 20));
268 jButtonCancel
.setText("Cancel");
269 jButtonCancel
.addActionListener(this);
271 return jButtonCancel
;
274 public static void main(String
[] args
) {
279 * This method initializes this
282 private void init() {
283 this.setSize(500, 275);
284 this.setContentPane(getJScrollPane());
285 this.setTitle("Events");
287 this.setViewMode(false);
292 * This method initializes this Fill values to all fields if these values are
298 private void init(EventsIdentification inEventsId
) {
300 this.id
= inEventsId
;
302 if (this.id
!= null) {
303 this.jComboBoxGuidC_Name
.setSelectedItem(id
.getName());
304 this.jComboBoxEventsType
.setSelectedItem(id
.getType());
305 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
306 this.jTextAreaHelpText
.setText(id
.getHelp());
308 jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
309 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
310 this.jComboBoxEventGroup
.setSelectedItem(id
.getGroup());
315 * This is the override edit constructor
317 * @param inEventsIdentification
321 public EventsDlg(EventsIdentification inEventsIdentification
, IFrame iFrame
) {
323 init(inEventsIdentification
);
327 * Disable all components when the mode is view
330 * true - The view mode; false - The non-view mode
333 public void setViewMode(boolean isView
) {
335 this.jComboBoxGuidC_Name
.setEnabled(!isView
);
336 this.jComboBoxUsage
.setEnabled(!isView
);
341 * This method initializes jContentPane
343 * @return javax.swing.JPanel jContentPane
346 private JPanel
getJContentPane() {
347 if (jContentPane
== null) {
348 jStarLabel1
= new StarLabel();
349 jStarLabel1
.setLocation(new java
.awt
.Point(2, 10));
350 jLabelEventType
= new JLabel();
351 jLabelEventType
.setText("Type");
352 jLabelEventType
.setBounds(new java
.awt
.Rectangle(15, 10, 145, 20));
354 jStarLabel2
= new StarLabel();
355 jStarLabel2
.setLocation(new java
.awt
.Point(2, 35));
356 jLabelC_Name
= new JLabel();
357 jLabelC_Name
.setText("Guid C Name");
358 jLabelC_Name
.setBounds(new java
.awt
.Rectangle(15, 35, 145, 20));
360 jStarLabel3
= new StarLabel();
361 jStarLabel3
.setLocation(new java
.awt
.Point(2, 60));
362 jLabelGroup
= new JLabel();
363 jLabelGroup
.setText("Event Type");
364 jLabelGroup
.setBounds(new java
.awt
.Rectangle(15, 60, 145, 20));
366 jStarLabel4
= new StarLabel();
367 jStarLabel4
.setLocation(new java
.awt
.Point(2, 85));
368 jLabelUsage
= new JLabel();
369 jLabelUsage
.setText("Usage");
370 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 85, 140, 20));
372 jLabelHelpText
= new JLabel();
373 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(15, 110, 145, 20));
374 jLabelHelpText
.setText("Help Text");
376 jLabelFeatureFlag
= new JLabel();
377 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(15, 155, 145, 20));
378 jLabelFeatureFlag
.setText("Feature Flag");
380 jLabelArch
= new JLabel();
381 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 180, 145, 20));
382 jLabelArch
.setText("Arch");
383 jArchCheckBox
= new ArchCheckBox();
384 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(160, 180, 320, 20));
385 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
387 jContentPane
= new JPanel();
388 jContentPane
.setLayout(null);
389 jContentPane
.setPreferredSize(new java
.awt
.Dimension(485, 230));
391 jContentPane
.add(jStarLabel1
, null);
392 jContentPane
.add(jLabelEventType
, null);
393 jContentPane
.add(getJComboBoxEventsType(), null);
394 jContentPane
.add(jStarLabel2
, null);
395 jContentPane
.add(jLabelC_Name
, null);
396 jContentPane
.add(getJComboBoxGuidC_Name(), null);
397 jContentPane
.add(jStarLabel3
, null);
398 jContentPane
.add(jLabelGroup
, null);
399 jContentPane
.add(getJComboBoxEventGroup(), null);
400 jContentPane
.add(jStarLabel4
, null);
401 jContentPane
.add(jLabelUsage
, null);
402 jContentPane
.add(getJComboBoxUsage(), null);
403 jContentPane
.add(jLabelHelpText
, null);
404 jContentPane
.add(getJScrollPaneHelpText(), null);
405 jContentPane
.add(jLabelFeatureFlag
, null);
406 jContentPane
.add(getJTextFieldFeatureFlag(), null);
407 jContentPane
.add(jLabelArch
, null);
408 jContentPane
.add(jArchCheckBox
, null);
409 jContentPane
.add(getJButtonOk(), null);
410 jContentPane
.add(getJButtonCancel(), null);
417 * This method initializes events groups and usage type
420 private void initFrame() {
421 Tools
.generateComboBoxByVector(jComboBoxEventsType
, ed
.getVEventType());
422 Tools
.generateComboBoxByVector(jComboBoxEventGroup
, ed
.getVEventGroup());
423 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVEventUsage());
424 Tools
.generateComboBoxByVector(jComboBoxGuidC_Name
, wt
425 .getAllGuidDeclarationsFromWorkspace());
431 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
433 * Override actionPerformed to listen all actions
436 public void actionPerformed(ActionEvent arg0
) {
437 if (arg0
.getSource() == jButtonOk
) {
440 this.returnType
= DataType
.RETURN_TYPE_OK
;
441 this.setVisible(false);
445 if (arg0
.getSource() == jButtonCancel
) {
446 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
447 this.setVisible(false);
452 * Data validation for all fields
454 * @retval true - All datas are valid
455 * @retval false - At least one data is invalid
458 public boolean checkAdd() {
460 // Check if all fields have correct data types
466 if (isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
467 Log
.wrn("Update Events", "Event Name couldn't be empty");
471 if (!isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
472 if (!DataValidation
.isC_NameType(this.jComboBoxGuidC_Name
473 .getSelectedItem().toString())) {
474 Log
.wrn("Update Events", "Incorrect data type for Event Name");
482 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
483 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
484 Log
.wrn("Update Events", "Incorrect data type for Feature Flag");
492 private EventsIdentification
getCurrentEvents() {
493 String arg0
= this.jComboBoxGuidC_Name
.getSelectedItem().toString();
494 String arg1
= this.jComboBoxEventsType
.getSelectedItem().toString();
495 String arg2
= this.jComboBoxUsage
.getSelectedItem().toString();
497 String arg3
= this.jTextFieldFeatureFlag
.getText();
498 Vector
<String
> arg4
= this.jArchCheckBox
.getSelectedItemsVector();
499 String arg5
= this.jTextAreaHelpText
.getText();
500 String arg6
= this.jComboBoxEventGroup
.getSelectedItem().toString();
501 id
= new EventsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
505 public EventsIdentification
getId() {
509 public void setId(EventsIdentification id
) {