]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IFrame.java
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@671 6f19259b...
[mirror_edk2.git] / Tools / Source / ModuleEditor / 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 ModuleEditor 1.0\r
32 \r
33 **/\r
34public class IFrame extends JFrame implements ActionListener, WindowListener {\r
35\r
36 ///\r
37 /// Define class Serial Version UID\r
38 ///\r
39 private static final long serialVersionUID = -3324138961029300427L;\r
40\r
41 //\r
42 //Define class members\r
43 //\r
44 private ExitConfirm ec = null;\r
45\r
46 //\r
47 // To indicate the status while quit\r
48 // 0 - When setup (Default)\r
49 // 1 - Whne editing module\r
50 //\r
51 private int intExitType = 0;\r
52\r
53 /**\r
54 Main class, used for test\r
55 \r
56 @param args\r
57 \r
58 **/\r
59 public static void main(String[] args) {\r
60 IFrame i = new IFrame();\r
61 i.setVisible(true);\r
62 }\r
63\r
64 /**\r
65 This is the default constructor\r
66 \r
67 **/\r
68 public IFrame() {\r
69 super();\r
70 initialize();\r
71 }\r
72\r
73 /**\r
74 This method initializes this\r
75 \r
76 **/\r
77 public void initialize() {\r
78 this.setResizable(false);\r
79 this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);\r
80 this.addWindowListener(this);\r
81 }\r
82\r
83 /**\r
84 Start the dialog at the center of screen\r
85 \r
86 @param intWidth The width of the dialog\r
87 @param intHeight The height of the dialog\r
88 \r
89 **/\r
90 protected void centerWindow(int intWidth, int intHeight) {\r
91 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r
92 this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);\r
93 }\r
94\r
95 /**\r
96 Start the dialog at the center of screen\r
97 \r
98 **/\r
99 protected void centerWindow() {\r
100 centerWindow(this.getSize().width, this.getSize().height);\r
101 }\r
102\r
103 /**\r
104 Set the exit window type\r
105 \r
106 @param ExitType The input data of ExitType\r
107 \r
108 **/\r
109 protected void setExitType(int ExitType) {\r
110 this.intExitType = ExitType;\r
111 }\r
112\r
113 /* (non-Javadoc)\r
114 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)\r
115 *\r
116 * Override windowClosing to call this.onDisvisible()\r
117 * \r
118 */\r
119 public void windowClosing(WindowEvent arg0) {\r
120 this.onDisvisible();\r
121 }\r
122\r
123 public void windowOpened(WindowEvent arg0) {\r
124 // TODO Auto-generated method stub\r
125\r
126 }\r
127\r
128 public void windowClosed(WindowEvent arg0) {\r
129 // TODO Auto-generated method stub\r
130\r
131 }\r
132\r
133 public void windowIconified(WindowEvent arg0) {\r
134 // TODO Auto-generated method stub\r
135\r
136 }\r
137\r
138 public void windowDeiconified(WindowEvent arg0) {\r
139 // TODO Auto-generated method stub\r
140\r
141 }\r
142\r
143 public void windowActivated(WindowEvent arg0) {\r
144 // TODO Auto-generated method stub\r
145\r
146 }\r
147\r
148 public void windowDeactivated(WindowEvent arg0) {\r
149 // TODO Auto-generated method stub\r
150\r
151 }\r
152\r
153 public void actionPerformed(ActionEvent arg0) {\r
154 // TODO Auto-generated method stub\r
155\r
156 }\r
157\r
158 /**\r
159 Define the actions when exit\r
160 \r
161 **/\r
162 public void onExit() {\r
163 ec = new ExitConfirm(this, true);\r
164 //\r
165 //Show different warning message via different ExitType\r
166 //\r
167 switch (intExitType) {\r
168 case 0:\r
169 ec.setSetupMessage();\r
170 break;\r
171 case 1:\r
172 ec.setModuleMessage();\r
173 break;\r
174 }\r
175 ec.setVisible(true);\r
176 if (ec.isCancel) {\r
177 this.dispose();\r
178 System.exit(0);\r
179 }\r
180 }\r
181\r
182 /**\r
183 Define the actions when disvisible\r
184 \r
185 **/\r
186 public void onDisvisible() {\r
187 ec = new ExitConfirm(this, true);\r
188 //\r
189 //Show different warning message via different ExitType\r
190 //\r
191 switch (intExitType) {\r
192 case 0:\r
193 ec.setSetupMessage();\r
194 break;\r
195 case 1:\r
196 ec.setModuleMessage();\r
197 break;\r
198 }\r
199 ec.setVisible(true);\r
200 if (ec.isCancel) {\r
201 this.dispose();\r
202 }\r
203 }\r
204}\r