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, 157, 320, 20));
210 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
211 jTextFieldFeatureFlag
.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");
213 return jTextFieldFeatureFlag
;
217 * This method initializes jTextAreaHelpText
219 * @return javax.swing.JTextArea
222 private JTextArea
getJTextAreaHelpText() {
223 if (jTextAreaHelpText
== null) {
224 jTextAreaHelpText
= new JTextArea();
225 jTextAreaHelpText
.setLineWrap(true);
226 jTextAreaHelpText
.setWrapStyleWord(true);
228 return jTextAreaHelpText
;
232 * This method initializes jScrollPaneHelpText
234 * @return javax.swing.JScrollPane
237 private JScrollPane
getJScrollPaneHelpText() {
238 if (jScrollPaneHelpText
== null) {
239 jScrollPaneHelpText
= new JScrollPane();
240 jScrollPaneHelpText
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_NEVER
);
241 jScrollPaneHelpText
.setSize(new java
.awt
.Dimension(320, 40));
242 jScrollPaneHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 40));
243 jScrollPaneHelpText
.setLocation(new java
.awt
.Point(168, 112));
244 jScrollPaneHelpText
.setViewportView(getJTextAreaHelpText());
246 return jScrollPaneHelpText
;
250 * This method initializes jButtonOk
252 * @return javax.swing.JButton
255 private JButton
getJButtonOk() {
256 if (jButtonOk
== null) {
257 jButtonOk
= new JButton();
258 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 212, 90, 20));
259 jButtonOk
.setText("Ok");
260 jButtonOk
.addActionListener(this);
266 * This method initializes jButtonCancel
268 * @return javax.swing.JButton
271 private JButton
getJButtonCancel() {
272 if (jButtonCancel
== null) {
273 jButtonCancel
= new JButton();
274 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 212, 90, 20));
275 jButtonCancel
.setText("Cancel");
276 jButtonCancel
.addActionListener(this);
278 return jButtonCancel
;
281 public static void main(String
[] args
) {
286 * This method initializes this
289 private void init() {
290 this.setSize(505, 280);
291 this.setContentPane(getJScrollPane());
292 this.setTitle("Events");
294 this.setViewMode(false);
299 * This method initializes this Fill values to all fields if these values are
305 private void init(EventsIdentification inEventsId
) {
307 this.id
= inEventsId
;
309 if (this.id
!= null) {
310 this.jComboBoxGuidC_Name
.setSelectedItem(id
.getName());
311 this.jComboBoxEventsType
.setSelectedItem(id
.getType());
312 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
313 this.jTextAreaHelpText
.setText(id
.getHelp());
315 jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
316 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
317 this.jComboBoxEventGroup
.setSelectedItem(id
.getGroup());
322 * This is the override edit constructor
324 * @param inEventsIdentification
328 public EventsDlg(EventsIdentification inEventsIdentification
, IFrame iFrame
) {
330 init(inEventsIdentification
);
334 * Disable all components when the mode is view
337 * true - The view mode; false - The non-view mode
340 public void setViewMode(boolean isView
) {
342 this.jComboBoxGuidC_Name
.setEnabled(!isView
);
343 this.jComboBoxUsage
.setEnabled(!isView
);
348 * This method initializes jContentPane
350 * @return javax.swing.JPanel jContentPane
353 private JPanel
getJContentPane() {
354 if (jContentPane
== null) {
355 jStarLabel1
= new StarLabel();
356 jStarLabel1
.setLocation(new java
.awt
.Point(2, 12));
357 jLabelEventType
= new JLabel();
358 jLabelEventType
.setText("Select Event Type");
359 jLabelEventType
.setBounds(new java
.awt
.Rectangle(12, 12, 168, 20));
361 jStarLabel2
= new StarLabel();
362 jStarLabel2
.setLocation(new java
.awt
.Point(2, 37));
363 jLabelC_Name
= new JLabel();
364 jLabelC_Name
.setText("Guid C Name");
365 jLabelC_Name
.setBounds(new java
.awt
.Rectangle(12, 37, 168, 20));
367 jStarLabel3
= new StarLabel();
368 jStarLabel3
.setLocation(new java
.awt
.Point(2, 62));
369 jLabelGroup
= new JLabel();
370 jLabelGroup
.setText("Event Group Type");
371 jLabelGroup
.setBounds(new java
.awt
.Rectangle(12, 62, 168, 20));
373 jStarLabel4
= new StarLabel();
374 jStarLabel4
.setLocation(new java
.awt
.Point(2, 87));
375 jLabelUsage
= new JLabel();
376 jLabelUsage
.setText("Usage");
377 jLabelUsage
.setBounds(new java
.awt
.Rectangle(12, 87, 168, 20));
379 jLabelHelpText
= new JLabel();
380 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(12, 112, 168, 20));
381 jLabelHelpText
.setText("Help Text");
383 jLabelFeatureFlag
= new JLabel();
384 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(12, 157, 168, 20));
385 jLabelFeatureFlag
.setText("Feature Flag Expression");
387 jLabelArch
= new JLabel();
388 jLabelArch
.setBounds(new java
.awt
.Rectangle(12, 182, 168, 20));
389 jLabelArch
.setText("Supported Architectures");
390 jArchCheckBox
= new ArchCheckBox();
391 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(168, 182, 320, 20));
392 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
394 jContentPane
= new JPanel();
395 jContentPane
.setLayout(null);
396 jContentPane
.setPreferredSize(new java
.awt
.Dimension(485, 235));
398 jContentPane
.add(jStarLabel1
, null);
399 jContentPane
.add(jLabelEventType
, null);
400 jContentPane
.add(getJComboBoxEventsType(), null);
401 jContentPane
.add(jStarLabel2
, null);
402 jContentPane
.add(jLabelC_Name
, null);
403 jContentPane
.add(getJComboBoxGuidC_Name(), null);
404 jContentPane
.add(jStarLabel3
, null);
405 jContentPane
.add(jLabelGroup
, null);
406 jContentPane
.add(getJComboBoxEventGroup(), null);
407 jContentPane
.add(jStarLabel4
, null);
408 jContentPane
.add(jLabelUsage
, null);
409 jContentPane
.add(getJComboBoxUsage(), null);
410 jContentPane
.add(jLabelHelpText
, null);
411 jContentPane
.add(getJScrollPaneHelpText(), null);
412 jContentPane
.add(jLabelFeatureFlag
, null);
413 jContentPane
.add(getJTextFieldFeatureFlag(), null);
414 jContentPane
.add(jLabelArch
, null);
415 jContentPane
.add(jArchCheckBox
, null);
416 jContentPane
.add(getJButtonOk(), null);
417 jContentPane
.add(getJButtonCancel(), null);
424 * This method initializes events groups and usage type
427 private void initFrame() {
428 Tools
.generateComboBoxByVector(jComboBoxEventsType
, ed
.getVEventType());
429 Tools
.generateComboBoxByVector(jComboBoxEventGroup
, ed
.getVEventGroup());
430 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVEventUsage());
431 Tools
.generateComboBoxByVector(jComboBoxGuidC_Name
, wt
.getAllGuidDeclarationsFromWorkspace());
437 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
439 * Override actionPerformed to listen all actions
442 public void actionPerformed(ActionEvent arg0
) {
443 if (arg0
.getSource() == jButtonOk
) {
446 this.returnType
= DataType
.RETURN_TYPE_OK
;
447 this.setVisible(false);
451 if (arg0
.getSource() == jButtonCancel
) {
452 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
453 this.setVisible(false);
458 * Data validation for all fields
460 * @retval true - All datas are valid
461 * @retval false - At least one data is invalid
464 public boolean checkAdd() {
466 // Check if all fields have correct data types
472 if (isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
473 Log
.wrn("Update Events", "Event Name couldn't be empty");
477 if (!isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
478 if (!DataValidation
.isC_NameType(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
479 Log
.wrn("Update Events", "Incorrect data type for Event Name");
487 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
488 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
489 Log
.wrn("Update Events", "Incorrect data type for Feature Flag");
497 private EventsIdentification
getCurrentEvents() {
498 String arg0
= this.jComboBoxGuidC_Name
.getSelectedItem().toString();
499 String arg1
= this.jComboBoxEventsType
.getSelectedItem().toString();
500 String arg2
= this.jComboBoxUsage
.getSelectedItem().toString();
502 String arg3
= this.jTextFieldFeatureFlag
.getText();
503 Vector
<String
> arg4
= this.jArchCheckBox
.getSelectedItemsVector();
504 String arg5
= this.jTextAreaHelpText
.getText();
505 String arg6
= this.jComboBoxEventGroup
.getSelectedItem().toString();
506 id
= new EventsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
510 public EventsIdentification
getId() {
514 public void setId(EventsIdentification id
) {