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
.ModuleIdentification
;
38 import org
.tianocore
.frameworkwizard
.module
.Identifications
.Events
.EventsIdentification
;
39 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
40 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
43 * The class is used to create, update Events section of the MSA file
46 * @since ModuleEditor 1.0
49 public class EventsDlg
extends IDialog
{
52 // / Define class Serial Version UID
54 private static final long serialVersionUID
= -4396143706422842331L;
57 // Define class members
59 private JPanel jContentPane
= null;
61 private JLabel jLabelEventType
= null;
63 private JLabel jLabelC_Name
= null;
65 private JComboBox jComboBoxGuidC_Name
= null;
67 private JLabel jLabelUsage
= null;
69 private JLabel jLabelGroup
= null;
71 private JComboBox jComboBoxUsage
= null;
73 private JComboBox jComboBoxEventGroup
= null;
75 private StarLabel jStarLabel1
= null;
77 private StarLabel jStarLabel2
= null;
79 private StarLabel jStarLabel3
= null;
81 private StarLabel jStarLabel4
= null;
83 private JComboBox jComboBoxEventsType
= null;
85 private JScrollPane jScrollPane
= null;
87 private JLabel jLabelArch
= null;
89 private JLabel jLabelHelpText
= null;
91 private JTextArea jTextAreaHelpText
= null;
93 private JScrollPane jScrollPaneHelpText
= null;
95 private JLabel jLabelFeatureFlag
= null;
97 private JTextField jTextFieldFeatureFlag
= null;
99 private ArchCheckBox jArchCheckBox
= null;
101 private JButton jButtonOk
= null;
103 private JButton jButtonCancel
= null;
108 private EventsIdentification id
= null;
110 private EnumerationData ed
= new EnumerationData();
112 private WorkspaceTools wt
= new WorkspaceTools();
115 * This method initializes jComboBoxType
117 * @return javax.swing.JComboBox jComboBoxType
120 private JComboBox
getJComboBoxEventsType() {
121 if (jComboBoxEventsType
== null) {
122 jComboBoxEventsType
= new JComboBox();
123 jComboBoxEventsType
.setBounds(new java
.awt
.Rectangle(168, 12, 320, 20));
124 jComboBoxEventsType
.setPreferredSize(new java
.awt
.Dimension(320, 20));
126 .setToolTipText("<html>Select CreateEvents if the Module has an event that is waiting to be signaled.<br>"
127 + "Select SignalEvents if the Module will signal all events in an event group.<br>"
128 + "NOTE: Signal events are named by GUID.</html>");
130 return jComboBoxEventsType
;
134 * This method initializes jTextFieldC_Name
136 * @return javax.swing.JTextField jTextFieldC_Name
139 private JComboBox
getJComboBoxGuidC_Name() {
140 if (jComboBoxGuidC_Name
== null) {
141 jComboBoxGuidC_Name
= new JComboBox();
142 jComboBoxGuidC_Name
.setBounds(new java
.awt
.Rectangle(168, 37, 320, 20));
143 jComboBoxGuidC_Name
.setPreferredSize(new java
.awt
.Dimension(320, 20));
144 jComboBoxGuidC_Name
.setToolTipText("Select the GUID C Name of the Event");
146 return jComboBoxGuidC_Name
;
150 * This method initializes jComboBoxEventsType
152 * @return javax.swing.JComboBox
154 private JComboBox
getJComboBoxEventGroup() {
155 if (jComboBoxEventGroup
== null) {
156 jComboBoxEventGroup
= new JComboBox();
157 jComboBoxEventGroup
.setBounds(new java
.awt
.Rectangle(168, 62, 320, 20));
158 jComboBoxEventGroup
.setPreferredSize(new java
.awt
.Dimension(320, 20));
159 jComboBoxEventGroup
.setToolTipText("Select Type of Event: Guid or Timer.");
162 return jComboBoxEventGroup
;
166 * This method initializes jComboBoxUsage
168 * @return javax.swing.JComboBox jComboBoxUsage
171 private JComboBox
getJComboBoxUsage() {
172 if (jComboBoxUsage
== null) {
173 jComboBoxUsage
= new JComboBox();
174 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(168, 87, 320, 20));
175 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
177 .setToolTipText("<html><table>"
178 + "<tr><td colspan=2 align=center><b>Create Events</b></td></tr>"
179 + "<tr><td>ALWAYS_CONSUMED</td><td>Module registers a notification function and REQUIRES that it be<br>"
180 + "executed for the module to fully function.</td></tr>"
181 + "<tr><td>SOMETIMES_CONSUMED</td><td>Module registers a notification function and calls the function<br>"
182 + "when it is signaled</td></tr><tr><td colspan=2 align=center><b>Signal Events</b></td></tr>"
183 + "<tr><td>ALWAYS_PRODUCED</td><td>Module will Always signal the event</td></tr>"
184 + "<tr><td>SOMETIMES_PRODUCED</td><td>Module will sometimes signal the event</td></tr>"
185 + "</table></html>");
187 return jComboBoxUsage
;
191 * This method initializes jScrollPane
193 * @return javax.swing.JScrollPane
195 private JScrollPane
getJScrollPane() {
196 if (jScrollPane
== null) {
197 jScrollPane
= new JScrollPane();
198 jScrollPane
.setViewportView(getJContentPane());
204 * This method initializes jTextFieldFeatureFlag
206 * @return javax.swing.JTextField
208 private JTextField
getJTextFieldFeatureFlag() {
209 if (jTextFieldFeatureFlag
== null) {
210 jTextFieldFeatureFlag
= new JTextField();
211 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(168, 182, 320, 20));
212 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
213 jTextFieldFeatureFlag
.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");
214 jTextFieldFeatureFlag
.setEnabled(false);
216 return jTextFieldFeatureFlag
;
220 * This method initializes jTextAreaHelpText
222 * @return javax.swing.JTextArea
225 private JTextArea
getJTextAreaHelpText() {
226 if (jTextAreaHelpText
== null) {
227 jTextAreaHelpText
= new JTextArea();
228 jTextAreaHelpText
.setLineWrap(true);
229 jTextAreaHelpText
.setWrapStyleWord(true);
231 return jTextAreaHelpText
;
235 * This method initializes jScrollPaneHelpText
237 * @return javax.swing.JScrollPane
240 private JScrollPane
getJScrollPaneHelpText() {
241 if (jScrollPaneHelpText
== null) {
242 jScrollPaneHelpText
= new JScrollPane();
243 jScrollPaneHelpText
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
244 jScrollPaneHelpText
.setSize(new java
.awt
.Dimension(320, 40));
245 jScrollPaneHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 40));
246 jScrollPaneHelpText
.setLocation(new java
.awt
.Point(168, 112));
247 jScrollPaneHelpText
.setViewportView(getJTextAreaHelpText());
249 return jScrollPaneHelpText
;
253 * This method initializes jButtonOk
255 * @return javax.swing.JButton
258 private JButton
getJButtonOk() {
259 if (jButtonOk
== null) {
260 jButtonOk
= new JButton();
261 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 212, 90, 20));
262 jButtonOk
.setText("Ok");
263 jButtonOk
.addActionListener(this);
269 * This method initializes jButtonCancel
271 * @return javax.swing.JButton
274 private JButton
getJButtonCancel() {
275 if (jButtonCancel
== null) {
276 jButtonCancel
= new JButton();
277 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 212, 90, 20));
278 jButtonCancel
.setText("Cancel");
279 jButtonCancel
.addActionListener(this);
281 return jButtonCancel
;
284 public static void main(String
[] args
) {
289 * This method initializes this
292 private void init() {
293 this.setSize(505, 280);
294 this.setContentPane(getJScrollPane());
295 this.setTitle("Events");
297 this.setViewMode(false);
302 * This method initializes this Fill values to all fields if these values are
308 private void init(EventsIdentification inEventsId
, ModuleIdentification mid
) {
310 this.id
= inEventsId
;
313 // Init arch with module's arch
315 this.jArchCheckBox
.setEnabledItems(wt
.getModuleArch(mid
));
318 // Get defined guids from dependent packages
320 Vector
<PackageIdentification
> vpid
= wt
.getPackageDependenciesOfModule(mid
);
321 if (vpid
.size() <= 0) {
324 "This module hasn't defined any package dependency, so there is no guid value can be added for event");
327 // Init guids drop down list
330 .generateComboBoxByVector(jComboBoxGuidC_Name
,
331 wt
.getAllGuidDeclarationsFromPackages(vpid
, EnumerationData
.GUID_TYPE_EFI_EVENT
));
333 if (this.id
!= null) {
334 this.jComboBoxGuidC_Name
.setSelectedItem(id
.getName());
335 this.jComboBoxEventsType
.setSelectedItem(id
.getType());
336 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
337 this.jTextAreaHelpText
.setText(id
.getHelp());
339 jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
340 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
341 this.jComboBoxEventGroup
.setSelectedItem(id
.getGroup());
346 * This is the override edit constructor
348 * @param inEventsIdentification
352 public EventsDlg(EventsIdentification inEventsIdentification
, IFrame iFrame
, ModuleIdentification mid
) {
354 init(inEventsIdentification
, mid
);
358 * Disable all components when the mode is view
361 * true - The view mode; false - The non-view mode
364 public void setViewMode(boolean isView
) {
366 this.jComboBoxGuidC_Name
.setEnabled(!isView
);
367 this.jComboBoxUsage
.setEnabled(!isView
);
372 * This method initializes jContentPane
374 * @return javax.swing.JPanel jContentPane
377 private JPanel
getJContentPane() {
378 if (jContentPane
== null) {
379 jStarLabel1
= new StarLabel();
380 jStarLabel1
.setLocation(new java
.awt
.Point(2, 12));
381 jLabelEventType
= new JLabel();
382 jLabelEventType
.setText("Select Event Type");
383 jLabelEventType
.setBounds(new java
.awt
.Rectangle(12, 12, 168, 20));
385 jStarLabel2
= new StarLabel();
386 jStarLabel2
.setLocation(new java
.awt
.Point(2, 37));
387 jLabelC_Name
= new JLabel();
388 jLabelC_Name
.setText("Guid C Name");
389 jLabelC_Name
.setBounds(new java
.awt
.Rectangle(12, 37, 168, 20));
391 jStarLabel3
= new StarLabel();
392 jStarLabel3
.setLocation(new java
.awt
.Point(2, 62));
393 jLabelGroup
= new JLabel();
394 jLabelGroup
.setText("Event Group Type");
395 jLabelGroup
.setBounds(new java
.awt
.Rectangle(12, 62, 168, 20));
397 jStarLabel4
= new StarLabel();
398 jStarLabel4
.setLocation(new java
.awt
.Point(2, 87));
399 jLabelUsage
= new JLabel();
400 jLabelUsage
.setText("Usage");
401 jLabelUsage
.setBounds(new java
.awt
.Rectangle(12, 87, 168, 20));
403 jLabelHelpText
= new JLabel();
404 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(12, 112, 168, 20));
405 jLabelHelpText
.setText("Help Text");
407 jLabelFeatureFlag
= new JLabel();
408 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(12, 182, 168, 20));
409 jLabelFeatureFlag
.setText("Feature Flag Expression");
410 jLabelFeatureFlag
.setEnabled(false);
412 jLabelArch
= new JLabel();
413 jLabelArch
.setBounds(new java
.awt
.Rectangle(12, 157, 168, 20));
414 jLabelArch
.setText("Supported Architectures");
415 jArchCheckBox
= new ArchCheckBox();
416 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(168, 157, 320, 20));
417 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
419 jContentPane
= new JPanel();
420 jContentPane
.setLayout(null);
421 jContentPane
.setPreferredSize(new java
.awt
.Dimension(485, 235));
423 jContentPane
.add(jStarLabel1
, null);
424 jContentPane
.add(jLabelEventType
, null);
425 jContentPane
.add(getJComboBoxEventsType(), null);
426 jContentPane
.add(jStarLabel2
, null);
427 jContentPane
.add(jLabelC_Name
, null);
428 jContentPane
.add(getJComboBoxGuidC_Name(), null);
429 jContentPane
.add(jStarLabel3
, null);
430 jContentPane
.add(jLabelGroup
, null);
431 jContentPane
.add(getJComboBoxEventGroup(), null);
432 jContentPane
.add(jStarLabel4
, null);
433 jContentPane
.add(jLabelUsage
, null);
434 jContentPane
.add(getJComboBoxUsage(), null);
435 jContentPane
.add(jLabelHelpText
, null);
436 jContentPane
.add(getJScrollPaneHelpText(), null);
437 jContentPane
.add(jLabelFeatureFlag
, null);
438 jContentPane
.add(getJTextFieldFeatureFlag(), null);
439 jContentPane
.add(jLabelArch
, null);
440 jContentPane
.add(jArchCheckBox
, null);
441 jContentPane
.add(getJButtonOk(), null);
442 jContentPane
.add(getJButtonCancel(), null);
449 * This method initializes events groups and usage type
452 private void initFrame() {
453 Tools
.generateComboBoxByVector(jComboBoxEventsType
, ed
.getVEventType());
454 Tools
.generateComboBoxByVector(jComboBoxEventGroup
, ed
.getVEventGroup());
455 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVEventUsage());
461 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
463 * Override actionPerformed to listen all actions
466 public void actionPerformed(ActionEvent arg0
) {
467 if (arg0
.getSource() == jButtonOk
) {
470 this.returnType
= DataType
.RETURN_TYPE_OK
;
471 this.setVisible(false);
475 if (arg0
.getSource() == jButtonCancel
) {
476 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
477 this.setVisible(false);
482 * Data validation for all fields
484 * @retval true - All datas are valid
485 * @retval false - At least one data is invalid
488 public boolean checkAdd() {
490 // Check if all fields have correct data types
496 if (this.jComboBoxGuidC_Name
.getSelectedItem() == null) {
497 Log
.wrn("Update Guids", "Please select one Event Name");
504 if (isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
505 Log
.wrn("Update Events", "Event Name couldn't be empty");
509 if (!isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
510 if (!DataValidation
.isC_NameType(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
511 Log
.wrn("Update Events", "Incorrect data type for Event Name");
519 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
520 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
521 Log
.wrn("Update Events", "Incorrect data type for Feature Flag");
529 private EventsIdentification
getCurrentEvents() {
530 String arg0
= this.jComboBoxGuidC_Name
.getSelectedItem().toString();
531 String arg1
= this.jComboBoxEventsType
.getSelectedItem().toString();
532 String arg2
= this.jComboBoxUsage
.getSelectedItem().toString();
534 String arg3
= this.jTextFieldFeatureFlag
.getText();
535 Vector
<String
> arg4
= this.jArchCheckBox
.getSelectedItemsVector();
536 String arg5
= this.jTextAreaHelpText
.getText();
537 String arg6
= this.jComboBoxEventGroup
.getSelectedItem().toString();
538 id
= new EventsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
542 public EventsIdentification
getId() {
546 public void setId(EventsIdentification id
) {