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