2 Java class UpdatePkgHeader is GUI for update Package Header 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 Package Header in spd file
36 @since PackageEditor 1.0
38 public class UpdatePkgHeader
extends JFrame
implements ActionListener
{
40 private JPanel jContentPane
= null;
42 private JScrollPane jScrollPane
= null;
44 private JTable jTable
= null;
46 private SpdFileContents sfc
= null;
48 private JButton jButtonOk
= null;
50 private JButton jButtonCancel
= null;
52 private DefaultTableModel model
= null;
54 private JButton jButton
= null;
57 This is the default constructor
59 public UpdatePkgHeader(SpdFileContents sfc
) {
66 public void actionPerformed(ActionEvent arg0
) {
67 if (arg0
.getSource() == jButtonOk
) {
72 if (arg0
.getSource() == jButtonCancel
) {
77 if (arg0
.getSource() == jButton
) {
78 String
[] o
= { "BASE", "" };
84 This method initializes this
88 private void initialize() {
89 this.setSize(604, 553);
90 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
91 this.setTitle("Update Package Headers");
92 this.setContentPane(getJContentPane());
96 This method initializes jContentPane
98 @return javax.swing.JPanel
100 private JPanel
getJContentPane() {
101 if (jContentPane
== null) {
102 jContentPane
= new JPanel();
103 jContentPane
.setLayout(null);
104 jContentPane
.add(getJScrollPane(), null);
105 jContentPane
.add(getJButtonOk(), null);
106 jContentPane
.add(getJButtonCancel(), null);
107 jContentPane
.add(getJButton(), null);
113 This method initializes jScrollPane
115 @return javax.swing.JScrollPane
117 private JScrollPane
getJScrollPane() {
118 if (jScrollPane
== null) {
119 jScrollPane
= new JScrollPane();
120 jScrollPane
.setBounds(new java
.awt
.Rectangle(38, 45, 453, 419));
121 jScrollPane
.setViewportView(getJTable());
127 This method initializes jTable
129 @return javax.swing.JTable
131 private JTable
getJTable() {
132 if (jTable
== null) {
133 model
= new DefaultTableModel();
134 jTable
= new JTable(model
);
135 jTable
.setRowHeight(20);
136 model
.addColumn("ModuleType");
137 model
.addColumn("IncludeHeader");
139 // Using combobox to display ModuleType in table
141 TableColumn typeColumn
= jTable
.getColumnModel().getColumn(0);
142 JComboBox jComboBoxSelect
= new JComboBox();
143 jComboBoxSelect
.addItem("BASE");
144 jComboBoxSelect
.addItem("SEC");
145 jComboBoxSelect
.addItem("PEI_CORE");
146 jComboBoxSelect
.addItem("PEIM");
147 jComboBoxSelect
.addItem("DXE_CORE");
148 jComboBoxSelect
.addItem("DXE_DRIVER");
149 jComboBoxSelect
.addItem("DXE_RUNTIME_DRIVER");
150 jComboBoxSelect
.addItem("DXE_SAL_DRIVER");
151 jComboBoxSelect
.addItem("DXE_SMM_DRIVER");
152 jComboBoxSelect
.addItem("TOOLS");
153 jComboBoxSelect
.addItem("UEFI_DRIVER");
154 jComboBoxSelect
.addItem("UEFI_APPLICATION");
155 jComboBoxSelect
.addItem("USER_DEFINED");
156 typeColumn
.setCellEditor(new DefaultCellEditor(jComboBoxSelect
));
158 if (sfc
.getSpdPackageHeaderCount() == 0) {
161 String
[][] saa
= new String
[sfc
.getSpdPackageHeaderCount()][2];
162 sfc
.getSpdPackageHeaders(saa
);
164 while (i
< saa
.length
) {
165 model
.addRow(saa
[i
]);
174 Remove original package headers before saving updated ones
176 protected void save() {
177 if (jTable
.isEditing()) {
178 jTable
.getCellEditor().stopCellEditing();
180 sfc
.removeSpdPkgHeader();
181 int rowCount
= model
.getRowCount();
183 while (i
< rowCount
) {
184 String headFile
= null;
185 if (model
.getValueAt(i
, 1) != null) {
186 headFile
= model
.getValueAt(i
, 1).toString();
188 sfc
.genSpdModuleHeaders(model
.getValueAt(i
, 0).toString(), headFile
, null, null, null, null, null, null);
194 This method initializes jButtonOk
196 @return javax.swing.JButton
198 private JButton
getJButtonOk() {
199 if (jButtonOk
== null) {
200 jButtonOk
= new JButton();
201 jButtonOk
.setText("Ok");
202 jButtonOk
.setSize(new java
.awt
.Dimension(84, 20));
203 jButtonOk
.setLocation(new java
.awt
.Point(316, 486));
204 jButtonOk
.addActionListener(this);
210 This method initializes jButtonCancel
212 @return javax.swing.JButton
214 private JButton
getJButtonCancel() {
215 if (jButtonCancel
== null) {
216 jButtonCancel
= new JButton();
217 jButtonCancel
.setText("Cancel");
218 jButtonCancel
.setSize(new java
.awt
.Dimension(82, 20));
219 jButtonCancel
.setLocation(new java
.awt
.Point(411, 486));
220 jButtonCancel
.addActionListener(this);
222 return jButtonCancel
;
226 This method initializes jButton
228 @return javax.swing.JButton
230 private JButton
getJButton() {
231 if (jButton
== null) {
232 jButton
= new JButton();
233 jButton
.setBounds(new java
.awt
.Rectangle(220, 486, 85, 20));
234 jButton
.setText("Insert");
235 jButton
.addActionListener(this);
239 } // @jve:decl-index=0:visual-constraint="11,7"