]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IFrame.java
1. Move resize funtions from IInternalFrame.java to Tools.java.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / ui / IFrame.java
1 /** @file
2
3 The file is used to override Frame to provides customized interfaces
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 **/
15
16 package org.tianocore.frameworkwizard.common.ui;
17
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.ComponentEvent;
23 import java.awt.event.ComponentListener;
24 import java.awt.event.WindowEvent;
25 import java.awt.event.WindowListener;
26
27 import javax.swing.JFrame;
28 import javax.swing.JOptionPane;
29
30 /**
31 The class is used to override Frame to provides customized interfaces
32 It extends JFrame implements ActionListener and WindowListener
33
34 **/
35 public class IFrame extends JFrame implements ActionListener, WindowListener, ComponentListener {
36
37 ///
38 /// Define class Serial Version UID
39 ///
40 private static final long serialVersionUID = -3324138961029300427L;
41
42 //
43 //Define class members
44 //
45 private ExitConfirm ec = null;
46
47 //
48 // To indicate the status while quit
49 // 0 - When setup (Default)
50 // 1 - Whne editing module
51 //
52 private int intExitType = 0;
53
54 /**
55 Main class, used for test
56
57 @param args
58
59 **/
60 public static void main(String[] args) {
61 IFrame i = new IFrame();
62 i.setVisible(true);
63 }
64
65 /**
66 This is the default constructor
67
68 **/
69 public IFrame() {
70 super();
71 initialize();
72 }
73
74 /**
75 This method initializes this
76
77 **/
78 public void initialize() {
79 this.setResizable(false);
80 this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
81 this.addWindowListener(this);
82 this.addComponentListener(this);
83 }
84
85 /**
86 Start the dialog at the center of screen
87
88 @param intWidth The width of the dialog
89 @param intHeight The height of the dialog
90
91 **/
92 protected void centerWindow(int intWidth, int intHeight) {
93 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
94 this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
95 }
96
97 /**
98 Start the window full of the screen
99
100 **/
101 protected void maxWindow() {
102 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
103 this.setLocation(0, 0);
104 this.setSize(d);
105 }
106
107 /**
108 Start the dialog at the center of screen
109
110 **/
111 protected void centerWindow() {
112 centerWindow(this.getSize().width, this.getSize().height);
113 }
114
115 /**
116 Set the exit window type
117
118 @param ExitType The input data of ExitType
119
120 **/
121 protected void setExitType(int ExitType) {
122 this.intExitType = ExitType;
123 }
124
125 /* (non-Javadoc)
126 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
127 *
128 * Override windowClosing to call this.onDisvisible()
129 *
130 */
131 public void windowClosing(WindowEvent arg0) {
132 //this.onDisvisible();
133 }
134
135 public void windowOpened(WindowEvent arg0) {
136 // TODO Auto-generated method stub
137
138 }
139
140 public void windowClosed(WindowEvent arg0) {
141 // TODO Auto-generated method stub
142
143 }
144
145 public void windowIconified(WindowEvent arg0) {
146 // TODO Auto-generated method stub
147
148 }
149
150 public void windowDeiconified(WindowEvent arg0) {
151 // TODO Auto-generated method stub
152
153 }
154
155 public void windowActivated(WindowEvent arg0) {
156 // TODO Auto-generated method stub
157
158 }
159
160 public void windowDeactivated(WindowEvent arg0) {
161 // TODO Auto-generated method stub
162
163 }
164
165 public void actionPerformed(ActionEvent arg0) {
166 // TODO Auto-generated method stub
167
168 }
169
170 /**
171 Define the actions when exit
172
173 **/
174 public void onExit() {
175 ec = new ExitConfirm(this, true);
176 //
177 //Show different warning message via different ExitType
178 //
179 switch (intExitType) {
180 case 0:
181 ec.setSetupMessage();
182 break;
183 case 1:
184 ec.setModuleMessage();
185 break;
186 }
187 ec.setVisible(true);
188 if (ec.isCancel) {
189 this.dispose();
190 System.exit(0);
191 }
192 }
193
194 /**
195 Define the actions when disvisible
196
197 **/
198 public void onDisvisible() {
199 ec = new ExitConfirm(this, true);
200 //
201 //Show different warning message via different ExitType
202 //
203 switch (intExitType) {
204 case 0:
205 ec.setSetupMessage();
206 break;
207 case 1:
208 ec.setModuleMessage();
209 break;
210 }
211 ec.setVisible(true);
212 if (ec.isCancel) {
213 this.dispose();
214 }
215 }
216
217 public int showSaveDialog() {
218 return JOptionPane.showConfirmDialog(null, "Save all changed files?", "Save", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
219 }
220
221 /**
222 Check the input data is empty or not
223
224 @param strValue The input data which need be checked
225
226 @retval true - The input data is empty
227 @retval fals - The input data is not empty
228
229 **/
230 public boolean isEmpty(String strValue) {
231 if (strValue.length() > 0) {
232 return false;
233 }
234 return true;
235 }
236
237 /**
238 Display the dialog
239
240 **/
241 public void showDialog() {
242 this.setVisible(true);
243 }
244
245 public void componentResized(ComponentEvent arg0) {
246 // TODO Auto-generated method stub
247
248 }
249
250 public void componentMoved(ComponentEvent arg0) {
251 // TODO Auto-generated method stub
252
253 }
254
255 public void componentShown(ComponentEvent arg0) {
256 // TODO Auto-generated method stub
257
258 }
259
260 public void componentHidden(ComponentEvent arg0) {
261 // TODO Auto-generated method stub
262
263 }
264 }