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