]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/common/ui/IFrame.java
Obliterate these files.
[mirror_edk2.git] / Tools / Source / CreateMdkPkg / src / org / tianocore / packaging / common / ui / IFrame.java
CommitLineData
878ddf1f 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.packaging.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
26\r
27/**\r
28 The class is used to override Frame to provides customized interfaces \r
29 It extends JFrame implements ActionListener and WindowListener\r
30 \r
31 @since CreateMdkPkg 1.0\r
32 \r
33 **/\r
34public class IFrame extends JFrame implements ActionListener, WindowListener {\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
51\r
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 dialog at the center of screen\r
96 \r
97 **/\r
98 protected void centerWindow() {\r
99 centerWindow(this.getSize().width, this.getSize().height);\r
100 }\r
101\r
102 /**\r
103 Set the exit window type\r
104 \r
105 @param ExitType The input data of ExitType\r
106 \r
107 **/\r
108 protected void setExitType(int ExitType) {\r
109 this.intExitType = ExitType;\r
110 }\r
111\r
112 /* (non-Javadoc)\r
113 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)\r
114 *\r
115 * Override windowClosing to call this.onDisvisible()\r
116 * \r
117 */\r
118 public void windowClosing(WindowEvent arg0) {\r
119 this.onDisvisible();\r
120 }\r
121\r
122 public void windowOpened(WindowEvent arg0) {\r
123 // TODO Auto-generated method stub\r
124\r
125 }\r
126\r
127 public void windowClosed(WindowEvent arg0) {\r
128 // TODO Auto-generated method stub\r
129\r
130 }\r
131\r
132 public void windowIconified(WindowEvent arg0) {\r
133 // TODO Auto-generated method stub\r
134\r
135 }\r
136\r
137 public void windowDeiconified(WindowEvent arg0) {\r
138 // TODO Auto-generated method stub\r
139\r
140 }\r
141\r
142 public void windowActivated(WindowEvent arg0) {\r
143 // TODO Auto-generated method stub\r
144\r
145 }\r
146\r
147 public void windowDeactivated(WindowEvent arg0) {\r
148 // TODO Auto-generated method stub\r
149\r
150 }\r
151\r
152 public void actionPerformed(ActionEvent arg0) {\r
153 // TODO Auto-generated method stub\r
154\r
155 }\r
156\r
157 /**\r
158 Define the actions when exit\r
159 \r
160 **/\r
161 public void onExit() {\r
162 ec = new ExitConfirm(this, true);\r
163 //\r
164 //Show different warning message via different ExitType\r
165 //\r
166 switch (intExitType) {\r
167 case 0:\r
168 ec.setSetupMessage();\r
169 break;\r
170 case 1:\r
171 ec.setModuleMessage();\r
172 break;\r
173 }\r
174 ec.setVisible(true);\r
175 if (ec.isCancel) {\r
176 this.dispose();\r
177 System.exit(0);\r
178 }\r
179 }\r
180\r
181 /**\r
182 Define the actions when disvisible\r
183 \r
184 **/\r
185 public void onDisvisible() {\r
186 ec = new ExitConfirm(this, true);\r
187 //\r
188 //Show different warning message via different ExitType\r
189 //\r
190 switch (intExitType) {\r
191 case 0:\r
192 ec.setSetupMessage();\r
193 break;\r
194 case 1:\r
195 ec.setModuleMessage();\r
196 break;\r
197 }\r
198 ec.setVisible(true);\r
199 if (ec.isCancel) {\r
200 this.dispose();\r
201 }\r
202 }\r
203}\r