]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateMsaFile.java
2 Java class UpdateLibraryClass is GUI for msa files 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
;
33 GUI for msa files in spd file
35 @since PackageEditor 1.0
37 public class UpdateMsaFile
extends JFrame
implements ActionListener
{
39 private JPanel jContentPane
= null;
41 private JScrollPane jScrollPane
= null;
43 private JTable jTable
= null;
45 private SpdFileContents sfc
= null;
47 private JButton jButtonOk
= null;
49 private JButton jButtonCancel
= null;
51 private DefaultTableModel model
= null;
53 private JButton jButton
= null;
56 This is the default constructor
58 public UpdateMsaFile(SpdFileContents sfc
) {
65 public void actionPerformed(ActionEvent arg0
) {
66 if (arg0
.getSource() == jButtonOk
) {
71 if (arg0
.getSource() == jButtonCancel
) {
75 if (arg0
.getSource() == jButton
) {
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 MSA Files");
90 this.setContentPane(getJContentPane());
94 Start the window at the center of screen
97 protected void centerWindow(int intWidth
, int intHeight
) {
98 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
99 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
103 Start the window at the center of screen
106 protected void centerWindow() {
107 centerWindow(this.getSize().width
, this.getSize().height
);
110 This method initializes jContentPane
112 @return javax.swing.JPanel
114 private JPanel
getJContentPane() {
115 if (jContentPane
== null) {
116 jContentPane
= new JPanel();
117 jContentPane
.setLayout(null);
118 jContentPane
.add(getJScrollPane(), null);
119 jContentPane
.add(getJButtonOk(), null);
120 jContentPane
.add(getJButtonCancel(), null);
121 jContentPane
.add(getJButton(), null);
127 This method initializes jScrollPane
129 @return javax.swing.JScrollPane
131 private JScrollPane
getJScrollPane() {
132 if (jScrollPane
== null) {
133 jScrollPane
= new JScrollPane();
134 jScrollPane
.setBounds(new java
.awt
.Rectangle(38, 45, 453, 419));
135 jScrollPane
.setViewportView(getJTable());
141 This method initializes jTable
143 @return javax.swing.JTable
145 private JTable
getJTable() {
146 if (jTable
== null) {
147 model
= new DefaultTableModel();
148 jTable
= new JTable(model
);
149 jTable
.setRowHeight(20);
150 model
.addColumn("MSA File");
152 if (sfc
.getSpdMsaFileCount() == 0) {
156 // initialize table using SpdFileContents object
158 String
[][] saa
= new String
[sfc
.getSpdMsaFileCount()][1];
159 sfc
.getSpdMsaFiles(saa
);
161 while (i
< saa
.length
) {
162 model
.addRow(saa
[i
]);
170 Remove original Msa files before saving updated ones
172 protected void save() {
173 if (jTable
.isEditing()) {
174 jTable
.getCellEditor().stopCellEditing();
176 sfc
.removeSpdMsaFile();
177 int rowCount
= jTable
.getRowCount();
179 while (i
< rowCount
) {
180 String msaFile
= null;
181 if (jTable
.getValueAt(i
, 0) != null) {
182 msaFile
= jTable
.getValueAt(i
, 0).toString();
184 sfc
.genSpdMsaFiles(msaFile
, null);
190 This method initializes jButtonOk
192 @return javax.swing.JButton
194 private JButton
getJButtonOk() {
195 if (jButtonOk
== null) {
196 jButtonOk
= new JButton();
197 jButtonOk
.setText("Ok");
198 jButtonOk
.setSize(new java
.awt
.Dimension(84, 20));
199 jButtonOk
.setLocation(new java
.awt
.Point(316, 486));
200 jButtonOk
.addActionListener(this);
206 This method initializes jButtonCancel
208 @return javax.swing.JButton
210 private JButton
getJButtonCancel() {
211 if (jButtonCancel
== null) {
212 jButtonCancel
= new JButton();
213 jButtonCancel
.setText("Cancel");
214 jButtonCancel
.setSize(new java
.awt
.Dimension(82, 20));
215 jButtonCancel
.setLocation(new java
.awt
.Point(411, 486));
216 jButtonCancel
.addActionListener(this);
218 return jButtonCancel
;
222 This method initializes jButton
224 @return javax.swing.JButton
226 private JButton
getJButton() {
227 if (jButton
== null) {
228 jButton
= new JButton();
229 jButton
.setBounds(new java
.awt
.Rectangle(219, 486, 79, 19));
230 jButton
.setText("Insert");
231 jButton
.addActionListener(this);
236 } // @jve:decl-index=0:visual-constraint="11,7"