3 The file is used to create, update Event of MSA/MBD 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
;
27 import org
.tianocore
.frameworkwizard
.common
.DataType
;
28 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
29 import org
.tianocore
.frameworkwizard
.common
.EnumerationData
;
30 import org
.tianocore
.frameworkwizard
.common
.Log
;
31 import org
.tianocore
.frameworkwizard
.common
.Tools
;
32 import org
.tianocore
.frameworkwizard
.common
.ui
.ArchCheckBox
;
33 import org
.tianocore
.frameworkwizard
.common
.ui
.IDialog
;
34 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
35 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
36 import org
.tianocore
.frameworkwizard
.module
.Identifications
.Events
.EventsIdentification
;
37 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
40 The class is used to create, update Event of MSA/MBD file
41 It extends IInternalFrame
43 @since ModuleEditor 1.0
46 public class EventsDlg
extends IDialog
{
49 /// Define class Serial Version UID
51 private static final long serialVersionUID
= -4396143706422842331L;
54 //Define class members
56 private JPanel jContentPane
= null;
58 private JLabel jLabelEventType
= null;
60 private JLabel jLabelC_Name
= null;
62 private JComboBox jComboBoxGuidC_Name
= null;
64 private JLabel jLabelUsage
= null;
66 private JLabel jLabelGroup
= null;
68 private JComboBox jComboBoxUsage
= null;
70 private JComboBox jComboBoxEventGroup
= null;
72 private StarLabel jStarLabel1
= null;
74 private StarLabel jStarLabel2
= null;
76 private StarLabel jStarLabel3
= null;
78 private JComboBox jComboBoxEventsType
= null;
80 private JScrollPane jScrollPane
= null;
82 private JLabel jLabelArch
= null;
84 private JLabel jLabelHelpText
= null;
86 private JTextField jTextFieldHelpText
= null;
88 private JLabel jLabelFeatureFlag
= null;
90 private JTextField jTextFieldFeatureFlag
= null;
92 private ArchCheckBox jArchCheckBox
= null;
94 private JButton jButtonOk
= null;
96 private JButton jButtonCancel
= null;
101 private EventsIdentification id
= null;
103 private EnumerationData ed
= new EnumerationData();
105 private WorkspaceTools wt
= new WorkspaceTools();
108 This method initializes jTextFieldC_Name
110 @return javax.swing.JTextField jTextFieldC_Name
113 private JComboBox
getJComboBoxGuidC_Name() {
114 if (jComboBoxGuidC_Name
== null) {
115 jComboBoxGuidC_Name
= new JComboBox();
116 jComboBoxGuidC_Name
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
117 jComboBoxGuidC_Name
.setPreferredSize(new java
.awt
.Dimension(320, 20));
118 jComboBoxGuidC_Name
.setToolTipText("Select the GUID C Name of the Event");
120 return jComboBoxGuidC_Name
;
124 This method initializes jComboBoxUsage
126 @return javax.swing.JComboBox jComboBoxUsage
129 private JComboBox
getJComboBoxUsage() {
130 if (jComboBoxUsage
== null) {
131 jComboBoxUsage
= new JComboBox();
132 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(160, 85, 320, 20));
133 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
135 return jComboBoxUsage
;
139 This method initializes jComboBoxType
141 @return javax.swing.JComboBox jComboBoxType
144 private JComboBox
getJComboBoxEventsType() {
145 if (jComboBoxEventsType
== null) {
146 jComboBoxEventsType
= new JComboBox();
147 jComboBoxEventsType
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
148 jComboBoxEventsType
.setPreferredSize(new java
.awt
.Dimension(320, 20));
150 .setToolTipText("<html>Select Create event if the Module has an event that<br> is waiting to be signaled. Select Signal if the Module will signal all events in an event group. Signal Event The events are named by GUID.</html>");
152 return jComboBoxEventsType
;
156 * This method initializes jComboBoxEventsType
158 * @return javax.swing.JComboBox
160 private JComboBox
getJComboBoxEventGroup() {
161 if (jComboBoxEventGroup
== null) {
162 jComboBoxEventGroup
= new JComboBox();
163 jComboBoxEventGroup
.setBounds(new java
.awt
.Rectangle(160, 60, 320, 20));
164 jComboBoxEventGroup
.setPreferredSize(new java
.awt
.Dimension(320, 20));
167 return jComboBoxEventGroup
;
171 This method initializes jScrollPane
173 @return javax.swing.JScrollPane
175 private JScrollPane
getJScrollPane() {
176 if (jScrollPane
== null) {
177 jScrollPane
= new JScrollPane();
178 jScrollPane
.setViewportView(getJContentPane());
184 * This method initializes jTextFieldFeatureFlag
186 * @return javax.swing.JTextField
188 private JTextField
getJTextFieldFeatureFlag() {
189 if (jTextFieldFeatureFlag
== null) {
190 jTextFieldFeatureFlag
= new JTextField();
191 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(160, 135, 320, 20));
192 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
194 return jTextFieldFeatureFlag
;
198 This method initializes jTextFieldHelpText
200 @return javax.swing.JTextField
203 private JTextField
getJTextFieldHelpText() {
204 if (jTextFieldHelpText
== null) {
205 jTextFieldHelpText
= new JTextField();
206 jTextFieldHelpText
.setBounds(new java
.awt
.Rectangle(160, 110, 320, 20));
207 jTextFieldHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 20));
209 return jTextFieldHelpText
;
213 This method initializes jButtonOk
215 @return javax.swing.JButton
218 private JButton
getJButtonOk() {
219 if (jButtonOk
== null) {
220 jButtonOk
= new JButton();
221 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 190, 90, 20));
222 jButtonOk
.setText("Ok");
223 jButtonOk
.addActionListener(this);
229 This method initializes jButtonCancel
231 @return javax.swing.JButton
234 private JButton
getJButtonCancel() {
235 if (jButtonCancel
== null) {
236 jButtonCancel
= new JButton();
237 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 190, 90, 20));
238 jButtonCancel
.setText("Cancel");
239 jButtonCancel
.addActionListener(this);
241 return jButtonCancel
;
244 public static void main(String
[] args
) {
249 This method initializes this
252 private void init() {
253 this.setSize(500, 255);
254 this.setContentPane(getJScrollPane());
255 this.setTitle("Events");
257 this.setViewMode(false);
262 This method initializes this
263 Fill values to all fields if these values are not empty
268 private void init(EventsIdentification inEventsId
) {
270 this.id
= inEventsId
;
272 if (this.id
!= null) {
273 this.jComboBoxGuidC_Name
.setSelectedItem(id
.getName());
274 this.jComboBoxEventsType
.setSelectedItem(id
.getType());
275 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
276 this.jTextFieldHelpText
.setText(id
.getHelp());
278 jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
279 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
280 this.jComboBoxEventGroup
.setSelectedItem(id
.getGroup());
285 This is the override edit constructor
287 @param inEventsIdentification
291 public EventsDlg(EventsIdentification inEventsIdentification
, IFrame iFrame
) {
293 init(inEventsIdentification
);
297 Disable all components when the mode is view
299 @param isView true - The view mode; false - The non-view mode
302 public void setViewMode(boolean isView
) {
304 this.jComboBoxGuidC_Name
.setEnabled(!isView
);
305 this.jComboBoxUsage
.setEnabled(!isView
);
310 This method initializes jContentPane
312 @return javax.swing.JPanel jContentPane
315 private JPanel
getJContentPane() {
316 if (jContentPane
== null) {
317 jArchCheckBox
= new ArchCheckBox();
318 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(160, 135, 320, 20));
319 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
320 jLabelFeatureFlag
= new JLabel();
321 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(15, 135, 140, 20));
322 jLabelFeatureFlag
.setText("Feature Flag");
323 jLabelArch
= new JLabel();
324 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 160, 140, 20));
325 jLabelArch
.setText("Arch");
326 jLabelUsage
= new JLabel();
327 jLabelUsage
.setText("Usage");
328 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 85, 140, 20));
329 jLabelC_Name
= new JLabel();
330 jLabelC_Name
.setText("Guid C_Name");
331 jLabelC_Name
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
332 jLabelGroup
= new JLabel();
333 jLabelGroup
.setText("Even Type");
334 jLabelGroup
.setBounds(new java
.awt
.Rectangle(15, 60, 140, 20));
335 jLabelEventType
= new JLabel();
336 jLabelEventType
.setText("Type");
337 jLabelEventType
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
338 jLabelHelpText
= new JLabel();
339 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(14, 110, 140, 20));
340 jLabelHelpText
.setText("Help Text");
342 jContentPane
= new JPanel();
343 jContentPane
.setLayout(null);
344 jContentPane
.setPreferredSize(new java
.awt
.Dimension(490, 220));
346 jContentPane
.add(jLabelEventType
, null);
347 jContentPane
.add(jLabelGroup
, null);
348 jContentPane
.add(jLabelC_Name
, null);
349 jContentPane
.add(getJComboBoxGuidC_Name(), null);
350 jContentPane
.add(jLabelUsage
, null);
351 jContentPane
.add(getJComboBoxUsage(), null);
352 jStarLabel1
= new StarLabel();
353 jStarLabel1
.setBounds(new java
.awt
.Rectangle(0, 10, 10, 20));
354 jStarLabel2
= new StarLabel();
355 jStarLabel2
.setBounds(new java
.awt
.Rectangle(0, 35, 10, 20));
356 jStarLabel3
= new StarLabel();
357 jStarLabel3
.setBounds(new java
.awt
.Rectangle(0, 60, 10, 20));
359 jContentPane
.add(jStarLabel1
, null);
360 jContentPane
.add(jStarLabel2
, null);
361 jContentPane
.add(jStarLabel3
, null);
362 jContentPane
.add(getJComboBoxEventsType(), null);
364 jContentPane
.add(jLabelArch
, null);
365 jContentPane
.add(jLabelFeatureFlag
, null);
366 jContentPane
.add(getJTextFieldFeatureFlag(), null);
367 jContentPane
.add(jLabelHelpText
, null);
368 jContentPane
.add(getJTextFieldHelpText(), null);
369 jContentPane
.add(jArchCheckBox
, null);
370 jContentPane
.add(getJButtonOk(), null);
371 jContentPane
.add(getJButtonCancel(), null);
372 jContentPane
.add(getJComboBoxEventGroup(), null);
378 This method initializes events groups and usage type
381 private void initFrame() {
382 Tools
.generateComboBoxByVector(jComboBoxEventsType
, ed
.getVEventType());
383 Tools
.generateComboBoxByVector(jComboBoxEventGroup
, ed
.getVEventGroup());
384 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVEventUsage());
385 Tools
.generateComboBoxByVector(jComboBoxGuidC_Name
, wt
.getAllGuidDeclarationsFromWorkspace());
389 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
391 * Override actionPerformed to listen all actions
394 public void actionPerformed(ActionEvent arg0
) {
395 if (arg0
.getSource() == jButtonOk
) {
398 this.returnType
= DataType
.RETURN_TYPE_OK
;
399 this.setVisible(false);
403 if (arg0
.getSource() == jButtonCancel
) {
404 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
405 this.setVisible(false);
410 Data validation for all fields
412 @retval true - All datas are valid
413 @retval false - At least one data is invalid
416 public boolean checkAdd() {
418 // Check if all fields have correct data types
424 if (isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
425 Log
.wrn("Update Events", "Event Name couldn't be empty");
429 if (!isEmpty(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
430 if (!DataValidation
.isC_NameType(this.jComboBoxGuidC_Name
.getSelectedItem().toString())) {
431 Log
.wrn("Update Events", "Incorrect data type for Event Name");
439 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
440 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
441 Log
.wrn("Update Events", "Incorrect data type for Feature Flag");
449 private EventsIdentification
getCurrentEvents() {
450 String arg0
= this.jComboBoxGuidC_Name
.getSelectedItem().toString();
451 String arg1
= this.jComboBoxEventsType
.getSelectedItem().toString();
452 String arg2
= this.jComboBoxUsage
.getSelectedItem().toString();
454 String arg3
= this.jTextFieldFeatureFlag
.getText();
455 Vector
<String
> arg4
= this.jArchCheckBox
.getSelectedItemsVector();
456 String arg5
= this.jTextFieldHelpText
.getText();
457 String arg6
= this.jComboBoxEventGroup
.getSelectedItem().toString();
458 id
= new EventsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
462 public EventsIdentification
getId() {
466 public void setId(EventsIdentification id
) {