]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageAction.java
71d291548da76755847259df940a6526397c5546
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
;
29 GUI for create spd file
31 @since PackageEditor 1.0
33 public class PackageAction
extends JFrame
{
37 private JPanel jContentPane
= null;
39 private JButton jButton
= null;
41 private JButton jButton1
= null;
43 private JButton jButton2
= null;
45 private JButton jButton3
= null;
47 private JButton jButton4
= null;
49 private JButton jButton5
= null;
51 private JButton jButton6
= null;
53 private JButton jButton7
= null;
56 /// SpdFileContents object passed from main
58 private SpdFileContents sfc
= null;
60 private JFrame pThis
= null; // @jve:decl-index=0:visual-constraint="304,10"
62 private JButton jButton8
= null;
64 private JButton jButton9
= null; // @jve:decl-index=0:visual-constraint="116,388"
67 This is the default constructor
69 public PackageAction(SpdFileContents sfc
) {
76 This method initializes this
80 private void initialize() {
81 this.setSize(305, 385);
82 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
83 this.setContentPane(getJContentPane());
84 this.setTitle("Please Choose an Action");
91 Start the window at the center of screen
94 protected void centerWindow(int intWidth
, int intHeight
) {
95 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
96 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
100 Start the window at the center of screen
103 protected void centerWindow() {
104 centerWindow(this.getSize().width
, this.getSize().height
);
108 This method initializes jContentPane
110 @return javax.swing.JPanel
112 private JPanel
getJContentPane() {
113 if (jContentPane
== null) {
114 GridLayout gridLayout
= new GridLayout();
115 gridLayout
.setRows(10);
116 gridLayout
.setColumns(1);
117 jContentPane
= new JPanel();
118 jContentPane
.setPreferredSize(new java
.awt
.Dimension(200,300));
119 jContentPane
.setLayout(gridLayout
);
120 jContentPane
.add(getJButton8(), null);
121 jContentPane
.add(getJButton7(), null);
122 jContentPane
.add(getJButton6(), null);
123 jContentPane
.add(getJButton5(), null);
124 jContentPane
.add(getJButton4(), null);
125 jContentPane
.add(getJButton3(), null);
126 jContentPane
.add(getJButton2(), null);
127 jContentPane
.add(getJButton1(), null);
128 jContentPane
.add(getJButton(), null);
129 jContentPane
.add(getJButton9(), null);
135 This method initializes jButton
137 @return javax.swing.JButton
139 private JButton
getJButton() {
140 if (jButton
== null) {
141 jButton
= new JButton();
142 jButton
.setText("Save");
143 jButton
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
144 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
146 // save sfc contents to file
148 JFileChooser chooser
= new JFileChooser(System
.getenv("WORKSPACE"));
149 chooser
.setMultiSelectionEnabled(false);
151 int retval
= chooser
.showSaveDialog(frame
);
152 if (retval
== JFileChooser
.APPROVE_OPTION
) {
154 File theFile
= chooser
.getSelectedFile();
155 if (theFile
.exists()) {
156 int retVal
= JOptionPane
.showConfirmDialog(frame
, "Are you sure to replace the exising one?", "File Exists",
157 JOptionPane
.YES_NO_OPTION
);
158 if (retVal
== JOptionPane
.NO_OPTION
) {
164 } catch (Exception ee
) {
165 System
.out
.println(ee
.toString());
177 This method initializes jButton1
179 @return javax.swing.JButton
181 private JButton
getJButton1() {
182 if (jButton1
== null) {
183 jButton1
= new JButton();
184 jButton1
.setText("Add PCD Information");
185 jButton1
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
186 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
188 // Add PCD frame show modal
190 ModalFrameUtil
.showAsModal(new PackagePCD(sfc
), pThis
);
198 This method initializes jButton2
200 @return javax.swing.JButton
202 private JButton
getJButton2() {
203 if (jButton2
== null) {
204 jButton2
= new JButton();
205 jButton2
.setText("Add PPI Declarations");
206 jButton2
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
207 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
209 // Add PPI frame show modal
211 ModalFrameUtil
.showAsModal(new PackagePpi(sfc
), pThis
);
219 This method initializes jButton3
221 @return javax.swing.JButton
223 private JButton
getJButton3() {
224 if (jButton3
== null) {
225 jButton3
= new JButton();
226 jButton3
.setText("Add Protocol Declarations");
227 jButton3
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
228 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
229 ModalFrameUtil
.showAsModal(new PackageProtocols(sfc
), pThis
);
237 This method initializes jButton4
239 @return javax.swing.JButton
241 private JButton
getJButton4() {
242 if (jButton4
== null) {
243 jButton4
= new JButton();
244 jButton4
.setText("Add GUID Declarations");
245 jButton4
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
246 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
247 ModalFrameUtil
.showAsModal(new PackageGuids(sfc
), pThis
);
255 This method initializes jButton5
257 @return javax.swing.JButton
259 private JButton
getJButton5() {
260 if (jButton5
== null) {
261 jButton5
= new JButton();
262 jButton5
.setText("Add Package Headers");
263 jButton5
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
264 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
265 ModalFrameUtil
.showAsModal(new PackagePkgHeader(sfc
), pThis
);
273 This method initializes jButton6
275 @return javax.swing.JButton
277 private JButton
getJButton6() {
278 if (jButton6
== null) {
279 jButton6
= new JButton();
280 jButton6
.setText("Add MSA Files");
281 jButton6
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
282 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
283 ModalFrameUtil
.showAsModal(new PackageMsaFile(sfc
), pThis
);
291 This method initializes jButton7
293 @return javax.swing.JButton
295 private JButton
getJButton7() {
296 if (jButton7
== null) {
297 jButton7
= new JButton();
298 jButton7
.setText("Add Library Classes");
299 jButton7
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
300 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
301 ModalFrameUtil
.showAsModal(new PackageLibraryClass(sfc
), pThis
);
309 This method initializes jButton8
311 @return javax.swing.JButton
313 private JButton
getJButton8() {
314 if (jButton8
== null) {
315 jButton8
= new JButton();
316 jButton8
.setText("Add SPD Header");
317 jButton8
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
318 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
319 ModalFrameUtil
.showAsModal(new PackageNew(sfc
), pThis
);
327 This method initializes jButton9
329 @return javax.swing.JButton
331 private JButton
getJButton9() {
332 if (jButton9
== null) {
333 jButton9
= new JButton();
334 jButton9
.setText("Done");
335 jButton9
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
336 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
338 // quit current frame
348 } // @jve:decl-index=0:visual-constraint="104,41"