]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateMsaFile.java
Initial import.
[mirror_edk2.git] / Tools / Source / PackageEditor / src / org / tianocore / packaging / UpdateMsaFile.java
1 /** @file
2 Java class UpdateLibraryClass is GUI for msa files in spd file.
3
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
9
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.
12 **/
13 package org.tianocore.packaging;
14
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;
20
21 import javax.swing.JScrollPane;
22 import javax.swing.JTable;
23 import javax.swing.table.*;
24
25 import org.tianocore.common.Tools;
26
27 import java.awt.event.ActionEvent;
28 import java.awt.event.ActionListener;
29
30 /**
31 GUI for msa files in spd file
32
33 @since PackageEditor 1.0
34 **/
35 public class UpdateMsaFile extends JFrame implements ActionListener {
36
37 private JPanel jContentPane = null;
38
39 private JScrollPane jScrollPane = null;
40
41 private JTable jTable = null;
42
43 private SpdFileContents sfc = null;
44
45 private JButton jButtonOk = null;
46
47 private JButton jButtonCancel = null;
48
49 private DefaultTableModel model = null;
50
51 private JButton jButton = null;
52
53 /**
54 This is the default constructor
55 **/
56 public UpdateMsaFile(SpdFileContents sfc) {
57 super();
58 this.sfc = sfc;
59 initialize();
60
61 }
62
63 public void actionPerformed(ActionEvent arg0) {
64 if (arg0.getSource() == jButtonOk) {
65 this.save();
66 this.dispose();
67
68 }
69 if (arg0.getSource() == jButtonCancel) {
70 this.dispose();
71
72 }
73 if (arg0.getSource() == jButton) {
74 String[] o = { "" };
75 model.addRow(o);
76 }
77 }
78
79 /**
80 This method initializes this
81
82 @return void
83 **/
84 private void initialize() {
85 this.setSize(604, 553);
86 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
87 this.setTitle("Update MSA Files");
88 this.setContentPane(getJContentPane());
89 }
90
91 /**
92 This method initializes jContentPane
93
94 @return javax.swing.JPanel
95 **/
96 private JPanel getJContentPane() {
97 if (jContentPane == null) {
98 jContentPane = new JPanel();
99 jContentPane.setLayout(null);
100 jContentPane.add(getJScrollPane(), null);
101 jContentPane.add(getJButtonOk(), null);
102 jContentPane.add(getJButtonCancel(), null);
103 jContentPane.add(getJButton(), null);
104 }
105 return jContentPane;
106 }
107
108 /**
109 This method initializes jScrollPane
110
111 @return javax.swing.JScrollPane
112 **/
113 private JScrollPane getJScrollPane() {
114 if (jScrollPane == null) {
115 jScrollPane = new JScrollPane();
116 jScrollPane.setBounds(new java.awt.Rectangle(38, 45, 453, 419));
117 jScrollPane.setViewportView(getJTable());
118 }
119 return jScrollPane;
120 }
121
122 /**
123 This method initializes jTable
124
125 @return javax.swing.JTable
126 **/
127 private JTable getJTable() {
128 if (jTable == null) {
129 model = new DefaultTableModel();
130 jTable = new JTable(model);
131 jTable.setRowHeight(20);
132 model.addColumn("MSA File");
133
134 if (sfc.getSpdMsaFileCount() == 0) {
135 return jTable;
136 }
137 //
138 // initialize table using SpdFileContents object
139 //
140 String[][] saa = new String[sfc.getSpdMsaFileCount()][1];
141 sfc.getSpdMsaFiles(saa);
142 int i = 0;
143 while (i < saa.length) {
144 model.addRow(saa[i]);
145 i++;
146 }
147 }
148 return jTable;
149 }
150
151 /**
152 Remove original Msa files before saving updated ones
153 **/
154 protected void save() {
155
156 sfc.removeSpdMsaFile();
157 int rowCount = jTable.getRowCount();
158 int i = 0;
159 while (i < rowCount) {
160 String msaFile = null;
161 if (jTable.getValueAt(i, 0) != null) {
162 msaFile = jTable.getValueAt(i, 0).toString();
163 }
164 sfc.genSpdMsaFiles(msaFile, null);
165 i++;
166 }
167 }
168
169 /**
170 This method initializes jButtonOk
171
172 @return javax.swing.JButton
173 **/
174 private JButton getJButtonOk() {
175 if (jButtonOk == null) {
176 jButtonOk = new JButton();
177 jButtonOk.setText("Ok");
178 jButtonOk.setSize(new java.awt.Dimension(84, 20));
179 jButtonOk.setLocation(new java.awt.Point(316, 486));
180 jButtonOk.addActionListener(this);
181 }
182 return jButtonOk;
183 }
184
185 /**
186 This method initializes jButtonCancel
187
188 @return javax.swing.JButton
189 **/
190 private JButton getJButtonCancel() {
191 if (jButtonCancel == null) {
192 jButtonCancel = new JButton();
193 jButtonCancel.setText("Cancel");
194 jButtonCancel.setSize(new java.awt.Dimension(82, 20));
195 jButtonCancel.setLocation(new java.awt.Point(411, 486));
196 jButtonCancel.addActionListener(this);
197 }
198 return jButtonCancel;
199 }
200
201 /**
202 This method initializes jButton
203
204 @return javax.swing.JButton
205 **/
206 private JButton getJButton() {
207 if (jButton == null) {
208 jButton = new JButton();
209 jButton.setBounds(new java.awt.Rectangle(219, 486, 79, 19));
210 jButton.setText("Insert");
211 jButton.addActionListener(this);
212 }
213 return jButton;
214 }
215
216 } // @jve:decl-index=0:visual-constraint="11,7"
217