3 The file is used to create, update Events section of the MSA 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 Events section of the MSA file
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(168, 12, 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>"
125 + "Select SignalEvents if the Module will signal all events in an event group.<br>"
126 + "NOTE: Signal events are named by GUID.</html>");
128 return jComboBoxEventsType
;
132 * This method initializes jTextFieldC_Name
134 * @return javax.swing.JTextField jTextFieldC_Name
137 private JComboBox
getJComboBoxGuidC_Name() {
138 if (jComboBoxGuidC_Name
== null) {
139 jComboBoxGuidC_Name
= new JComboBox();
140 jComboBoxGuidC_Name
.setBounds(new java
.awt
.Rectangle(168, 37, 320, 20));
141 jComboBoxGuidC_Name
.setPreferredSize(new java
.awt
.Dimension(320, 20));
142 jComboBoxGuidC_Name
.setToolTipText("Select the GUID C Name of the Event");
144 return jComboBoxGuidC_Name
;
148 * This method initializes jComboBoxEventsType
150 * @return javax.swing.JComboBox
152 private JComboBox
getJComboBoxEventGroup() {
153 if (jComboBoxEventGroup
== null) {
154 jComboBoxEventGroup
= new JComboBox();
155 jComboBoxEventGroup
.setBounds(new java
.awt
.Rectangle(168, 62, 320, 20));
156 jComboBoxEventGroup
.setPreferredSize(new java
.awt
.Dimension(320, 20));
157 jComboBoxEventGroup
.setToolTipText("Select Type of Event: Guid or Timer.");
160 return jComboBoxEventGroup
;
164 * This method initializes jComboBoxUsage
166 * @return javax.swing.JComboBox jComboBoxUsage
169 private JComboBox
getJComboBoxUsage() {
170 if (jComboBoxUsage
== null) {
171 jComboBoxUsage
= new JComboBox();
172 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(168, 87, 320, 20));
173 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
175 .setToolTipText("<html><table>"
176 + "<tr><td colspan=2 align=center><b>Create Events</b></td></tr>"
177 + "<tr><td>ALWAYS_CONSUMED</td><td>Module registers a notification function and REQUIRES that it be<br>"
178 + "executed for the module to fully function.</td></tr>"
179 + "<tr><td>SOMETIMES_CONSUMED</td><td>Module registers a notification function and calls the function<br>"
180 + "when it is signaled</td></tr><tr><td colspan=2 align=center><b>Signal Events</b></td></tr>"
181 + "<tr><td>ALWAYS_PRODUCED</td><td>Module will Always signal the event</td></tr>"
182 + "<tr><td>SOMETIMES_PRODUCED</td><td>Module will sometimes signal the event</td></tr>"
183 + "</table></html>");
185 return jComboBoxUsage
;
189 * This method initializes jScrollPane
191 * @return javax.swing.JScrollPane
193 private JScrollPane
getJScrollPane() {
194 if (jScrollPane
== null) {
195 jScrollPane
= new JScrollPane();
196 jScrollPane
.setViewportView(getJContentPane());
202 * This method initializes jTextFieldFeatureFlag
204 * @return javax.swing.JTextField
206 private JTextField
getJTextFieldFeatureFlag() {
207 if (jTextFieldFeatureFlag
== null) {
208 jTextFieldFeatureFlag
= new JTextField();
209 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(168, 182, 320, 20));
210 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
211 jTextFieldFeatureFlag
.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");
212 jTextFieldFeatureFlag
.setEnabled(false);
214 return jTextFieldFeatureFlag
;
218 * This method initializes jTextAreaHelpText
220 * @return javax.swing.JTextArea
223 private JTextArea
getJTextAreaHelpText() {
224 if (jTextAreaHelpText
== null) {
225 jTextAreaHelpText
= new JTextArea();
226 jTextAreaHelpText
.setLineWrap(true);
227 jTextAreaHelpText
.setWrapStyleWord(true);
229 return jTextAreaHelpText
;
233 * This method initializes jScrollPaneHelpText
235 * @return javax.swing.JScrollPane
238 private JScrollPane
getJScrollPaneHelpText() {
239 if (jScrollPaneHelpText
== null) {
240 jScrollPaneHelpText
= new JScrollPane();
241 jScrollPaneHelpText
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
242 jScrollPaneHelpText
.setSize(new java
.awt
.Dimension(320, 40));
243 jScrollPaneHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 40));
244 jScrollPaneHelpText
.setLocation(new java
.awt
.Point(168, 112));
245 jScrollPaneHelpText
.setViewportView(getJTextAreaHelpText());
247 return jScrollPaneHelpText
;
251 * This method initializes jButtonOk
253 * @return javax.swing.JButton
256 private JButton
getJButtonOk() {
257 if (jButtonOk
== null) {
258 jButtonOk
= new JButton();
259 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 212, 90, 20));
260 jButtonOk
.setText("Ok");
261 jButtonOk
.addActionListener(this);
267 * This method initializes jButtonCancel
269 * @return javax.swing.JButton
272 private JButton
getJButtonCancel() {
273 if (jButtonCancel
== null) {
274 jButtonCancel
= new JButton();
275 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 212, 90, 20));
276 jButtonCancel
.setText("Cancel");
277 jButtonCancel
.addActionListener(this);
279 return jButtonCancel
;
282 public static void main(String
[] args
) {
287 * This method initializes this
290 private void init() {
291 this.setSize(505, 280);
292 this.setContentPane(getJScrollPane());
293 this.setTitle("Events");
295 this.setViewMode(false);
300 * This method initializes this Fill values to all fields if these values are
306 private void init(EventsIdentification inEventsId
) {
308 this.id
= inEventsId
;
310 if (this.id
!= null) {
311 this.jComboBoxGuidC_Name
.setSelectedItem(id
.getName());
312 this.jComboBoxEventsType
.setSelectedItem(id
.getType());
313 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
314 this.jTextAreaHelpText
.setText(id
.getHelp());
316 jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
317 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
318 this.jComboBoxEventGroup
.setSelectedItem(id
.getGroup());
323 * This is the override edit constructor
325 * @param inEventsIdentification
329 public EventsDlg(EventsIdentification inEventsIdentification
, IFrame iFrame
) {
331 init(inEventsIdentification
);
335 * Disable all components when the mode is view
338 * true - The view mode; false - The non-view mode
341 public void setViewMode(boolean isView
) {
343 this.jComboBoxGuidC_Name
.setEnabled(!isView
);
344 this.jComboBoxUsage
.setEnabled(!isView
);
349 * This method initializes jContentPane
351 * @return javax.swing.JPanel jContentPane
354 private JPanel
getJContentPane() {
355 if (jContentPane
== null) {
356 jStarLabel1
= new StarLabel();
357 jStarLabel1
.setLocation(new java
.awt
.Point(2, 12));
358 jLabelEventType
= new JLabel();
359 jLabelEventType
.setText("Select Event Type");
360 jLabelEventType
.setBounds(new java
.awt
.Rectangle(12, 12, 168, 20));
362 jStarLabel2
= new StarLabel();
363 jStarLabel2
.setLocation(new java
.awt
.Point(2, 37));
364 jLabelC_Name
= new JLabel();
365 jLabelC_Name
.setText("Guid C Name");
366 jLabelC_Name
.setBounds(new java
.awt
.Rectangle(12, 37, 168, 20));
368 jStarLabel3
= new StarLabel();
369 jStarLabel3
.setLocation(new java
.awt
.Point(2, 62));
370 jLabelGroup
= new JLabel();
371 jLabelGroup
.setText("Event Group Type");
372 jLabelGroup
.setBounds(new java
.awt
.Rectangle(12, 62, 168, 20));
374 jStarLabel4
= new StarLabel();
375 jStarLabel4
.setLocation(new java
.awt
.Point(2, 87));
376 jLabelUsage
= new JLabel();
377 jLabelUsage
.setText("Usage");
378 jLabelUsage
.setBounds(new java
.awt
.Rectangle(12, 87, 168, 20));
380 jLabelHelpText
= new JLabel();
381 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(12, 112, 168, 20));
382 jLabelHelpText
.setText("Help Text");
384 jLabelFeatureFlag
= new JLabel();
385 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(12, 182, 168, 20));
386 jLabelFeatureFlag
.setText("Feature Flag Expression");
387 jLabelFeatureFlag
.setEnabled(false);
389 jLabelArch
= new JLabel();
390 jLabelArch
.setBounds(new java
.awt
.Rectangle(12, 157, 168, 20));
391 jLabelArch
.setText("Supported Architectures");
392 jArchCheckBox
= new ArchCheckBox();
393 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(168, 157, 320, 20));
394 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
396 jContentPane
= new JPanel();
397 jContentPane
.setLayout(null);
398 jContentPane
.setPreferredSize(new java
.awt
.Dimension(485, 235));
400 jContentPane
.add(jStarLabel1
, null);
401 jContentPane
.add(jLabelEventType
, null);
402 jContentPane
.add(getJComboBoxEventsType(), null);
403 jContentPane
.add(jStarLabel2
, null);
404 jContentPane
.add(jLabelC_Name
, null);
405 jContentPane
.add(getJComboBoxGuidC_Name(), null);
406 jContentPane
.add(jStarLabel3
, null);
407 jContentPane
.add(jLabelGroup
, null);
408 jContentPane
.add(getJComboBoxEventGroup(), null);
409 jContentPane
.add(jStarLabel4
, null);
410 jContentPane
.add(jLabelUsage
, null);
411 jContentPane
.add(getJComboBoxUsage(), null);
412 jContentPane
.add(jLabelHelpText
, null);
413 jContentPane
.add(getJScrollPaneHelpText(), null);
414 jContentPane
.add(jLabelFeatureFlag
, null);
415 jContentPane
.add(getJTextFieldFeatureFlag(), null);
416 jContentPane
.add(jLabelArch
, null);
417 jContentPane
.add(jArchCheckBox
, null);
418 jContentPane
.add(getJButtonOk(), null);
419 jContentPane
.add(getJButtonCancel(), null);
426 * This method initializes events groups and usage type
429 private void initFrame() {
430 Tools
.generateComboBoxByVector(jComboBoxEventsType
, ed
.getVEventType());
431 Tools
.generateComboBoxByVector(jComboBoxEventGroup
, ed
.getVEventGroup());
432 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVEventUsage());
433 Tools
.generateComboBoxByVector(jComboBoxGuidC_Name
, wt
.getAllGuidDeclarationsFromWorkspace());
439 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
441 * Override actionPerformed to listen all actions
444 public void actionPerformed(ActionEvent arg0
) {
445 if (arg0
.getSource() == jButtonOk
) {
448 this.returnType
= DataType
.RETURN_TYPE_OK
;
449 this.setVisible(false);
453 if (arg0
.getSource() == jButtonCancel
) {
454 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
455 this.setVisible(false);
460 * Data validation for all fields
462 * @retval true - All datas are valid
463 * @retval false - At least one data is invalid
466 public boolean checkAdd() {
468 // Check if all fields have correct data types
474 if (isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
475 Log
.wrn("Update Events", "Event Name couldn't be empty");
479 if (!isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
480 if (!DataValidation
.isC_NameType(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
481 Log
.wrn("Update Events", "Incorrect data type for Event Name");
489 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
490 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
491 Log
.wrn("Update Events", "Incorrect data type for Feature Flag");
499 private EventsIdentification
getCurrentEvents() {
500 String arg0
= this.jComboBoxGuidC_Name
.getSelectedItem().toString();
501 String arg1
= this.jComboBoxEventsType
.getSelectedItem().toString();
502 String arg2
= this.jComboBoxUsage
.getSelectedItem().toString();
504 String arg3
= this.jTextFieldFeatureFlag
.getText();
505 Vector
<String
> arg4
= this.jArchCheckBox
.getSelectedItemsVector();
506 String arg5
= this.jTextAreaHelpText
.getText();
507 String arg6
= this.jComboBoxEventGroup
.getSelectedItem().toString();
508 id
= new EventsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
512 public EventsIdentification
getId() {
516 public void setId(EventsIdentification id
) {