]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateGuids.java
2 Java class UpdateGuids is GUI for update GUID declarations 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 GUID declarations in spd file
36 @since PackageEditor 1.0
38 public class UpdateGuids
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 UpdateGuids(SpdFileContents sfc
) {
66 public void actionPerformed(ActionEvent arg0
) {
67 if (arg0
.getSource() == jButtonOk
) {
72 if (arg0
.getSource() == jButtonCancel
) {
76 if (arg0
.getSource() == jButton
) {
77 String
[] o
= { "", "", "" };
83 This method initializes this
87 private void initialize() {
88 this.setSize(669, 568);
89 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
90 this.setTitle("Update GUID Declarations");
91 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,586,315));
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("Name");
137 model
.addColumn("C_Name");
138 model
.addColumn("GUID");
139 if (sfc
.getSpdGuidDeclarationCount() == 0) {
143 // initialize table using SpdFileContents object
145 String
[][] saa
= new String
[sfc
.getSpdGuidDeclarationCount()][3];
146 sfc
.getSpdGuidDeclarations(saa
);
148 while (i
< saa
.length
) {
149 model
.addRow(saa
[i
]);
153 jTable
.getColumnModel().getColumn(2).setCellEditor(new GuidEditor());
159 Remove original GUID declarations before saving updated ones
161 protected void save() {
162 if (jTable
.isEditing()) {
163 jTable
.getCellEditor().stopCellEditing();
165 sfc
.removeSpdGuidDeclaration();
166 int rowCount
= model
.getRowCount();
169 while (i
< rowCount
) {
171 if (model
.getValueAt(i
, 0) != null) {
172 name
= model
.getValueAt(i
, 0).toString();
175 if (model
.getValueAt(i
, 1) != null) {
176 cName
= model
.getValueAt(i
, 1).toString();
179 if (model
.getValueAt(i
, 2) != null) {
180 guid
= model
.getValueAt(i
, 2).toString();
182 sfc
.genSpdGuidDeclarations(name
, cName
, guid
, null);
188 This method initializes jButtonOk
190 @return javax.swing.JButton
192 private JButton
getJButtonOk() {
193 if (jButtonOk
== null) {
194 jButtonOk
= new JButton();
195 jButtonOk
.setText("Ok");
196 jButtonOk
.setSize(new java
.awt
.Dimension(84, 20));
197 jButtonOk
.setLocation(new java
.awt
.Point(316, 486));
198 jButtonOk
.addActionListener(this);
204 This method initializes jButtonCancel
206 @return javax.swing.JButton
208 private JButton
getJButtonCancel() {
209 if (jButtonCancel
== null) {
210 jButtonCancel
= new JButton();
211 jButtonCancel
.setText("Cancel");
212 jButtonCancel
.setSize(new java
.awt
.Dimension(82, 20));
213 jButtonCancel
.setLocation(new java
.awt
.Point(411, 486));
214 jButtonCancel
.addActionListener(this);
216 return jButtonCancel
;
220 This method initializes jButton
222 @return javax.swing.JButton
224 private JButton
getJButton() {
225 if (jButton
== null) {
226 jButton
= new JButton();
227 jButton
.setBounds(new java
.awt
.Rectangle(219, 487, 78, 18));
228 jButton
.setText("Insert");
229 jButton
.addActionListener(this);
234 Start the window at the center of screen
237 protected void centerWindow(int intWidth
, int intHeight
) {
238 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
239 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
243 Start the window at the center of screen
246 protected void centerWindow() {
247 centerWindow(this.getSize().width
, this.getSize().height
);
249 } // @jve:decl-index=0:visual-constraint="11,7"