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
.IComboBox
;
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
.ModuleIdentification
;
39 import org
.tianocore
.frameworkwizard
.module
.Identifications
.Events
.EventsIdentification
;
40 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
41 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
44 * The class is used to create, update Events section of the MSA file
47 * @since ModuleEditor 1.0
50 public class EventsDlg
extends IDialog
{
53 // / Define class Serial Version UID
55 private static final long serialVersionUID
= -4396143706422842331L;
58 // Define class members
60 private JPanel jContentPane
= null;
62 private JLabel jLabelEventType
= null;
64 private JLabel jLabelC_Name
= null;
66 private IComboBox iComboBoxGuidC_Name
= null;
68 private JLabel jLabelUsage
= null;
70 private JLabel jLabelGroup
= null;
72 private JComboBox jComboBoxUsage
= null;
74 private JComboBox jComboBoxEventGroup
= null;
76 private StarLabel jStarLabel1
= null;
78 private StarLabel jStarLabel2
= null;
80 private StarLabel jStarLabel3
= null;
82 private StarLabel jStarLabel4
= null;
84 private JComboBox jComboBoxEventsType
= null;
86 private JScrollPane jScrollPane
= null;
88 private JLabel jLabelArch
= null;
90 private JLabel jLabelHelpText
= null;
92 private JTextArea jTextAreaHelpText
= null;
94 private JScrollPane jScrollPaneHelpText
= null;
96 private JLabel jLabelFeatureFlag
= null;
98 private JTextField jTextFieldFeatureFlag
= null;
100 private ArchCheckBox jArchCheckBox
= null;
102 private JButton jButtonOk
= null;
104 private JButton jButtonCancel
= null;
109 private EventsIdentification id
= null;
111 private EnumerationData ed
= new EnumerationData();
113 private WorkspaceTools wt
= new WorkspaceTools();
116 * This method initializes jComboBoxType
118 * @return javax.swing.JComboBox jComboBoxType
121 private JComboBox
getJComboBoxEventsType() {
122 if (jComboBoxEventsType
== null) {
123 jComboBoxEventsType
= new JComboBox();
124 jComboBoxEventsType
.setBounds(new java
.awt
.Rectangle(168, 12, 320, 20));
125 jComboBoxEventsType
.setPreferredSize(new java
.awt
.Dimension(320, 20));
127 .setToolTipText("<html>Select CreateEvents if the Module has an event that is waiting to be signaled.<br>"
128 + "Select SignalEvents if the Module will signal all events in an event group.<br>"
129 + "NOTE: Signal events are named by GUID.</html>");
131 return jComboBoxEventsType
;
135 * This method initializes jTextFieldC_Name
137 * @return javax.swing.JTextField jTextFieldC_Name
140 private IComboBox
getIComboBoxGuidC_Name() {
141 if (iComboBoxGuidC_Name
== null) {
142 iComboBoxGuidC_Name
= new IComboBox();
143 iComboBoxGuidC_Name
.setBounds(new java
.awt
.Rectangle(168, 37, 320, 20));
144 iComboBoxGuidC_Name
.setPreferredSize(new java
.awt
.Dimension(320, 20));
145 iComboBoxGuidC_Name
.setToolTipText("Select the GUID C Name of the Event");
147 return iComboBoxGuidC_Name
;
151 * This method initializes jComboBoxEventsType
153 * @return javax.swing.JComboBox
155 private JComboBox
getJComboBoxEventGroup() {
156 if (jComboBoxEventGroup
== null) {
157 jComboBoxEventGroup
= new JComboBox();
158 jComboBoxEventGroup
.setBounds(new java
.awt
.Rectangle(168, 62, 320, 20));
159 jComboBoxEventGroup
.setPreferredSize(new java
.awt
.Dimension(320, 20));
160 jComboBoxEventGroup
.setToolTipText("Select Type of Event: Guid or Timer.");
163 return jComboBoxEventGroup
;
167 * This method initializes jComboBoxUsage
169 * @return javax.swing.JComboBox jComboBoxUsage
172 private JComboBox
getJComboBoxUsage() {
173 if (jComboBoxUsage
== null) {
174 jComboBoxUsage
= new JComboBox();
175 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(168, 87, 320, 20));
176 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
178 .setToolTipText("<html><table>"
179 + "<tr><td colspan=2 align=center><b>Create Events</b></td></tr>"
180 + "<tr><td>ALWAYS_CONSUMED</td><td>Module registers a notification function and REQUIRES that it be<br>"
181 + "executed for the module to fully function.</td></tr>"
182 + "<tr><td>SOMETIMES_CONSUMED</td><td>Module registers a notification function and calls the function<br>"
183 + "when it is signaled</td></tr><tr><td colspan=2 align=center><b>Signal Events</b></td></tr>"
184 + "<tr><td>ALWAYS_PRODUCED</td><td>Module will Always signal the event</td></tr>"
185 + "<tr><td>SOMETIMES_PRODUCED</td><td>Module will sometimes signal the event</td></tr>"
186 + "</table></html>");
188 return jComboBoxUsage
;
192 * This method initializes jScrollPane
194 * @return javax.swing.JScrollPane
196 private JScrollPane
getJScrollPane() {
197 if (jScrollPane
== null) {
198 jScrollPane
= new JScrollPane();
199 jScrollPane
.setViewportView(getJContentPane());
205 * This method initializes jTextFieldFeatureFlag
207 * @return javax.swing.JTextField
209 private JTextField
getJTextFieldFeatureFlag() {
210 if (jTextFieldFeatureFlag
== null) {
211 jTextFieldFeatureFlag
= new JTextField();
212 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(168, 182, 320, 20));
213 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
214 jTextFieldFeatureFlag
.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");
215 jTextFieldFeatureFlag
.setEnabled(false);
217 return jTextFieldFeatureFlag
;
221 * This method initializes jTextAreaHelpText
223 * @return javax.swing.JTextArea
226 private JTextArea
getJTextAreaHelpText() {
227 if (jTextAreaHelpText
== null) {
228 jTextAreaHelpText
= new JTextArea();
229 jTextAreaHelpText
.setLineWrap(true);
230 jTextAreaHelpText
.setWrapStyleWord(true);
232 return jTextAreaHelpText
;
236 * This method initializes jScrollPaneHelpText
238 * @return javax.swing.JScrollPane
241 private JScrollPane
getJScrollPaneHelpText() {
242 if (jScrollPaneHelpText
== null) {
243 jScrollPaneHelpText
= new JScrollPane();
244 jScrollPaneHelpText
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
245 jScrollPaneHelpText
.setSize(new java
.awt
.Dimension(320, 40));
246 jScrollPaneHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 40));
247 jScrollPaneHelpText
.setLocation(new java
.awt
.Point(168, 112));
248 jScrollPaneHelpText
.setViewportView(getJTextAreaHelpText());
250 return jScrollPaneHelpText
;
254 * This method initializes jButtonOk
256 * @return javax.swing.JButton
259 private JButton
getJButtonOk() {
260 if (jButtonOk
== null) {
261 jButtonOk
= new JButton();
262 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 212, 90, 20));
263 jButtonOk
.setText("Ok");
264 jButtonOk
.addActionListener(this);
270 * This method initializes jButtonCancel
272 * @return javax.swing.JButton
275 private JButton
getJButtonCancel() {
276 if (jButtonCancel
== null) {
277 jButtonCancel
= new JButton();
278 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 212, 90, 20));
279 jButtonCancel
.setText("Cancel");
280 jButtonCancel
.addActionListener(this);
282 return jButtonCancel
;
285 public static void main(String
[] args
) {
290 * This method initializes this
293 private void init() {
294 this.setSize(505, 280);
295 this.setContentPane(getJScrollPane());
296 this.setTitle("Events");
298 this.setViewMode(false);
303 * This method initializes this Fill values to all fields if these values are
309 private void init(EventsIdentification inEventsId
, ModuleIdentification mid
) {
311 this.id
= inEventsId
;
314 // Init arch with module's arch
316 this.jArchCheckBox
.setEnabledItems(wt
.getModuleArch(mid
));
319 // Get defined guids from dependent packages
321 Vector
<PackageIdentification
> vpid
= wt
.getPackageDependenciesOfModule(mid
);
322 if (vpid
.size() <= 0) {
325 "This module hasn't defined any package dependency, so there is no guid value can be added for event");
328 // Init guids drop down list
331 .generateComboBoxByVector(iComboBoxGuidC_Name
,
332 wt
.getAllGuidDeclarationsFromPackages(vpid
, EnumerationData
.GUID_TYPE_EFI_EVENT
));
334 if (this.id
!= null) {
335 this.iComboBoxGuidC_Name
.setSelectedItem(id
.getName());
336 this.jComboBoxEventsType
.setSelectedItem(id
.getType());
337 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
338 this.jTextAreaHelpText
.setText(id
.getHelp());
340 jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
341 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
342 this.jComboBoxEventGroup
.setSelectedItem(id
.getGroup());
347 * This is the override edit constructor
349 * @param inEventsIdentification
353 public EventsDlg(EventsIdentification inEventsIdentification
, IFrame iFrame
, ModuleIdentification mid
) {
355 init(inEventsIdentification
, mid
);
359 * Disable all components when the mode is view
362 * true - The view mode; false - The non-view mode
365 public void setViewMode(boolean isView
) {
367 this.iComboBoxGuidC_Name
.setEnabled(!isView
);
368 this.jComboBoxUsage
.setEnabled(!isView
);
373 * This method initializes jContentPane
375 * @return javax.swing.JPanel jContentPane
378 private JPanel
getJContentPane() {
379 if (jContentPane
== null) {
380 jStarLabel1
= new StarLabel();
381 jStarLabel1
.setLocation(new java
.awt
.Point(2, 12));
382 jLabelEventType
= new JLabel();
383 jLabelEventType
.setText("Select Event Type");
384 jLabelEventType
.setBounds(new java
.awt
.Rectangle(12, 12, 168, 20));
386 jStarLabel2
= new StarLabel();
387 jStarLabel2
.setLocation(new java
.awt
.Point(2, 37));
388 jLabelC_Name
= new JLabel();
389 jLabelC_Name
.setText("Guid C Name");
390 jLabelC_Name
.setBounds(new java
.awt
.Rectangle(12, 37, 168, 20));
392 jStarLabel3
= new StarLabel();
393 jStarLabel3
.setLocation(new java
.awt
.Point(2, 62));
394 jLabelGroup
= new JLabel();
395 jLabelGroup
.setText("Event Group Type");
396 jLabelGroup
.setBounds(new java
.awt
.Rectangle(12, 62, 168, 20));
398 jStarLabel4
= new StarLabel();
399 jStarLabel4
.setLocation(new java
.awt
.Point(2, 87));
400 jLabelUsage
= new JLabel();
401 jLabelUsage
.setText("Usage");
402 jLabelUsage
.setBounds(new java
.awt
.Rectangle(12, 87, 168, 20));
404 jLabelHelpText
= new JLabel();
405 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(12, 112, 168, 20));
406 jLabelHelpText
.setText("Help Text");
408 jLabelFeatureFlag
= new JLabel();
409 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(12, 182, 168, 20));
410 jLabelFeatureFlag
.setText("Feature Flag Expression");
411 jLabelFeatureFlag
.setEnabled(false);
413 jLabelArch
= new JLabel();
414 jLabelArch
.setBounds(new java
.awt
.Rectangle(12, 157, 168, 20));
415 jLabelArch
.setText("Supported Architectures");
416 jArchCheckBox
= new ArchCheckBox();
417 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(168, 157, 320, 20));
418 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
420 jContentPane
= new JPanel();
421 jContentPane
.setLayout(null);
422 jContentPane
.setPreferredSize(new java
.awt
.Dimension(485, 235));
424 jContentPane
.add(jStarLabel1
, null);
425 jContentPane
.add(jLabelEventType
, null);
426 jContentPane
.add(getJComboBoxEventsType(), null);
427 jContentPane
.add(jStarLabel2
, null);
428 jContentPane
.add(jLabelC_Name
, null);
429 jContentPane
.add(getIComboBoxGuidC_Name(), null);
430 jContentPane
.add(jStarLabel3
, null);
431 jContentPane
.add(jLabelGroup
, null);
432 jContentPane
.add(getJComboBoxEventGroup(), null);
433 jContentPane
.add(jStarLabel4
, null);
434 jContentPane
.add(jLabelUsage
, null);
435 jContentPane
.add(getJComboBoxUsage(), null);
436 jContentPane
.add(jLabelHelpText
, null);
437 jContentPane
.add(getJScrollPaneHelpText(), null);
438 jContentPane
.add(jLabelFeatureFlag
, null);
439 jContentPane
.add(getJTextFieldFeatureFlag(), null);
440 jContentPane
.add(jLabelArch
, null);
441 jContentPane
.add(jArchCheckBox
, null);
442 jContentPane
.add(getJButtonOk(), null);
443 jContentPane
.add(getJButtonCancel(), null);
450 * This method initializes events groups and usage type
453 private void initFrame() {
454 Tools
.generateComboBoxByVector(jComboBoxEventsType
, ed
.getVEventType());
455 Tools
.generateComboBoxByVector(jComboBoxEventGroup
, ed
.getVEventGroup());
456 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVEventUsage());
462 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
464 * Override actionPerformed to listen all actions
467 public void actionPerformed(ActionEvent arg0
) {
468 if (arg0
.getSource() == jButtonOk
) {
471 this.returnType
= DataType
.RETURN_TYPE_OK
;
472 this.setVisible(false);
476 if (arg0
.getSource() == jButtonCancel
) {
477 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
478 this.setVisible(false);
483 * Data validation for all fields
485 * @retval true - All datas are valid
486 * @retval false - At least one data is invalid
489 public boolean checkAdd() {
491 // Check if all fields have correct data types
497 if (this.iComboBoxGuidC_Name
.getSelectedItem() == null) {
498 Log
.wrn("Update Guids", "Please select one Event Name");
505 if (isEmpty(this.iComboBoxGuidC_Name
.getSelectedItem().toString())) {
506 Log
.wrn("Update Events", "Event Name couldn't be empty");
510 if (!isEmpty(this.iComboBoxGuidC_Name
.getSelectedItem().toString())) {
511 if (!DataValidation
.isC_NameType(this.iComboBoxGuidC_Name
.getSelectedItem().toString())) {
512 Log
.wrn("Update Events", "Incorrect data type for Event Name");
520 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
521 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
522 Log
.wrn("Update Events", "Incorrect data type for Feature Flag");
530 private EventsIdentification
getCurrentEvents() {
531 String arg0
= this.iComboBoxGuidC_Name
.getSelectedItem().toString();
532 String arg1
= this.jComboBoxEventsType
.getSelectedItem().toString();
533 String arg2
= this.jComboBoxUsage
.getSelectedItem().toString();
535 String arg3
= this.jTextFieldFeatureFlag
.getText();
536 Vector
<String
> arg4
= this.jArchCheckBox
.getSelectedItemsVector();
537 String arg5
= this.jTextAreaHelpText
.getText();
538 String arg6
= this.jComboBoxEventGroup
.getSelectedItem().toString();
539 id
= new EventsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
543 public EventsIdentification
getId() {
547 public void setId(EventsIdentification id
) {