3 The file is used to create, update Ppi 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
.awt
.event
.ItemEvent
;
19 import java
.awt
.event
.ItemListener
;
20 import java
.util
.Vector
;
22 import javax
.swing
.JButton
;
23 import javax
.swing
.JComboBox
;
24 import javax
.swing
.JLabel
;
25 import javax
.swing
.JPanel
;
26 import javax
.swing
.JScrollPane
;
27 import javax
.swing
.JTextField
;
29 import org
.tianocore
.frameworkwizard
.common
.DataType
;
30 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
31 import org
.tianocore
.frameworkwizard
.common
.EnumerationData
;
32 import org
.tianocore
.frameworkwizard
.common
.Log
;
33 import org
.tianocore
.frameworkwizard
.common
.Tools
;
34 import org
.tianocore
.frameworkwizard
.common
.ui
.ArchCheckBox
;
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
.Ppis
.PpisIdentification
;
39 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
42 The class is used to create, update Ppi of MSA/MBD file
43 It extends IInternalFrame
46 public class PpisDlg
extends IDialog
implements ItemListener
{
49 /// Define class Serial Version UID
51 private static final long serialVersionUID
= -4284901202357037724L;
54 //Define class members
56 private JPanel jContentPane
= null;
58 private JLabel jLabelC_Name
= null;
60 private JComboBox jComboBoxCName
= null;
62 private JTextField jTextFieldFeatureFlag
= null;
64 private JLabel jLabelFeatureFlag
= null;
66 private JLabel jLabelUsage
= null;
68 private JComboBox jComboBoxUsage
= null;
70 private JLabel jLabelPpiType
= null;
72 private StarLabel jStarLabel1
= null;
74 private StarLabel jStarLabel2
= null;
76 private JComboBox jComboBoxPpiType
= null;
78 private JLabel jLabelArch
= null;
80 private JScrollPane jScrollPane
= null;
82 private JLabel jLabelHelpText
= null;
84 private JTextField jTextFieldHelpText
= null;
86 private ArchCheckBox jArchCheckBox
= null;
88 private JButton jButtonOk
= null;
90 private JButton jButtonCancel
= null;
95 private PpisIdentification id
= null;
97 private WorkspaceTools wt
= new WorkspaceTools();
99 private EnumerationData ed
= new EnumerationData();
102 This method initializes jTextFieldC_Name
104 @return javax.swing.JTextField jTextFieldC_Name
107 private JComboBox
getJComboBoxCName() {
108 if (jComboBoxCName
== null) {
109 jComboBoxCName
= new JComboBox();
110 jComboBoxCName
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
111 jComboBoxCName
.setPreferredSize(new java
.awt
.Dimension(320, 20));
113 return jComboBoxCName
;
117 This method initializes jTextFieldFeatureFlag
119 @return javax.swing.JTextField jTextFieldFeatureFlag
122 private JTextField
getJTextFieldFeatureFlag() {
123 if (jTextFieldFeatureFlag
== null) {
124 jTextFieldFeatureFlag
= new JTextField();
125 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(160, 110, 320, 20));
126 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
128 return jTextFieldFeatureFlag
;
132 This method initializes jComboBox
134 @return javax.swing.JComboBox jComboBoxUsage
137 private JComboBox
getJComboBox() {
138 if (jComboBoxUsage
== null) {
139 jComboBoxUsage
= new JComboBox();
140 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(160, 60, 320, 20));
141 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
143 return jComboBoxUsage
;
147 * This method initializes jComboBoxPpiType
149 * @return javax.swing.JComboBox
151 private JComboBox
getJComboBoxPpiType() {
152 if (jComboBoxPpiType
== null) {
153 jComboBoxPpiType
= new JComboBox();
154 jComboBoxPpiType
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
155 jComboBoxPpiType
.setPreferredSize(new java
.awt
.Dimension(320, 20));
156 jComboBoxPpiType
.addItemListener(this);
158 return jComboBoxPpiType
;
162 This method initializes jScrollPane
164 @return javax.swing.JScrollPane
166 private JScrollPane
getJScrollPane() {
167 if (jScrollPane
== null) {
168 jScrollPane
= new JScrollPane();
169 jScrollPane
.setViewportView(getJContentPane());
175 This method initializes jTextFieldHelpText
177 @return javax.swing.JTextField
180 private JTextField
getJTextFieldHelpText() {
181 if (jTextFieldHelpText
== null) {
182 jTextFieldHelpText
= new JTextField();
183 jTextFieldHelpText
.setBounds(new java
.awt
.Rectangle(160, 85, 320, 20));
184 jTextFieldHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 20));
186 return jTextFieldHelpText
;
190 This method initializes jButtonOk
192 @return javax.swing.JButton
195 private JButton
getJButtonOk() {
196 if (jButtonOk
== null) {
197 jButtonOk
= new JButton();
198 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 165, 90, 20));
199 jButtonOk
.setText("Ok");
200 jButtonOk
.addActionListener(this);
206 This method initializes jButtonCancel
208 @return javax.swing.JButton
211 private JButton
getJButtonCancel() {
212 if (jButtonCancel
== null) {
213 jButtonCancel
= new JButton();
214 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 165, 90, 20));
215 jButtonCancel
.setText("Cancel");
216 jButtonCancel
.addActionListener(this);
218 return jButtonCancel
;
221 public static void main(String
[] args
) {
226 This method initializes this
229 private void init() {
230 this.setSize(510, 240);
231 this.setContentPane(getJScrollPane());
232 this.setTitle("Ppis");
238 This method initializes this
239 Fill values to all fields if these values are not empty
244 private void init(PpisIdentification inPpisId
) {
248 if (this.id
!= null) {
249 this.jComboBoxCName
.setSelectedItem(id
.getName());
250 this.jComboBoxPpiType
.setSelectedItem(id
.getType());
251 this.jComboBoxUsage
.setSelectedItem(id
.getUsage());
252 this.jTextFieldHelpText
.setText(id
.getHelp());
253 this.jTextFieldFeatureFlag
.setText(id
.getFeatureFlag());
254 this.jArchCheckBox
.setSelectedItems(id
.getSupArchList());
259 This is the override edit constructor
261 @param inProtocolsIdentification
265 public PpisDlg(PpisIdentification inPpisIdentification
, IFrame iFrame
) {
267 init(inPpisIdentification
);
271 This method initializes jContentPane
273 @return javax.swing.JPanel jContentPane
276 private JPanel
getJContentPane() {
277 if (jContentPane
== null) {
278 jArchCheckBox
= new ArchCheckBox();
279 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(160, 135, 320, 20));
280 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
281 jLabelArch
= new JLabel();
282 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 135, 140, 20));
283 jLabelArch
.setText("Arch");
284 jLabelPpiType
= new JLabel();
285 jLabelPpiType
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
286 jLabelPpiType
.setText("Ppi Type");
287 jLabelUsage
= new JLabel();
288 jLabelUsage
.setText("Usage");
289 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 60, 140, 20));
290 jLabelFeatureFlag
= new JLabel();
291 jLabelFeatureFlag
.setText("Feature Flag");
292 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(15, 110, 140, 20));
293 jLabelC_Name
= new JLabel();
294 jLabelC_Name
.setText("C Name Type");
295 jLabelC_Name
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
296 jLabelHelpText
= new JLabel();
297 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(14, 85, 140, 20));
298 jLabelHelpText
.setText("Help Text");
300 jContentPane
= new JPanel();
301 jContentPane
.setLayout(null);
302 jContentPane
.setPreferredSize(new java
.awt
.Dimension(490, 190));
304 jContentPane
.add(jLabelC_Name
, null);
305 jContentPane
.add(getJComboBoxCName(), null);
306 jContentPane
.add(getJTextFieldFeatureFlag(), null);
307 jContentPane
.add(jLabelFeatureFlag
, null);
308 jContentPane
.add(jLabelUsage
, null);
309 jContentPane
.add(getJComboBox(), null);
310 jContentPane
.add(getJComboBoxPpiType(), null);
311 jContentPane
.add(jLabelArch
, null);
312 jContentPane
.add(jLabelPpiType
, null);
313 jStarLabel1
= new StarLabel();
314 jStarLabel1
.setBounds(new java
.awt
.Rectangle(0, 10, 10, 20));
315 jStarLabel2
= new StarLabel();
316 jStarLabel2
.setBounds(new java
.awt
.Rectangle(0, 35, 10, 20));
318 jContentPane
.add(jStarLabel1
, null);
319 jContentPane
.add(jStarLabel2
, null);
321 jContentPane
.add(jLabelHelpText
, null);
322 jContentPane
.add(getJTextFieldHelpText(), null);
323 jContentPane
.add(jArchCheckBox
, null);
324 jContentPane
.add(getJButtonOk(), null);
325 jContentPane
.add(getJButtonCancel(), null);
331 This method initializes Usage type
334 private void initFrame() {
335 Tools
.generateComboBoxByVector(jComboBoxCName
, wt
.getAllPpiDeclarationsFromWorkspace());
336 Tools
.generateComboBoxByVector(jComboBoxPpiType
, ed
.getVPpiType());
337 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVPpiUsage());
341 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
343 * Override actionPerformed to listen all actions
346 public void actionPerformed(ActionEvent arg0
) {
347 if (arg0
.getSource() == jButtonOk
) {
350 this.returnType
= DataType
.RETURN_TYPE_OK
;
351 this.setVisible(false);
355 if (arg0
.getSource() == jButtonCancel
) {
356 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
357 this.setVisible(false);
362 Data validation for all fields
364 @retval true - All datas are valid
365 @retval false - At least one data is invalid
368 public boolean checkAdd() {
370 // Check if all fields have correct data types
376 if (!isEmpty(this.jComboBoxCName
.getSelectedItem().toString())) {
377 if (!DataValidation
.isC_NameType(this.jComboBoxCName
.getSelectedItem().toString())) {
378 Log
.wrn("Update Ppis", "Incorrect data type for Ppi/PpiNotify Name");
386 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
387 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
388 Log
.wrn("Update Ppis", "Incorrect data type for Feature Flag");
396 private PpisIdentification
getCurrentPpis() {
397 String arg0
= this.jComboBoxCName
.getSelectedItem().toString();
398 String arg1
= this.jComboBoxPpiType
.getSelectedItem().toString();
399 String arg2
= this.jComboBoxUsage
.getSelectedItem().toString();
401 String arg3
= this.jTextFieldFeatureFlag
.getText();
402 Vector
<String
> arg4
= this.jArchCheckBox
.getSelectedItemsVector();
403 String arg5
= this.jTextFieldHelpText
.getText();
405 id
= new PpisIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
);
410 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
412 * Reflesh the frame when selected item changed
415 public void itemStateChanged(ItemEvent arg0
) {
416 if (arg0
.getSource() == this.jComboBoxPpiType
&& arg0
.getStateChange() == ItemEvent
.SELECTED
) {
417 if (this.jComboBoxPpiType
.getSelectedItem().toString().equals(ed
.getVPpiType().get(0))) {
418 Tools
.generateComboBoxByVector(this.jComboBoxUsage
, ed
.getVPpiUsage());
420 Tools
.generateComboBoxByVector(this.jComboBoxUsage
, ed
.getVPpiNotifyUsage());
425 public PpisIdentification
getId() {
429 public void setId(PpisIdentification id
) {