]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageAction.java
2 Java class PackageAction is GUI for create 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 java
.awt
.BorderLayout
;
16 import java
.awt
.Dimension
;
17 import java
.awt
.Toolkit
;
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
;
26 import javax
.swing
.JButton
;
27 import javax
.swing
.filechooser
.FileFilter
;
30 GUI for create spd file
32 @since PackageEditor 1.0
34 public class PackageAction
extends JFrame
{
38 private JPanel jContentPane
= null;
40 private JButton jButton
= null;
42 private JButton jButton1
= null;
44 private JButton jButton2
= null;
46 private JButton jButton3
= null;
48 private JButton jButton4
= null;
50 private JButton jButton5
= null;
52 private JButton jButton6
= null;
54 private JButton jButton7
= null;
57 /// SpdFileContents object passed from main
59 private SpdFileContents sfc
= null;
61 private JFrame pThis
= null; // @jve:decl-index=0:visual-constraint="304,10"
63 private JButton jButton8
= null;
65 private JButton jButton9
= null; // @jve:decl-index=0:visual-constraint="116,388"
68 This is the default constructor
70 public PackageAction(SpdFileContents sfc
) {
77 This method initializes this
81 private void initialize() {
82 this.setSize(305, 385);
83 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
84 this.setContentPane(getJContentPane());
85 this.setTitle("Please Choose an Action");
92 Start the window at the center of screen
95 protected void centerWindow(int intWidth
, int intHeight
) {
96 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
97 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
101 Start the window at the center of screen
104 protected void centerWindow() {
105 centerWindow(this.getSize().width
, this.getSize().height
);
109 This method initializes jContentPane
111 @return javax.swing.JPanel
113 private JPanel
getJContentPane() {
114 if (jContentPane
== null) {
115 GridLayout gridLayout
= new GridLayout();
116 gridLayout
.setRows(10);
117 gridLayout
.setColumns(1);
118 jContentPane
= new JPanel();
119 jContentPane
.setPreferredSize(new java
.awt
.Dimension(200,300));
120 jContentPane
.setLayout(gridLayout
);
121 jContentPane
.add(getJButton8(), null);
122 jContentPane
.add(getJButton7(), null);
123 jContentPane
.add(getJButton6(), null);
124 jContentPane
.add(getJButton5(), null);
125 jContentPane
.add(getJButton4(), null);
126 jContentPane
.add(getJButton3(), null);
127 jContentPane
.add(getJButton2(), null);
128 jContentPane
.add(getJButton1(), null);
129 jContentPane
.add(getJButton(), null);
130 jContentPane
.add(getJButton9(), null);
136 This method initializes jButton
138 @return javax.swing.JButton
140 private JButton
getJButton() {
141 final FileFilter filter
= new PkgFileFilter("spd");
143 if (jButton
== null) {
144 jButton
= new JButton();
145 jButton
.setText("Save");
146 jButton
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
147 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
149 // save sfc contents to file
151 JFileChooser chooser
= new JFileChooser(PackagingMain
.dirForNewSpd
);
152 chooser
.setMultiSelectionEnabled(false);
153 chooser
.setFileFilter(filter
);
155 int retval
= chooser
.showSaveDialog(frame
);
156 if (retval
== JFileChooser
.APPROVE_OPTION
) {
158 File theFile
= chooser
.getSelectedFile();
159 if (theFile
.exists()) {
160 int retVal
= JOptionPane
.showConfirmDialog(frame
, "Are you sure to replace the exising one?", "File Exists",
161 JOptionPane
.YES_NO_OPTION
);
162 if (retVal
== JOptionPane
.NO_OPTION
) {
168 } catch (Exception ee
) {
169 System
.out
.println(ee
.toString());
181 This method initializes jButton1
183 @return javax.swing.JButton
185 private JButton
getJButton1() {
186 if (jButton1
== null) {
187 jButton1
= new JButton();
188 jButton1
.setText("Add PCD Information");
189 jButton1
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
190 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
192 // Add PCD frame show modal
194 ModalFrameUtil
.showAsModal(new PackagePCD(sfc
), pThis
);
202 This method initializes jButton2
204 @return javax.swing.JButton
206 private JButton
getJButton2() {
207 if (jButton2
== null) {
208 jButton2
= new JButton();
209 jButton2
.setText("Add PPI Declarations");
210 jButton2
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
211 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
213 // Add PPI frame show modal
215 ModalFrameUtil
.showAsModal(new PackagePpi(sfc
), pThis
);
223 This method initializes jButton3
225 @return javax.swing.JButton
227 private JButton
getJButton3() {
228 if (jButton3
== null) {
229 jButton3
= new JButton();
230 jButton3
.setText("Add Protocol Declarations");
231 jButton3
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
232 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
233 ModalFrameUtil
.showAsModal(new PackageProtocols(sfc
), pThis
);
241 This method initializes jButton4
243 @return javax.swing.JButton
245 private JButton
getJButton4() {
246 if (jButton4
== null) {
247 jButton4
= new JButton();
248 jButton4
.setText("Add GUID Declarations");
249 jButton4
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
250 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
251 ModalFrameUtil
.showAsModal(new PackageGuids(sfc
), pThis
);
259 This method initializes jButton5
261 @return javax.swing.JButton
263 private JButton
getJButton5() {
264 if (jButton5
== null) {
265 jButton5
= new JButton();
266 jButton5
.setText("Add Package Headers");
267 jButton5
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
268 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
269 ModalFrameUtil
.showAsModal(new PackagePkgHeader(sfc
), pThis
);
277 This method initializes jButton6
279 @return javax.swing.JButton
281 private JButton
getJButton6() {
282 if (jButton6
== null) {
283 jButton6
= new JButton();
284 jButton6
.setText("Add MSA Files");
285 jButton6
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
286 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
287 ModalFrameUtil
.showAsModal(new PackageMsaFile(sfc
), pThis
);
295 This method initializes jButton7
297 @return javax.swing.JButton
299 private JButton
getJButton7() {
300 if (jButton7
== null) {
301 jButton7
= new JButton();
302 jButton7
.setText("Add Library Classes");
303 jButton7
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
304 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
305 ModalFrameUtil
.showAsModal(new PackageLibraryClass(sfc
), pThis
);
313 This method initializes jButton8
315 @return javax.swing.JButton
317 private JButton
getJButton8() {
318 if (jButton8
== null) {
319 jButton8
= new JButton();
320 jButton8
.setText("Add SPD Header");
321 jButton8
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
322 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
323 ModalFrameUtil
.showAsModal(new PackageNew(sfc
), pThis
);
331 This method initializes jButton9
333 @return javax.swing.JButton
335 private JButton
getJButton9() {
336 if (jButton9
== null) {
337 jButton9
= new JButton();
338 jButton9
.setText("Done");
339 jButton9
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
340 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
342 // quit current frame
352 } // @jve:decl-index=0:visual-constraint="104,41"