]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateLibraryClass.java
2 Java class UpdateLibraryClass is GUI for update library class 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
.JPanel
;
16 import javax
.swing
.JFrame
;
17 import javax
.swing
.JLabel
;
18 import javax
.swing
.JTextField
;
19 import javax
.swing
.JButton
;
21 import javax
.swing
.JScrollPane
;
22 import javax
.swing
.JTable
;
23 import javax
.swing
.table
.*;
25 import org
.tianocore
.common
.Tools
;
27 import java
.awt
.Dimension
;
28 import java
.awt
.Toolkit
;
29 import java
.awt
.event
.ActionEvent
;
30 import java
.awt
.event
.ActionListener
;
34 GUI for update library class in spd file
36 @since PackageEditor 1.0
38 public class UpdateLibraryClass
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 UpdateLibraryClass(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
= { "", "" };
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 Library Class Declarations");
92 this.setContentPane(getJContentPane());
96 Start the window at the center of screen
99 protected void centerWindow(int intWidth
, int intHeight
) {
100 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
101 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
105 Start the window at the center of screen
108 protected void centerWindow() {
109 centerWindow(this.getSize().width
, this.getSize().height
);
113 This method initializes jContentPane
115 @return javax.swing.JPanel
117 private JPanel
getJContentPane() {
118 if (jContentPane
== null) {
119 jContentPane
= new JPanel();
120 jContentPane
.setLayout(null);
121 jContentPane
.add(getJScrollPane(), null);
122 jContentPane
.add(getJButtonOk(), null);
123 jContentPane
.add(getJButtonCancel(), null);
124 jContentPane
.add(getJButton(), null);
130 This method initializes jScrollPane
132 @return javax.swing.JScrollPane
134 private JScrollPane
getJScrollPane() {
135 if (jScrollPane
== null) {
136 jScrollPane
= new JScrollPane();
137 jScrollPane
.setBounds(new java
.awt
.Rectangle(38, 45, 453, 419));
138 jScrollPane
.setViewportView(getJTable());
144 This method initializes jTable
146 @return javax.swing.JTable
148 private JTable
getJTable() {
149 if (jTable
== null) {
150 model
= new DefaultTableModel();
151 jTable
= new JTable(model
);
152 jTable
.setRowHeight(20);
153 model
.addColumn("LibraryClass");
154 model
.addColumn("IncludeHeader");
155 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
159 // initialize table using SpdFileContents object
161 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][2];
162 sfc
.getSpdLibClassDeclarations(saa
);
164 while (i
< saa
.length
) {
165 model
.addRow(saa
[i
]);
174 Remove original library classes before saving updated ones
176 protected void save() {
177 if (jTable
.isEditing()) {
178 jTable
.getCellEditor().stopCellEditing();
180 sfc
.removeSpdLibClass();
181 int rowCount
= model
.getRowCount();
183 while (i
< rowCount
) {
184 String libClass
= null;
185 if (model
.getValueAt(i
, 0) != null) {
186 libClass
= model
.getValueAt(i
, 0).toString();
188 String headerFile
= null;
189 if (model
.getValueAt(i
, 1) != null) {
190 headerFile
= model
.getValueAt(i
, 1).toString();
192 sfc
.genSpdLibClassDeclarations(libClass
, null, headerFile
, null, null, null, null, null, null, null);
198 This method initializes jButtonOk
200 @return javax.swing.JButton
202 private JButton
getJButtonOk() {
203 if (jButtonOk
== null) {
204 jButtonOk
= new JButton();
205 jButtonOk
.setText("Ok");
206 jButtonOk
.setSize(new java
.awt
.Dimension(84, 20));
207 jButtonOk
.setLocation(new java
.awt
.Point(316, 486));
208 jButtonOk
.addActionListener(this);
214 This method initializes jButtonCancel
216 @return javax.swing.JButton
218 private JButton
getJButtonCancel() {
219 if (jButtonCancel
== null) {
220 jButtonCancel
= new JButton();
221 jButtonCancel
.setText("Cancel");
222 jButtonCancel
.setSize(new java
.awt
.Dimension(82, 20));
223 jButtonCancel
.setLocation(new java
.awt
.Point(411, 486));
224 jButtonCancel
.addActionListener(this);
226 return jButtonCancel
;
230 This method initializes jButton
232 @return javax.swing.JButton
234 private JButton
getJButton() {
235 if (jButton
== null) {
236 jButton
= new JButton();
237 jButton
.setBounds(new java
.awt
.Rectangle(221, 486, 79, 19));
238 jButton
.setText("Insert");
239 jButton
.addActionListener(this);
243 } // @jve:decl-index=0:visual-constraint="11,7"