]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IFrame.java
3 The file is used to override Frame to provides customized interfaces
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
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.
16 package org
.tianocore
.frameworkwizard
.common
.ui
;
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
;
27 import javax
.swing
.JFrame
;
28 import javax
.swing
.JOptionPane
;
30 import org
.tianocore
.frameworkwizard
.common
.Tools
;
33 The class is used to override Frame to provides customized interfaces
34 It extends JFrame implements ActionListener and WindowListener
37 public class IFrame
extends JFrame
implements ActionListener
, WindowListener
, ComponentListener
{
40 /// Define class Serial Version UID
42 private static final long serialVersionUID
= -3324138961029300427L;
45 //Define class members
47 private ExitConfirm ec
= null;
50 // To indicate the status while quit
51 // 0 - When setup (Default)
52 // 1 - Whne editing module
54 private int intExitType
= 0;
57 Main class, used for test
62 public static void main(String
[] args
) {
63 IFrame i
= new IFrame();
68 This is the default constructor
77 This method initializes this
80 public void initialize() {
81 this.setResizable(false);
82 this.setDefaultCloseOperation(JFrame
.DO_NOTHING_ON_CLOSE
);
83 this.addWindowListener(this);
84 this.addComponentListener(this);
88 Start the dialog at the center of screen
90 @param intWidth The width of the dialog
91 @param intHeight The height of the dialog
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);
100 Start the window full of the screen
103 protected void maxWindow() {
104 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
105 this.setLocation(0, 0);
110 Start the dialog at the center of screen
113 protected void centerWindow() {
114 centerWindow(this.getSize().width
, this.getSize().height
);
118 Set the exit window type
120 @param ExitType The input data of ExitType
123 protected void setExitType(int ExitType
) {
124 this.intExitType
= ExitType
;
128 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
130 * Override windowClosing to call this.onDisvisible()
133 public void windowClosing(WindowEvent arg0
) {
134 //this.onDisvisible();
137 public void windowOpened(WindowEvent arg0
) {
138 // TODO Auto-generated method stub
142 public void windowClosed(WindowEvent arg0
) {
143 // TODO Auto-generated method stub
147 public void windowIconified(WindowEvent arg0
) {
148 // TODO Auto-generated method stub
152 public void windowDeiconified(WindowEvent arg0
) {
153 // TODO Auto-generated method stub
157 public void windowActivated(WindowEvent arg0
) {
158 // TODO Auto-generated method stub
162 public void windowDeactivated(WindowEvent arg0
) {
163 // TODO Auto-generated method stub
167 public void actionPerformed(ActionEvent arg0
) {
168 // TODO Auto-generated method stub
173 Define the actions when exit
176 public void onExit() {
177 ec
= new ExitConfirm(this, true);
179 //Show different warning message via different ExitType
181 switch (intExitType
) {
183 ec
.setSetupMessage();
186 ec
.setModuleMessage();
197 Define the actions when disvisible
200 public void onDisvisible() {
201 ec
= new ExitConfirm(this, true);
203 //Show different warning message via different ExitType
205 switch (intExitType
) {
207 ec
.setSetupMessage();
210 ec
.setModuleMessage();
219 public int showSaveDialog() {
220 return JOptionPane
.showConfirmDialog(null, "Save all changed files?", "Save", JOptionPane
.YES_NO_CANCEL_OPTION
,
221 JOptionPane
.WARNING_MESSAGE
);
225 Check the input data is empty or not
227 @param strValue The input data which need be checked
229 @retval true - The input data is empty
230 @retval fals - The input data is not empty
233 public boolean isEmpty(String strValue
) {
234 return Tools
.isEmpty(strValue
);
241 public void showDialog() {
242 this.setVisible(true);
245 public void componentResized(ComponentEvent arg0
) {
246 // TODO Auto-generated method stub
250 public void componentMoved(ComponentEvent arg0
) {
251 // TODO Auto-generated method stub
255 public void componentShown(ComponentEvent arg0
) {
256 // TODO Auto-generated method stub
260 public void componentHidden(ComponentEvent arg0
) {
261 // TODO Auto-generated method stub