]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/common/ui/ExitConfirm.java
Obliterate these files.
[mirror_edk2.git] / Tools / Source / CreateMdkPkg / src / org / tianocore / packaging / common / ui / ExitConfirm.java
1 /** @file
2
3 The file is used to popup a exit confirmation window when program exists
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 **/
14 package org.tianocore.packaging.common.ui;
15
16 import java.awt.Dimension;
17 import java.awt.Toolkit;
18 import java.awt.event.ActionEvent;
19 import java.awt.event.ActionListener;
20 import java.awt.event.WindowEvent;
21 import java.awt.event.WindowListener;
22
23 import javax.swing.JButton;
24 import javax.swing.JDialog;
25 import javax.swing.JFrame;
26 import javax.swing.JLabel;
27 import javax.swing.JPanel;
28
29 /**
30 The class is used to popup a exit confirmation window when program exists
31 It extends JDialog and implements ActionListener and WindowListener
32
33 @since CreateMdkPkg 1.0
34
35 **/
36 public class ExitConfirm extends JDialog implements ActionListener, WindowListener {
37 ///
38 /// Define class Serial Version UID
39 ///
40 private static final long serialVersionUID = -5875921789385911029L;
41
42 //
43 // Define class members
44 //
45 private JPanel jContentPane = null;
46
47 private JLabel jLabelMessage = null;
48
49 private JLabel jLabelResume = null;
50
51 private JLabel jLabelExit = null;
52
53 private JButton jButtonResume = null;
54
55 private JButton jButtonExit = null;
56
57 public boolean isCancel = false;
58
59 /**
60 This method initializes jButtonResume
61
62 @return javax.swing.JButton jButtonResume
63
64 **/
65 private JButton getJButtonResume() {
66 if (jButtonResume == null) {
67 jButtonResume = new JButton();
68 jButtonResume.setText("Resume");
69 jButtonResume.setSize(new java.awt.Dimension(90, 20));
70 jButtonResume.setLocation(new java.awt.Point(150, 105));
71 jButtonResume.setMnemonic('R');
72 jButtonResume.addActionListener(this);
73 }
74 return jButtonResume;
75 }
76
77 /**
78 This method initializes jButtonExit
79
80 @return javax.swing.JButton jButtonExit
81
82 **/
83 private JButton getJButtonExit() {
84 if (jButtonExit == null) {
85 jButtonExit = new JButton();
86 jButtonExit.setText("Exit");
87 jButtonExit.setSize(new java.awt.Dimension(90, 20));
88 jButtonExit.setLocation(new java.awt.Point(260, 105));
89 jButtonExit.setMnemonic('x');
90 jButtonExit.addActionListener(this);
91 }
92 return jButtonExit;
93 }
94
95 /**
96 Main clasee, reserved for test
97
98 @param args
99
100 **/
101 public static void main(String[] args) {
102 // TODO Auto-generated method stub
103
104 }
105
106 /**
107 This is the default constructor
108
109 **/
110 public ExitConfirm(IFrame parentFrame, boolean modal) {
111 super(parentFrame, modal);
112 initialize();
113 }
114
115 /**
116 This method initializes this
117
118 **/
119 private void initialize() {
120 this.setSize(500, 170);
121 this.setTitle("Exit");
122 this.setResizable(false);
123 this.setContentPane(getJContentPane());
124 this.addWindowListener(this);
125 //
126 //Set DO_NOTHING_ON_CLOSE when click Close button on title bar
127 //
128 this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
129 centerWindow();
130 }
131
132 /**
133 This method initializes jContentPane
134
135 @return javax.swing.JPanel jContentPane
136
137 **/
138 private JPanel getJContentPane() {
139 if (jContentPane == null) {
140 jLabelExit = new JLabel();
141 jLabelExit.setSize(new java.awt.Dimension(450, 20));
142 jLabelExit.setLocation(new java.awt.Point(25, 70));
143 jLabelResume = new JLabel();
144 jLabelResume.setSize(new java.awt.Dimension(450, 20));
145 jLabelResume.setLocation(new java.awt.Point(25, 40));
146 jLabelMessage = new JLabel();
147 jLabelMessage.setSize(new java.awt.Dimension(450, 20));
148 jLabelMessage.setLocation(new java.awt.Point(25, 10));
149 jContentPane = new JPanel();
150 jContentPane.setLayout(null);
151 jContentPane.add(jLabelMessage, null);
152 jContentPane.add(jLabelResume, null);
153 jContentPane.add(jLabelExit, null);
154 jContentPane.add(getJButtonResume(), null);
155 jContentPane.add(getJButtonExit(), null);
156 }
157 return jContentPane;
158 }
159
160 /**
161 Call setWarningMessage to set messages of frame when it is used for Setup
162
163 **/
164 public void setSetupMessage() {
165 String strTitle = "Exit Setup";
166 String strMessage = "Setup is not complete. If you quit now, the program will not be installed.";
167 //String strResume = "You may run the setup program at a later time to complete the installation.";
168 String strResume = "";
169 String strExit = "To continue installing, click Resume. To quit the Setup program, click Exit.";
170 setWarningMessage(strTitle, strMessage, strResume, strExit);
171 }
172
173 /**
174 Call setWarningMessage to set messages of frame when it is used for Module Main GUI
175
176 **/
177 public void setModuleMessage() {
178 String strTitle = "Exit";
179 String strMessage = "Do you really want to quit now?";
180 String strResume = "All unsaved module information will be lost.";
181 String strExit = "To continue editing module, click Resume. To quit the program, click Exit.";
182 setWarningMessage(strTitle, strMessage, strResume, strExit);
183 }
184
185 /**
186 Set message information via input data
187
188 @param strTitle The title value
189 @param strMessage The main message value
190 @param strResume The resume message value
191 @param strExit The exit message value
192
193 **/
194 private void setWarningMessage(String strTitle, String strMessage, String strResume, String strExit) {
195 this.setTitle(strTitle);
196 jLabelMessage.setText(strMessage);
197 jLabelResume.setText(strResume);
198 jLabelExit.setText(strExit);
199 }
200
201 /* (non-Javadoc)
202 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
203 *
204 * Override actionPerformed to listern all actions
205 *
206 */
207 public void actionPerformed(ActionEvent arg0) {
208 //
209 //Set isCancel true when click button "Exit"
210 //
211 Object obj = arg0.getSource();
212 if (obj == jButtonResume) {
213 isCancel = false;
214 }
215 if (obj == jButtonExit) {
216 isCancel = true;
217 }
218 this.setVisible(false);
219 }
220
221 /**
222 Make the window in the center of the screen
223
224 **/
225 private void centerWindow() {
226 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
227 this.setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2);
228 }
229
230 public void windowActivated(WindowEvent arg0) {
231 // TODO Auto-generated method stub
232
233 }
234
235 public void windowClosed(WindowEvent arg0) {
236 // TODO Auto-generated method stub
237
238 }
239
240 public void windowClosing(WindowEvent arg0) {
241 isCancel = false;
242 this.setVisible(false);
243 }
244
245 public void windowDeactivated(WindowEvent arg0) {
246 // TODO Auto-generated method stub
247
248 }
249
250 public void windowDeiconified(WindowEvent arg0) {
251 // TODO Auto-generated method stub
252
253 }
254
255 public void windowIconified(WindowEvent arg0) {
256 // TODO Auto-generated method stub
257
258 }
259
260 public void windowOpened(WindowEvent arg0) {
261 // TODO Auto-generated method stub
262
263 }
264 }