]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/ModuleEditor/src/org/tianocore/packaging/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
.packaging
.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
35 @since ModuleEditor 1.0
38 public class ExitConfirm
extends JDialog
implements ActionListener
, WindowListener
{
41 /// Define class Serial Version UID
43 private static final long serialVersionUID
= -5875921789385911029L;
45 private JPanel jContentPane
= null;
47 private JLabel jLabelMessage
= null;
49 private JLabel jLabelResume
= null;
51 private JLabel jLabelExit
= null;
53 private JButton jButtonResume
= null;
55 private JButton jButtonExit
= null;
57 public boolean isCancel
= false;
60 This method initializes jButtonResume
62 @return javax.swing.JButton jButtonResume
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);
78 This method initializes jButtonExit
80 @return javax.swing.JButton jButtonExit
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);
96 Main clasee, reserved for test
101 public static void main(String
[] args
) {
102 // TODO Auto-generated method stub
107 This is the default constructor
110 public ExitConfirm(IFrame parentFrame
, boolean modal
) {
111 super(parentFrame
, modal
);
116 This method initializes this
121 private void initialize() {
122 this.setSize(500, 170);
123 this.setTitle("Exit");
124 this.setResizable(false);
125 this.setContentPane(getJContentPane());
126 this.addWindowListener(this);
128 //Set DO_NOTHING_ON_CLOSE when click Close button on title bar
130 this.setDefaultCloseOperation(JFrame
.DO_NOTHING_ON_CLOSE
);
135 This method initializes jContentPane
137 @return javax.swing.JPanel jContentPane
140 private JPanel
getJContentPane() {
141 if (jContentPane
== null) {
142 jLabelExit
= new JLabel();
143 jLabelExit
.setSize(new java
.awt
.Dimension(450, 20));
144 jLabelExit
.setLocation(new java
.awt
.Point(25, 70));
145 jLabelResume
= new JLabel();
146 jLabelResume
.setSize(new java
.awt
.Dimension(450, 20));
147 jLabelResume
.setLocation(new java
.awt
.Point(25, 40));
148 jLabelMessage
= new JLabel();
149 jLabelMessage
.setSize(new java
.awt
.Dimension(450, 20));
150 jLabelMessage
.setLocation(new java
.awt
.Point(25, 10));
151 jContentPane
= new JPanel();
152 jContentPane
.setLayout(null);
153 jContentPane
.add(jLabelMessage
, null);
154 jContentPane
.add(jLabelResume
, null);
155 jContentPane
.add(jLabelExit
, null);
156 jContentPane
.add(getJButtonResume(), null);
157 jContentPane
.add(getJButtonExit(), null);
163 Call setWarningMessage to set messages of frame when it is used for Setup
166 public void setSetupMessage() {
167 String strTitle
= "Exit Setup";
168 String strMessage
= "Setup is not complete. If you quit now, the program will not be installed.";
169 String strResume
= "You may run the setup program at a later time to complete the installation.";
170 String strExit
= "To continue installing, click Resume. To quit the Setup program, click Exit.";
171 setWarningMessage(strTitle
, strMessage
, strResume
, strExit
);
175 Call setWarningMessage to set messages of frame when it is used for Module Main GUI
178 public void setModuleMessage() {
179 String strTitle
= "Exit";
180 String strMessage
= "Do you really want to quit now?";
181 String strResume
= "All unsaved module information will be lost.";
182 String strExit
= "To continue editing module, click Resume. To quit the program, click Exit.";
183 setWarningMessage(strTitle
, strMessage
, strResume
, strExit
);
187 Set message information via input data
189 @param strTitle The title value
190 @param strMessage The main message value
191 @param strResume The resume message value
192 @param strExit The exit message value
195 private void setWarningMessage(String strTitle
, String strMessage
, String strResume
, String strExit
) {
196 this.setTitle(strTitle
);
197 jLabelMessage
.setText(strMessage
);
198 jLabelResume
.setText(strResume
);
199 jLabelExit
.setText(strExit
);
203 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
205 * Override actionPerformed to listern all actions
208 public void actionPerformed(ActionEvent arg0
) {
210 //Set isCancel true when click button "Exit"
212 Object obj
= arg0
.getSource();
213 if (obj
== jButtonResume
) {
216 if (obj
== jButtonExit
) {
219 this.setVisible(false);
223 Make the window in the center of the screen
226 private void centerWindow() {
227 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
228 this.setLocation((d
.width
- this.getSize().width
) / 2, (d
.height
- this.getSize().height
) / 2);
231 public void windowActivated(WindowEvent arg0
) {
232 // TODO Auto-generated method stub
236 public void windowClosed(WindowEvent arg0
) {
237 // TODO Auto-generated method stub
241 public void windowClosing(WindowEvent arg0
) {
243 this.setVisible(false);
246 public void windowDeactivated(WindowEvent arg0
) {
247 // TODO Auto-generated method stub
251 public void windowDeiconified(WindowEvent arg0
) {
252 // TODO Auto-generated method stub
256 public void windowIconified(WindowEvent arg0
) {
257 // TODO Auto-generated method stub
261 public void windowOpened(WindowEvent arg0
) {
262 // TODO Auto-generated method stub