]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IFrame.java
198841941bd0fbfa6c1df9eeed3f53fd3397d159
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
;
31 The class is used to override Frame to provides customized interfaces
32 It extends JFrame implements ActionListener and WindowListener
35 public class IFrame
extends JFrame
implements ActionListener
, WindowListener
, ComponentListener
{
38 /// Define class Serial Version UID
40 private static final long serialVersionUID
= -3324138961029300427L;
43 //Define class members
45 private ExitConfirm ec
= null;
48 // To indicate the status while quit
49 // 0 - When setup (Default)
50 // 1 - Whne editing module
52 private int intExitType
= 0;
55 Main class, used for test
60 public static void main(String
[] args
) {
61 IFrame i
= new IFrame();
66 This is the default constructor
75 This method initializes this
78 public void initialize() {
79 this.setResizable(false);
80 this.setDefaultCloseOperation(JFrame
.DO_NOTHING_ON_CLOSE
);
81 this.addWindowListener(this);
82 this.addComponentListener(this);
86 Start the dialog at the center of screen
88 @param intWidth The width of the dialog
89 @param intHeight The height of the dialog
92 protected void centerWindow(int intWidth
, int intHeight
) {
93 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
94 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
98 Start the window full of the screen
101 protected void maxWindow() {
102 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
103 this.setLocation(0, 0);
108 Start the dialog at the center of screen
111 protected void centerWindow() {
112 centerWindow(this.getSize().width
, this.getSize().height
);
116 Set the exit window type
118 @param ExitType The input data of ExitType
121 protected void setExitType(int ExitType
) {
122 this.intExitType
= ExitType
;
126 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
128 * Override windowClosing to call this.onDisvisible()
131 public void windowClosing(WindowEvent arg0
) {
132 //this.onDisvisible();
135 public void windowOpened(WindowEvent arg0
) {
136 // TODO Auto-generated method stub
140 public void windowClosed(WindowEvent arg0
) {
141 // TODO Auto-generated method stub
145 public void windowIconified(WindowEvent arg0
) {
146 // TODO Auto-generated method stub
150 public void windowDeiconified(WindowEvent arg0
) {
151 // TODO Auto-generated method stub
155 public void windowActivated(WindowEvent arg0
) {
156 // TODO Auto-generated method stub
160 public void windowDeactivated(WindowEvent arg0
) {
161 // TODO Auto-generated method stub
165 public void actionPerformed(ActionEvent arg0
) {
166 // TODO Auto-generated method stub
171 Define the actions when exit
174 public void onExit() {
175 ec
= new ExitConfirm(this, true);
177 //Show different warning message via different ExitType
179 switch (intExitType
) {
181 ec
.setSetupMessage();
184 ec
.setModuleMessage();
195 Define the actions when disvisible
198 public void onDisvisible() {
199 ec
= new ExitConfirm(this, true);
201 //Show different warning message via different ExitType
203 switch (intExitType
) {
205 ec
.setSetupMessage();
208 ec
.setModuleMessage();
217 public int showSaveDialog() {
218 return JOptionPane
.showConfirmDialog(null, "Save all changed files?", "Save", JOptionPane
.YES_NO_CANCEL_OPTION
, JOptionPane
.WARNING_MESSAGE
);
222 Check the input data is empty or not
224 @param strValue The input data which need be checked
226 @retval true - The input data is empty
227 @retval fals - The input data is not empty
230 public boolean isEmpty(String strValue
) {
231 if (strValue
.length() > 0) {
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