]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateAction.java
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@671 6f19259b...
[mirror_edk2.git] / Tools / Source / PackageEditor / src / org / tianocore / packaging / UpdateAction.java
1 /** @file
2 Java class UpdateAction is GUI for update 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 java.awt.BorderLayout;
16 import java.awt.Dimension;
17 import java.awt.Toolkit;
18
19 import javax.swing.JFileChooser;
20 import javax.swing.JOptionPane;
21 import javax.swing.JPanel;
22 import javax.swing.JFrame;
23 import java.awt.GridLayout;
24 import java.io.File;
25
26 import javax.swing.JButton;
27
28 /**
29 GUI for update spd file
30
31 @since PackageEditor 1.0
32 **/
33 public class UpdateAction extends JFrame {
34
35 static JFrame frame;
36
37 private JPanel jContentPane = null;
38
39 private JButton jButton = null;
40
41 private JButton jButton1 = null;
42
43 private JButton jButton2 = null;
44
45 private JButton jButton3 = null;
46
47 private JButton jButton4 = null;
48
49 private JButton jButton5 = null;
50
51 private JButton jButton6 = null;
52
53 private JButton jButton7 = null;
54
55 private SpdFileContents sfc = null;
56
57 private JFrame pThis = null; // @jve:decl-index=0:visual-constraint="322,10"
58
59 private JButton jButton8 = null;
60
61 private JButton jButton9 = null;
62
63 /**
64 This is the default constructor
65 **/
66 public UpdateAction(SpdFileContents sfc) {
67 super();
68 initialize();
69 this.sfc = sfc;
70 }
71
72 /**
73 This method initializes this
74
75 @return void
76 **/
77 private void initialize() {
78 this.setSize(300, 333);
79 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
80 this.setContentPane(getJContentPane());
81 this.setTitle("Please Choose an Action");
82 this.centerWindow();
83 this.pThis = this;
84 pThis.setSize(new java.awt.Dimension(316,399));
85 }
86
87 /**
88 Start the window at the center of screen
89
90 **/
91 protected void centerWindow(int intWidth, int intHeight) {
92 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
93 this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
94 }
95
96 /**
97 Start the window at the center of screen
98
99 **/
100 protected void centerWindow() {
101 centerWindow(this.getSize().width, this.getSize().height);
102 }
103
104 /**
105 This method initializes jContentPane
106
107 @return javax.swing.JPanel
108 **/
109 private JPanel getJContentPane() {
110 if (jContentPane == null) {
111 GridLayout gridLayout = new GridLayout();
112 gridLayout.setRows(10);
113 gridLayout.setColumns(1);
114 jContentPane = new JPanel();
115 jContentPane.setLayout(gridLayout);
116 jContentPane.add(getJButton8(), null);
117 jContentPane.add(getJButton7(), null);
118 jContentPane.add(getJButton6(), null);
119 jContentPane.add(getJButton5(), null);
120 jContentPane.add(getJButton4(), null);
121 jContentPane.add(getJButton3(), null);
122 jContentPane.add(getJButton2(), null);
123 jContentPane.add(getJButton1(), null);
124 jContentPane.add(getJButton(), null);
125 jContentPane.add(getJButton9(), null);
126 }
127 return jContentPane;
128 }
129
130 /**
131 This method initializes jButton
132
133 @return javax.swing.JButton
134 **/
135 private JButton getJButton() {
136 if (jButton == null) {
137 jButton = new JButton();
138 jButton.setText("Save");
139 jButton.addMouseListener(new java.awt.event.MouseAdapter() {
140 public void mouseClicked(java.awt.event.MouseEvent e) {
141 JFileChooser chooser = new JFileChooser(sfc.getFile());
142 chooser.setMultiSelectionEnabled(false);
143
144 int retval = chooser.showSaveDialog(frame);
145 if (retval == JFileChooser.APPROVE_OPTION) {
146 try {
147 File theFile = chooser.getSelectedFile();
148 if (theFile.exists()) {
149 int retVal = JOptionPane.showConfirmDialog(frame, "Are you sure to replace the exising one?", "File Exists",
150 JOptionPane.YES_NO_OPTION);
151 if (retVal == JOptionPane.NO_OPTION) {
152 return;
153 }
154 }
155 sfc.saveAs(theFile);
156
157 } catch (Exception ee) {
158 System.out.println(ee.toString());
159 }
160 // pThis.dispose();
161 }
162
163 }
164 });
165 }
166 return jButton;
167 }
168
169 /**
170 This method initializes jButton1
171
172 @return javax.swing.JButton
173 **/
174 private JButton getJButton1() {
175 if (jButton1 == null) {
176 jButton1 = new JButton();
177 jButton1.setText("Update PCD Information");
178 jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
179 public void mouseClicked(java.awt.event.MouseEvent e) {
180 ModalFrameUtil.showAsModal(new UpdatePCD(sfc), pThis);
181 }
182 });
183 }
184 return jButton1;
185 }
186
187 /**
188 This method initializes jButton2
189
190 @return javax.swing.JButton
191 **/
192 private JButton getJButton2() {
193 if (jButton2 == null) {
194 jButton2 = new JButton();
195 jButton2.setText("Update PPI Declarations");
196 jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
197 public void mouseClicked(java.awt.event.MouseEvent e) {
198 ModalFrameUtil.showAsModal(new UpdatePpi(sfc), pThis);
199 }
200 });
201 }
202 return jButton2;
203 }
204
205 /**
206 This method initializes jButton3
207
208 @return javax.swing.JButton
209 **/
210 private JButton getJButton3() {
211 if (jButton3 == null) {
212 jButton3 = new JButton();
213 jButton3.setText("Update Protocol Declarations");
214 jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
215 public void mouseClicked(java.awt.event.MouseEvent e) {
216 ModalFrameUtil.showAsModal(new UpdateProtocols(sfc), pThis);
217 }
218 });
219 }
220 return jButton3;
221 }
222
223 /**
224 This method initializes jButton4
225
226 @return javax.swing.JButton
227 **/
228 private JButton getJButton4() {
229 if (jButton4 == null) {
230 jButton4 = new JButton();
231 jButton4.setText("Update GUID Declarations");
232 jButton4.addMouseListener(new java.awt.event.MouseAdapter() {
233 public void mouseClicked(java.awt.event.MouseEvent e) {
234 ModalFrameUtil.showAsModal(new UpdateGuids(sfc), pThis);
235 }
236 });
237 }
238 return jButton4;
239 }
240
241 /**
242 This method initializes jButton5
243
244 @return javax.swing.JButton
245 **/
246 private JButton getJButton5() {
247 if (jButton5 == null) {
248 jButton5 = new JButton();
249 jButton5.setText("Update Package Headers");
250 jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
251 public void mouseClicked(java.awt.event.MouseEvent e) {
252 ModalFrameUtil.showAsModal(new UpdatePkgHeader(sfc), pThis);
253 }
254 });
255 }
256 return jButton5;
257 }
258
259 /**
260 This method initializes jButton6
261
262 @return javax.swing.JButton
263 **/
264 private JButton getJButton6() {
265 if (jButton6 == null) {
266 jButton6 = new JButton();
267 jButton6.setText("Update MSA Files");
268 jButton6.addMouseListener(new java.awt.event.MouseAdapter() {
269 public void mouseClicked(java.awt.event.MouseEvent e) {
270 ModalFrameUtil.showAsModal(new UpdateMsaFile(sfc), pThis);
271 }
272 });
273 }
274 return jButton6;
275 }
276
277 /**
278 This method initializes jButton7
279
280 @return javax.swing.JButton
281 **/
282 private JButton getJButton7() {
283 if (jButton7 == null) {
284 jButton7 = new JButton();
285 jButton7.setText("Update Library Classes");
286 jButton7.addMouseListener(new java.awt.event.MouseAdapter() {
287 public void mouseClicked(java.awt.event.MouseEvent e) {
288 ModalFrameUtil.showAsModal(new UpdateLibraryClass(sfc), pThis);
289 }
290 });
291 }
292 return jButton7;
293 }
294
295 /**
296 This method initializes jButton8
297
298 @return javax.swing.JButton
299 **/
300 private JButton getJButton8() {
301 if (jButton8 == null) {
302 jButton8 = new JButton();
303 jButton8.setText("Update SPD Header");
304 jButton8.addMouseListener(new java.awt.event.MouseAdapter() {
305 public void mouseClicked(java.awt.event.MouseEvent e) {
306 ModalFrameUtil.showAsModal(new UpdateNew(sfc), pThis);
307 }
308 });
309 }
310 return jButton8;
311 }
312
313 private JButton getJButton9() {
314 if (jButton9 == null) {
315 jButton9 = new JButton();
316 jButton9.setText("Done");
317 jButton9.addMouseListener(new java.awt.event.MouseAdapter() {
318 public void mouseClicked(java.awt.event.MouseEvent e) {
319
320 pThis.dispose();
321
322 }
323 });
324 }
325 return jButton9;
326 }
327
328 } // @jve:decl-index=0:visual-constraint="104,41"