2 Java class UpdatePCD is GUI for update PCD definitions in spd file.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 package org
.tianocore
.packaging
;
15 import javax
.swing
.DefaultCellEditor
;
16 import javax
.swing
.JComboBox
;
17 import javax
.swing
.JPanel
;
18 import javax
.swing
.JFrame
;
19 import javax
.swing
.JLabel
;
20 import javax
.swing
.JTextField
;
21 import javax
.swing
.JButton
;
23 import javax
.swing
.JScrollPane
;
24 import javax
.swing
.JTable
;
25 import javax
.swing
.table
.*;
27 import org
.tianocore
.common
.Tools
;
29 import java
.awt
.event
.ActionEvent
;
30 import java
.awt
.event
.ActionListener
;
34 GUI for update PCD definitions in spd file
36 @since PackageEditor 1.0
38 public class UpdatePCD
extends JFrame
implements ActionListener
{
40 private JPanel jContentPane
= null;
42 private SpdFileContents sfc
= null;
44 private JButton jButtonOk
= null;
46 private JButton jButtonCancel
= null;
48 private DefaultTableModel model
= null;
50 private String
[][] saa
= null;
52 private JScrollPane jScrollPane
= null;
54 private JTable jTable
= null;
56 private JButton jButton
= null;
59 This is the default constructor
61 public UpdatePCD(SpdFileContents sfc
) {
68 public void actionPerformed(ActionEvent arg0
) {
69 if (arg0
.getSource() == jButtonOk
) {
74 if (arg0
.getSource() == jButtonCancel
) {
78 if (arg0
.getSource() == jButton
) {
79 String
[] o
= { "FEATURE_FLAG", "", "", "UINT8", "0" };
86 This method initializes this
90 private void initialize() {
91 this.setSize(916, 486);
92 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
93 this.setTitle("Update PCD Definitions");
94 this.setContentPane(getJContentPane());
98 This method initializes jContentPane
100 @return javax.swing.JPanel
102 private JPanel
getJContentPane() {
103 if (jContentPane
== null) {
104 jContentPane
= new JPanel();
105 jContentPane
.setLayout(null);
106 jContentPane
.add(getJButtonOk(), null);
107 jContentPane
.add(getJButtonCancel(), null);
108 jContentPane
.add(getJScrollPane(), null);
109 jContentPane
.add(getJButton(), null);
115 Remove original Pcd definitions before saving updated ones
117 protected void save() {
118 sfc
.removeSpdPcdDefinition();
119 int rowCount
= model
.getRowCount();
121 while (i
< rowCount
) {
123 if (model
.getValueAt(i
, 1) != null) {
124 cName
= model
.getValueAt(i
, 1).toString();
127 if (model
.getValueAt(i
, 2) != null) {
128 token
= model
.getValueAt(i
, 2).toString();
130 String defaultVal
= null;
131 if (model
.getValueAt(i
, 4) != null) {
132 defaultVal
= model
.getValueAt(i
, 4).toString();
134 sfc
.genSpdPcdDefinitions(model
.getValueAt(i
, 0).toString(), cName
, token
,
135 model
.getValueAt(i
, 3).toString(), null, null, null, null, null, null, defaultVal
);
141 This method initializes jButtonOk
143 @return javax.swing.JButton
145 private JButton
getJButtonOk() {
146 if (jButtonOk
== null) {
147 jButtonOk
= new JButton();
148 jButtonOk
.setText("Ok");
149 jButtonOk
.setSize(new java
.awt
.Dimension(84, 20));
150 jButtonOk
.setLocation(new java
.awt
.Point(605, 404));
151 jButtonOk
.addActionListener(this);
157 This method initializes jButtonCancel
159 @return javax.swing.JButton
161 private JButton
getJButtonCancel() {
162 if (jButtonCancel
== null) {
163 jButtonCancel
= new JButton();
164 jButtonCancel
.setText("Cancel");
165 jButtonCancel
.setSize(new java
.awt
.Dimension(82, 20));
166 jButtonCancel
.setLocation(new java
.awt
.Point(712, 404));
167 jButtonCancel
.addActionListener(this);
169 return jButtonCancel
;
173 This method initializes jScrollPane
175 @return javax.swing.JScrollPane
177 private JScrollPane
getJScrollPane() {
178 if (jScrollPane
== null) {
179 jScrollPane
= new JScrollPane();
180 jScrollPane
.setHorizontalScrollBarPolicy(javax
.swing
.JScrollPane
.HORIZONTAL_SCROLLBAR_AS_NEEDED
);
181 jScrollPane
.setBounds(new java
.awt
.Rectangle(51, 62, 782, 304));
182 jScrollPane
.setViewportView(getJTable2());
188 This method initializes jTable
190 @return javax.swing.JTable
192 private JTable
getJTable2() {
193 if (jTable
== null) {
194 model
= new DefaultTableModel();
195 jTable
= new JTable(model
);
196 jTable
.setRowHeight(20);
197 model
.addColumn("ItemType");
198 model
.addColumn("C_Name");
199 model
.addColumn("Token");
200 model
.addColumn("DataType");
201 model
.addColumn("DefaultValue");
203 // Using combobox to display ItemType in table
205 JComboBox jComboBoxItemType
= new JComboBox();
206 jComboBoxItemType
.addItem("FEATURE_FLAG");
207 jComboBoxItemType
.addItem("FIXED_AT_BUILD");
208 jComboBoxItemType
.addItem("PATCHABLE_IN_MODULE");
209 jComboBoxItemType
.addItem("DYNAMIC");
210 jComboBoxItemType
.addItem("DYNAMIC_EX");
211 TableColumn itemTypeColumn
= jTable
.getColumnModel().getColumn(0);
212 itemTypeColumn
.setCellEditor(new DefaultCellEditor(jComboBoxItemType
));
214 // Using combobox to display data type in table
216 JComboBox jComboBoxDataType
= new JComboBox();
217 jComboBoxDataType
.addItem("UINT8");
218 jComboBoxDataType
.addItem("UINT16");
219 jComboBoxDataType
.addItem("UINT32");
220 jComboBoxDataType
.addItem("UINT64");
221 jComboBoxDataType
.addItem("VOID*");
222 jComboBoxDataType
.addItem("BOOLEAN");
223 TableColumn dataTypeColumn
= jTable
.getColumnModel().getColumn(3);
224 dataTypeColumn
.setCellEditor(new DefaultCellEditor(jComboBoxDataType
));
226 if (sfc
.getSpdPcdDefinitionCount() == 0) {
230 saa
= new String
[sfc
.getSpdPcdDefinitionCount()][5];
231 sfc
.getSpdPcdDefinitions(saa
);
233 while (i
< saa
.length
) {
234 model
.addRow(saa
[i
]);
243 This method initializes jButton
245 @return javax.swing.JButton
247 private JButton
getJButton() {
248 if (jButton
== null) {
249 jButton
= new JButton();
250 jButton
.setBounds(new java
.awt
.Rectangle(499, 404, 77, 20));
251 jButton
.setText("Insert");
252 jButton
.addActionListener(this);
256 } // @jve:decl-index=0:visual-constraint="11,7"