]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/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
.WindowEvent
;
23 import java
.awt
.event
.WindowListener
;
25 import javax
.swing
.JFrame
;
26 import javax
.swing
.JOptionPane
;
29 The class is used to override Frame to provides customized interfaces
30 It extends JFrame implements ActionListener and WindowListener
33 public class IFrame
extends JFrame
implements ActionListener
, WindowListener
{
36 /// Define class Serial Version UID
38 private static final long serialVersionUID
= -3324138961029300427L;
41 //Define class members
43 private ExitConfirm ec
= null;
46 // To indicate the status while quit
47 // 0 - When setup (Default)
48 // 1 - Whne editing module
50 private int intExitType
= 0;
53 Main class, used for test
58 public static void main(String
[] args
) {
59 IFrame i
= new IFrame();
64 This is the default constructor
73 This method initializes this
76 public void initialize() {
77 this.setResizable(false);
78 this.setDefaultCloseOperation(JFrame
.DO_NOTHING_ON_CLOSE
);
79 this.addWindowListener(this);
83 Start the dialog at the center of screen
85 @param intWidth The width of the dialog
86 @param intHeight The height of the dialog
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);
95 Start the window full of the screen
98 protected void maxWindow() {
99 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
100 this.setLocation(0, 0);
105 Start the dialog at the center of screen
108 protected void centerWindow() {
109 centerWindow(this.getSize().width
, this.getSize().height
);
113 Set the exit window type
115 @param ExitType The input data of ExitType
118 protected void setExitType(int ExitType
) {
119 this.intExitType
= ExitType
;
123 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
125 * Override windowClosing to call this.onDisvisible()
128 public void windowClosing(WindowEvent arg0
) {
132 public void windowOpened(WindowEvent arg0
) {
133 // TODO Auto-generated method stub
137 public void windowClosed(WindowEvent arg0
) {
138 // TODO Auto-generated method stub
142 public void windowIconified(WindowEvent arg0
) {
143 // TODO Auto-generated method stub
147 public void windowDeiconified(WindowEvent arg0
) {
148 // TODO Auto-generated method stub
152 public void windowActivated(WindowEvent arg0
) {
153 // TODO Auto-generated method stub
157 public void windowDeactivated(WindowEvent arg0
) {
158 // TODO Auto-generated method stub
162 public void actionPerformed(ActionEvent arg0
) {
163 // TODO Auto-generated method stub
168 Define the actions when exit
171 public void onExit() {
172 ec
= new ExitConfirm(this, true);
174 //Show different warning message via different ExitType
176 switch (intExitType
) {
178 ec
.setSetupMessage();
181 ec
.setModuleMessage();
192 Define the actions when disvisible
195 public void onDisvisible() {
196 ec
= new ExitConfirm(this, true);
198 //Show different warning message via different ExitType
200 switch (intExitType
) {
202 ec
.setSetupMessage();
205 ec
.setModuleMessage();
214 public int showSaveDialog() {
215 return JOptionPane
.showConfirmDialog(null, "Save all changed files?", "Save", JOptionPane
.YES_NO_CANCEL_OPTION
, JOptionPane
.WARNING_MESSAGE
);