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