]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ExitConfirm.java
3 The file is used to popup a exit confirmation window when program exists
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
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.
16 package org
.tianocore
.frameworkwizard
.common
.ui
;
18 import java
.awt
.Dimension
;
19 import java
.awt
.Toolkit
;
20 import java
.awt
.event
.ActionEvent
;
21 import java
.awt
.event
.ActionListener
;
22 import java
.awt
.event
.WindowEvent
;
23 import java
.awt
.event
.WindowListener
;
25 import javax
.swing
.JButton
;
26 import javax
.swing
.JDialog
;
27 import javax
.swing
.JFrame
;
28 import javax
.swing
.JLabel
;
29 import javax
.swing
.JPanel
;
32 The class is used to popup a exit confirmation window when program exists
33 It extends JDialog and implements ActionListener and WindowListener
36 public class ExitConfirm
extends JDialog
implements ActionListener
, WindowListener
{
39 /// Define class Serial Version UID
41 private static final long serialVersionUID
= -5875921789385911029L;
43 private JPanel jContentPane
= null;
45 private JLabel jLabelMessage
= null;
47 private JLabel jLabelResume
= null;
49 private JLabel jLabelExit
= null;
51 private JButton jButtonResume
= null;
53 private JButton jButtonExit
= null;
55 public boolean isCancel
= false;
58 This method initializes jButtonResume
60 @return javax.swing.JButton jButtonResume
63 private JButton
getJButtonResume() {
64 if (jButtonResume
== null) {
65 jButtonResume
= new JButton();
66 jButtonResume
.setText("Resume");
67 jButtonResume
.setSize(new java
.awt
.Dimension(90, 20));
68 jButtonResume
.setLocation(new java
.awt
.Point(150, 105));
69 jButtonResume
.setMnemonic('R');
70 jButtonResume
.addActionListener(this);
76 This method initializes jButtonExit
78 @return javax.swing.JButton jButtonExit
81 private JButton
getJButtonExit() {
82 if (jButtonExit
== null) {
83 jButtonExit
= new JButton();
84 jButtonExit
.setText("Exit");
85 jButtonExit
.setSize(new java
.awt
.Dimension(90, 20));
86 jButtonExit
.setLocation(new java
.awt
.Point(260, 105));
87 jButtonExit
.setMnemonic('x');
88 jButtonExit
.addActionListener(this);
94 Main clasee, reserved for test
99 public static void main(String
[] args
) {
100 // TODO Auto-generated method stub
105 This is the default constructor
108 public ExitConfirm(IFrame parentFrame
, boolean modal
) {
109 super(parentFrame
, modal
);
114 This method initializes this
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);
126 //Set DO_NOTHING_ON_CLOSE when click Close button on title bar
128 this.setDefaultCloseOperation(JFrame
.DO_NOTHING_ON_CLOSE
);
133 This method initializes jContentPane
135 @return javax.swing.JPanel jContentPane
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);
161 Call setWarningMessage to set messages of frame when it is used for Setup
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 strExit
= "To continue installing, click Resume. To quit the Setup program, click Exit.";
169 setWarningMessage(strTitle
, strMessage
, strResume
, strExit
);
173 Call setWarningMessage to set messages of frame when it is used for Module Main GUI
176 public void setModuleMessage() {
177 String strTitle
= "Exit";
178 String strMessage
= "Do you really want to quit now?";
179 String strResume
= "All unsaved module information will be lost.";
180 String strExit
= "To continue editing the module, click Resume. To quit the program, click Exit.";
181 setWarningMessage(strTitle
, strMessage
, strResume
, strExit
);
185 Set message information via input data
187 @param strTitle The title value
188 @param strMessage The main message value
189 @param strResume The resume message value
190 @param strExit The exit message value
193 private void setWarningMessage(String strTitle
, String strMessage
, String strResume
, String strExit
) {
194 this.setTitle(strTitle
);
195 jLabelMessage
.setText(strMessage
);
196 jLabelResume
.setText(strResume
);
197 jLabelExit
.setText(strExit
);
201 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
203 * Override actionPerformed to listern all actions
206 public void actionPerformed(ActionEvent arg0
) {
208 //Set isCancel true when click button "Exit"
210 Object obj
= arg0
.getSource();
211 if (obj
== jButtonResume
) {
214 if (obj
== jButtonExit
) {
217 this.setVisible(false);
221 Make the window in the center of the screen
224 private void centerWindow() {
225 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
226 this.setLocation((d
.width
- this.getSize().width
) / 2, (d
.height
- this.getSize().height
) / 2);
229 public void windowActivated(WindowEvent arg0
) {
230 // TODO Auto-generated method stub
234 public void windowClosed(WindowEvent arg0
) {
235 // TODO Auto-generated method stub
239 public void windowClosing(WindowEvent arg0
) {
241 this.setVisible(false);
244 public void windowDeactivated(WindowEvent arg0
) {
245 // TODO Auto-generated method stub
249 public void windowDeiconified(WindowEvent arg0
) {
250 // TODO Auto-generated method stub
254 public void windowIconified(WindowEvent arg0
) {
255 // TODO Auto-generated method stub
259 public void windowOpened(WindowEvent arg0
) {
260 // TODO Auto-generated method stub