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