]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/CreateMdkPkg/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.
14 package org
.tianocore
.packaging
.common
.ui
;
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
;
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
;
30 The class is used to popup a exit confirmation window when program exists
31 It extends JDialog and implements ActionListener and WindowListener
33 @since CreateMdkPkg 1.0
36 public class ExitConfirm
extends JDialog
implements ActionListener
, WindowListener
{
38 /// Define class Serial Version UID
40 private static final long serialVersionUID
= -5875921789385911029L;
43 // Define class members
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
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 strResume
= "";
169 String strExit
= "To continue installing, click Resume. To quit the Setup program, click Exit.";
170 setWarningMessage(strTitle
, strMessage
, strResume
, strExit
);
174 Call setWarningMessage to set messages of frame when it is used for Module Main GUI
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
);
186 Set message information via input data
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
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
);
202 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
204 * Override actionPerformed to listern all actions
207 public void actionPerformed(ActionEvent arg0
) {
209 //Set isCancel true when click button "Exit"
211 Object obj
= arg0
.getSource();
212 if (obj
== jButtonResume
) {
215 if (obj
== jButtonExit
) {
218 this.setVisible(false);
222 Make the window in the center of the screen
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);
230 public void windowActivated(WindowEvent arg0
) {
231 // TODO Auto-generated method stub
235 public void windowClosed(WindowEvent arg0
) {
236 // TODO Auto-generated method stub
240 public void windowClosing(WindowEvent arg0
) {
242 this.setVisible(false);
245 public void windowDeactivated(WindowEvent arg0
) {
246 // TODO Auto-generated method stub
250 public void windowDeiconified(WindowEvent arg0
) {
251 // TODO Auto-generated method stub
255 public void windowIconified(WindowEvent arg0
) {
256 // TODO Auto-generated method stub
260 public void windowOpened(WindowEvent arg0
) {
261 // TODO Auto-generated method stub