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
.workspace
.WorkspaceTools
;
42 * The class is used to create, update Events section of the MSA file
45 * @since ModuleEditor 1.0
48 public class EventsDlg
extends IDialog
{
51 // / Define class Serial Version UID
53 private static final long serialVersionUID
= -4396143706422842331L;
56 // Define class members
58 private JPanel jContentPane
= null;
60 private JLabel jLabelEventType
= null;
62 private JLabel jLabelC_Name
= null;
64 private JComboBox jComboBoxGuidC_Name
= null;
66 private JLabel jLabelUsage
= null;
68 private JLabel jLabelGroup
= null;
70 private JComboBox jComboBoxUsage
= null;
72 private JComboBox jComboBoxEventGroup
= null;
74 private StarLabel jStarLabel1
= null;
76 private StarLabel jStarLabel2
= null;
78 private StarLabel jStarLabel3
= null;
80 private StarLabel jStarLabel4
= null;
82 private JComboBox jComboBoxEventsType
= null;
84 private JScrollPane jScrollPane
= null;
86 private JLabel jLabelArch
= null;
88 private JLabel jLabelHelpText
= null;
90 private JTextArea jTextAreaHelpText
= null;
92 private JScrollPane jScrollPaneHelpText
= null;
94 private JLabel jLabelFeatureFlag
= null;
96 private JTextField jTextFieldFeatureFlag
= null;
98 private ArchCheckBox jArchCheckBox
= null;
100 private JButton jButtonOk
= null;
102 private JButton jButtonCancel
= null;
107 private EventsIdentification id
= null;
109 private EnumerationData ed
= new EnumerationData();
111 private WorkspaceTools wt
= new WorkspaceTools();
114 * This method initializes jComboBoxType
116 * @return javax.swing.JComboBox jComboBoxType
119 private JComboBox
getJComboBoxEventsType() {
120 if (jComboBoxEventsType
== null) {
121 jComboBoxEventsType
= new JComboBox();
122 jComboBoxEventsType
.setBounds(new java
.awt
.Rectangle(168, 12, 320, 20));
123 jComboBoxEventsType
.setPreferredSize(new java
.awt
.Dimension(320, 20));
125 .setToolTipText("<html>Select CreateEvents if the Module has an event that is waiting to be signaled.<br>"
126 + "Select SignalEvents if the Module will signal all events in an event group.<br>"
127 + "NOTE: Signal events are named by GUID.</html>");
129 return jComboBoxEventsType
;
133 * This method initializes jTextFieldC_Name
135 * @return javax.swing.JTextField jTextFieldC_Name
138 private JComboBox
getJComboBoxGuidC_Name() {
139 if (jComboBoxGuidC_Name
== null) {
140 jComboBoxGuidC_Name
= new JComboBox();
141 jComboBoxGuidC_Name
.setBounds(new java
.awt
.Rectangle(168, 37, 320, 20));
142 jComboBoxGuidC_Name
.setPreferredSize(new java
.awt
.Dimension(320, 20));
143 jComboBoxGuidC_Name
.setToolTipText("Select the GUID C Name of the Event");
145 return jComboBoxGuidC_Name
;
149 * This method initializes jComboBoxEventsType
151 * @return javax.swing.JComboBox
153 private JComboBox
getJComboBoxEventGroup() {
154 if (jComboBoxEventGroup
== null) {
155 jComboBoxEventGroup
= new JComboBox();
156 jComboBoxEventGroup
.setBounds(new java
.awt
.Rectangle(168, 62, 320, 20));
157 jComboBoxEventGroup
.setPreferredSize(new java
.awt
.Dimension(320, 20));
158 jComboBoxEventGroup
.setToolTipText("Select Type of Event: Guid or Timer.");
161 return jComboBoxEventGroup
;
165 * This method initializes jComboBoxUsage
167 * @return javax.swing.JComboBox jComboBoxUsage
170 private JComboBox
getJComboBoxUsage() {
171 if (jComboBoxUsage
== null) {
172 jComboBoxUsage
= new JComboBox();
173 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(168, 87, 320, 20));
174 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
176 .setToolTipText("<html><table>"
177 + "<tr><td colspan=2 align=center><b>Create Events</b></td></tr>"
178 + "<tr><td>ALWAYS_CONSUMED</td><td>Module registers a notification function and REQUIRES that it be<br>"
179 + "executed for the module to fully function.</td></tr>"
180 + "<tr><td>SOMETIMES_CONSUMED</td><td>Module registers a notification function and calls the function<br>"
181 + "when it is signaled</td></tr><tr><td colspan=2 align=center><b>Signal Events</b></td></tr>"
182 + "<tr><td>ALWAYS_PRODUCED</td><td>Module will Always signal the event</td></tr>"
183 + "<tr><td>SOMETIMES_PRODUCED</td><td>Module will sometimes signal the event</td></tr>"
184 + "</table></html>");
186 return jComboBoxUsage
;
190 * This method initializes jScrollPane
192 * @return javax.swing.JScrollPane
194 private JScrollPane
getJScrollPane() {
195 if (jScrollPane
== null) {
196 jScrollPane
= new JScrollPane();
197 jScrollPane
.setViewportView(getJContentPane());
203 * This method initializes jTextFieldFeatureFlag
205 * @return javax.swing.JTextField
207 private JTextField
getJTextFieldFeatureFlag() {
208 if (jTextFieldFeatureFlag
== null) {
209 jTextFieldFeatureFlag
= new JTextField();
210 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(168, 182, 320, 20));
211 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
212 jTextFieldFeatureFlag
.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");
213 jTextFieldFeatureFlag
.setEnabled(false);
215 return jTextFieldFeatureFlag
;
219 * This method initializes jTextAreaHelpText
221 * @return javax.swing.JTextArea
224 private JTextArea
getJTextAreaHelpText() {
225 if (jTextAreaHelpText
== null) {
226 jTextAreaHelpText
= new JTextArea();
227 jTextAreaHelpText
.setLineWrap(true);
228 jTextAreaHelpText
.setWrapStyleWord(true);
230 return jTextAreaHelpText
;
234 * This method initializes jScrollPaneHelpText
236 * @return javax.swing.JScrollPane
239 private JScrollPane
getJScrollPaneHelpText() {
240 if (jScrollPaneHelpText
== null) {
241 jScrollPaneHelpText
= new JScrollPane();
242 jScrollPaneHelpText
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
243 jScrollPaneHelpText
.setSize(new java
.awt
.Dimension(320, 40));
244 jScrollPaneHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 40));
245 jScrollPaneHelpText
.setLocation(new java
.awt
.Point(168, 112));
246 jScrollPaneHelpText
.setViewportView(getJTextAreaHelpText());
248 return jScrollPaneHelpText
;
252 * This method initializes jButtonOk
254 * @return javax.swing.JButton
257 private JButton
getJButtonOk() {
258 if (jButtonOk
== null) {
259 jButtonOk
= new JButton();
260 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 212, 90, 20));
261 jButtonOk
.setText("Ok");
262 jButtonOk
.addActionListener(this);
268 * This method initializes jButtonCancel
270 * @return javax.swing.JButton
273 private JButton
getJButtonCancel() {
274 if (jButtonCancel
== null) {
275 jButtonCancel
= new JButton();
276 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 212, 90, 20));
277 jButtonCancel
.setText("Cancel");
278 jButtonCancel
.addActionListener(this);
280 return jButtonCancel
;
283 public static void main(String
[] args
) {
288 * This method initializes this
291 private void init() {
292 this.setSize(505, 280);
293 this.setContentPane(getJScrollPane());
294 this.setTitle("Events");
296 this.setViewMode(false);
301 * This method initializes this Fill values to all fields if these values are
307 private void init(EventsIdentification inEventsId
, ModuleIdentification mid
) {
309 this.id
= inEventsId
;
312 // Init arch with module's arch
314 this.jArchCheckBox
.setEnabledItems(wt
.getModuleArch(mid
));
316 if (this.id
!= null) {
317 this.jComboBoxGuidC_Name
.setSelectedItem(id
.getName());
318 this.jComboBoxEventsType
.setSelectedItem(id
.getType());
319 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
320 this.jTextAreaHelpText
.setText(id
.getHelp());
322 jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
323 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
324 this.jComboBoxEventGroup
.setSelectedItem(id
.getGroup());
329 * This is the override edit constructor
331 * @param inEventsIdentification
335 public EventsDlg(EventsIdentification inEventsIdentification
, IFrame iFrame
, ModuleIdentification mid
) {
337 init(inEventsIdentification
, mid
);
341 * Disable all components when the mode is view
344 * true - The view mode; false - The non-view mode
347 public void setViewMode(boolean isView
) {
349 this.jComboBoxGuidC_Name
.setEnabled(!isView
);
350 this.jComboBoxUsage
.setEnabled(!isView
);
355 * This method initializes jContentPane
357 * @return javax.swing.JPanel jContentPane
360 private JPanel
getJContentPane() {
361 if (jContentPane
== null) {
362 jStarLabel1
= new StarLabel();
363 jStarLabel1
.setLocation(new java
.awt
.Point(2, 12));
364 jLabelEventType
= new JLabel();
365 jLabelEventType
.setText("Select Event Type");
366 jLabelEventType
.setBounds(new java
.awt
.Rectangle(12, 12, 168, 20));
368 jStarLabel2
= new StarLabel();
369 jStarLabel2
.setLocation(new java
.awt
.Point(2, 37));
370 jLabelC_Name
= new JLabel();
371 jLabelC_Name
.setText("Guid C Name");
372 jLabelC_Name
.setBounds(new java
.awt
.Rectangle(12, 37, 168, 20));
374 jStarLabel3
= new StarLabel();
375 jStarLabel3
.setLocation(new java
.awt
.Point(2, 62));
376 jLabelGroup
= new JLabel();
377 jLabelGroup
.setText("Event Group Type");
378 jLabelGroup
.setBounds(new java
.awt
.Rectangle(12, 62, 168, 20));
380 jStarLabel4
= new StarLabel();
381 jStarLabel4
.setLocation(new java
.awt
.Point(2, 87));
382 jLabelUsage
= new JLabel();
383 jLabelUsage
.setText("Usage");
384 jLabelUsage
.setBounds(new java
.awt
.Rectangle(12, 87, 168, 20));
386 jLabelHelpText
= new JLabel();
387 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(12, 112, 168, 20));
388 jLabelHelpText
.setText("Help Text");
390 jLabelFeatureFlag
= new JLabel();
391 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(12, 182, 168, 20));
392 jLabelFeatureFlag
.setText("Feature Flag Expression");
393 jLabelFeatureFlag
.setEnabled(false);
395 jLabelArch
= new JLabel();
396 jLabelArch
.setBounds(new java
.awt
.Rectangle(12, 157, 168, 20));
397 jLabelArch
.setText("Supported Architectures");
398 jArchCheckBox
= new ArchCheckBox();
399 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(168, 157, 320, 20));
400 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
402 jContentPane
= new JPanel();
403 jContentPane
.setLayout(null);
404 jContentPane
.setPreferredSize(new java
.awt
.Dimension(485, 235));
406 jContentPane
.add(jStarLabel1
, null);
407 jContentPane
.add(jLabelEventType
, null);
408 jContentPane
.add(getJComboBoxEventsType(), null);
409 jContentPane
.add(jStarLabel2
, null);
410 jContentPane
.add(jLabelC_Name
, null);
411 jContentPane
.add(getJComboBoxGuidC_Name(), null);
412 jContentPane
.add(jStarLabel3
, null);
413 jContentPane
.add(jLabelGroup
, null);
414 jContentPane
.add(getJComboBoxEventGroup(), null);
415 jContentPane
.add(jStarLabel4
, null);
416 jContentPane
.add(jLabelUsage
, null);
417 jContentPane
.add(getJComboBoxUsage(), null);
418 jContentPane
.add(jLabelHelpText
, null);
419 jContentPane
.add(getJScrollPaneHelpText(), null);
420 jContentPane
.add(jLabelFeatureFlag
, null);
421 jContentPane
.add(getJTextFieldFeatureFlag(), null);
422 jContentPane
.add(jLabelArch
, null);
423 jContentPane
.add(jArchCheckBox
, null);
424 jContentPane
.add(getJButtonOk(), null);
425 jContentPane
.add(getJButtonCancel(), null);
432 * This method initializes events groups and usage type
435 private void initFrame() {
436 Tools
.generateComboBoxByVector(jComboBoxEventsType
, ed
.getVEventType());
437 Tools
.generateComboBoxByVector(jComboBoxEventGroup
, ed
.getVEventGroup());
438 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVEventUsage());
439 Tools
.generateComboBoxByVector(jComboBoxGuidC_Name
, wt
.getAllGuidDeclarationsFromWorkspace());
445 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
447 * Override actionPerformed to listen all actions
450 public void actionPerformed(ActionEvent arg0
) {
451 if (arg0
.getSource() == jButtonOk
) {
454 this.returnType
= DataType
.RETURN_TYPE_OK
;
455 this.setVisible(false);
459 if (arg0
.getSource() == jButtonCancel
) {
460 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
461 this.setVisible(false);
466 * Data validation for all fields
468 * @retval true - All datas are valid
469 * @retval false - At least one data is invalid
472 public boolean checkAdd() {
474 // Check if all fields have correct data types
480 if (isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
481 Log
.wrn("Update Events", "Event Name couldn't be empty");
485 if (!isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
486 if (!DataValidation
.isC_NameType(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
487 Log
.wrn("Update Events", "Incorrect data type for Event Name");
495 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
496 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
497 Log
.wrn("Update Events", "Incorrect data type for Feature Flag");
505 private EventsIdentification
getCurrentEvents() {
506 String arg0
= this.jComboBoxGuidC_Name
.getSelectedItem().toString();
507 String arg1
= this.jComboBoxEventsType
.getSelectedItem().toString();
508 String arg2
= this.jComboBoxUsage
.getSelectedItem().toString();
510 String arg3
= this.jTextFieldFeatureFlag
.getText();
511 Vector
<String
> arg4
= this.jArchCheckBox
.getSelectedItemsVector();
512 String arg5
= this.jTextAreaHelpText
.getText();
513 String arg6
= this.jComboBoxEventGroup
.getSelectedItem().toString();
514 id
= new EventsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
518 public EventsIdentification
getId() {
522 public void setId(EventsIdentification id
) {