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