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