]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateLibraryClass.java
8e796d48f142c859b1b3b2eb718645a36cba8b70
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
.event
.ActionEvent
;
28 import java
.awt
.event
.ActionListener
;
32 GUI for update library class in spd file
34 @since PackageEditor 1.0
36 public class UpdateLibraryClass
extends JFrame
implements ActionListener
{
38 private JPanel jContentPane
= null;
40 private JScrollPane jScrollPane
= null;
42 private JTable jTable
= null;
44 private SpdFileContents sfc
= null;
46 private JButton jButtonOk
= null;
48 private JButton jButtonCancel
= null;
50 private DefaultTableModel model
= null;
52 private JButton jButton
= null;
55 This is the default constructor
57 public UpdateLibraryClass(SpdFileContents sfc
) {
64 public void actionPerformed(ActionEvent arg0
) {
65 if (arg0
.getSource() == jButtonOk
) {
70 if (arg0
.getSource() == jButtonCancel
) {
75 if (arg0
.getSource() == jButton
) {
76 String
[] o
= { "", "" };
82 This method initializes this
86 private void initialize() {
87 this.setSize(604, 553);
88 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
89 this.setTitle("Update Library Class Declarations");
90 this.setContentPane(getJContentPane());
94 This method initializes jContentPane
96 @return javax.swing.JPanel
98 private JPanel
getJContentPane() {
99 if (jContentPane
== null) {
100 jContentPane
= new JPanel();
101 jContentPane
.setLayout(null);
102 jContentPane
.add(getJScrollPane(), null);
103 jContentPane
.add(getJButtonOk(), null);
104 jContentPane
.add(getJButtonCancel(), null);
105 jContentPane
.add(getJButton(), null);
111 This method initializes jScrollPane
113 @return javax.swing.JScrollPane
115 private JScrollPane
getJScrollPane() {
116 if (jScrollPane
== null) {
117 jScrollPane
= new JScrollPane();
118 jScrollPane
.setBounds(new java
.awt
.Rectangle(38, 45, 453, 419));
119 jScrollPane
.setViewportView(getJTable());
125 This method initializes jTable
127 @return javax.swing.JTable
129 private JTable
getJTable() {
130 if (jTable
== null) {
131 model
= new DefaultTableModel();
132 jTable
= new JTable(model
);
133 jTable
.setRowHeight(20);
134 model
.addColumn("LibraryClass");
135 model
.addColumn("IncludeHeader");
136 if (sfc
.getSpdLibClassDeclarationCount() == 0) {
140 // initialize table using SpdFileContents object
142 String
[][] saa
= new String
[sfc
.getSpdLibClassDeclarationCount()][2];
143 sfc
.getSpdLibClassDeclarations(saa
);
145 while (i
< saa
.length
) {
146 model
.addRow(saa
[i
]);
155 Remove original library classes before saving updated ones
157 protected void save() {
158 if (jTable
.isEditing()) {
159 jTable
.getCellEditor().stopCellEditing();
161 sfc
.removeSpdLibClass();
162 int rowCount
= model
.getRowCount();
164 while (i
< rowCount
) {
165 String libClass
= null;
166 if (model
.getValueAt(i
, 0) != null) {
167 libClass
= model
.getValueAt(i
, 0).toString();
169 String headerFile
= null;
170 if (model
.getValueAt(i
, 1) != null) {
171 headerFile
= model
.getValueAt(i
, 1).toString();
173 sfc
.genSpdLibClassDeclarations(libClass
, null, headerFile
, null, null, null, null, null, null, null);
179 This method initializes jButtonOk
181 @return javax.swing.JButton
183 private JButton
getJButtonOk() {
184 if (jButtonOk
== null) {
185 jButtonOk
= new JButton();
186 jButtonOk
.setText("Ok");
187 jButtonOk
.setSize(new java
.awt
.Dimension(84, 20));
188 jButtonOk
.setLocation(new java
.awt
.Point(316, 486));
189 jButtonOk
.addActionListener(this);
195 This method initializes jButtonCancel
197 @return javax.swing.JButton
199 private JButton
getJButtonCancel() {
200 if (jButtonCancel
== null) {
201 jButtonCancel
= new JButton();
202 jButtonCancel
.setText("Cancel");
203 jButtonCancel
.setSize(new java
.awt
.Dimension(82, 20));
204 jButtonCancel
.setLocation(new java
.awt
.Point(411, 486));
205 jButtonCancel
.addActionListener(this);
207 return jButtonCancel
;
211 This method initializes jButton
213 @return javax.swing.JButton
215 private JButton
getJButton() {
216 if (jButton
== null) {
217 jButton
= new JButton();
218 jButton
.setBounds(new java
.awt
.Rectangle(221, 486, 79, 19));
219 jButton
.setText("Insert");
220 jButton
.addActionListener(this);
224 } // @jve:decl-index=0:visual-constraint="11,7"