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