+++ /dev/null
-/** @file\r
- \r
- The file is used to override Frame to provides customized interfaces \r
- \r
- Copyright (c) 2006, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
- \r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
- \r
- **/\r
-\r
-package org.tianocore.frameworkwizard.common.ui;\r
-\r
-import java.awt.Dimension;\r
-import java.awt.Toolkit;\r
-import java.awt.event.ActionEvent;\r
-import java.awt.event.ActionListener;\r
-import java.awt.event.ComponentEvent;\r
-import java.awt.event.ComponentListener;\r
-import java.awt.event.WindowEvent;\r
-import java.awt.event.WindowListener;\r
-\r
-import javax.swing.JFrame;\r
-import javax.swing.JOptionPane;\r
-\r
-import org.tianocore.frameworkwizard.common.Tools;\r
-\r
-/**\r
- The class is used to override Frame to provides customized interfaces \r
- It extends JFrame implements ActionListener and WindowListener\r
- \r
- **/\r
-public class IFrame extends JFrame implements ActionListener, WindowListener, ComponentListener {\r
-\r
- ///\r
- /// Define class Serial Version UID\r
- ///\r
- private static final long serialVersionUID = -3324138961029300427L;\r
-\r
- //\r
- //Define class members\r
- //\r
- private ExitConfirm ec = null;\r
-\r
- //\r
- // To indicate the status while quit\r
- // 0 - When setup (Default)\r
- // 1 - Whne editing module\r
- //\r
- private int intExitType = 0;\r
- \r
- /**\r
- Main class, used for test\r
- \r
- @param args\r
- \r
- **/\r
- public static void main(String[] args) {\r
- IFrame i = new IFrame();\r
- i.setVisible(true);\r
- }\r
-\r
- /**\r
- This is the default constructor\r
- \r
- **/\r
- public IFrame() {\r
- super();\r
- initialize();\r
- }\r
-\r
- /**\r
- This method initializes this\r
- \r
- **/\r
- public void initialize() {\r
- this.setResizable(false);\r
- this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);\r
- this.addWindowListener(this);\r
- this.addComponentListener(this);\r
- }\r
-\r
- /**\r
- Start the dialog at the center of screen\r
- \r
- @param intWidth The width of the dialog\r
- @param intHeight The height of the dialog\r
- \r
- **/\r
- protected void centerWindow(int intWidth, int intHeight) {\r
- Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r
- this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);\r
- }\r
- \r
- /**\r
- Start the window full of the screen\r
- \r
- **/\r
- protected void maxWindow() {\r
- Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r
- this.setLocation(0, 0);\r
- this.setSize(d);\r
- }\r
-\r
- /**\r
- Start the dialog at the center of screen\r
- \r
- **/\r
- protected void centerWindow() {\r
- centerWindow(this.getSize().width, this.getSize().height);\r
- }\r
-\r
- /**\r
- Set the exit window type\r
- \r
- @param ExitType The input data of ExitType\r
- \r
- **/\r
- protected void setExitType(int ExitType) {\r
- this.intExitType = ExitType;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)\r
- *\r
- * Override windowClosing to call this.onDisvisible()\r
- * \r
- */\r
- public void windowClosing(WindowEvent arg0) {\r
- //this.onDisvisible();\r
- }\r
-\r
- public void windowOpened(WindowEvent arg0) {\r
- // TODO Auto-generated method stub\r
-\r
- }\r
-\r
- public void windowClosed(WindowEvent arg0) {\r
- // TODO Auto-generated method stub\r
-\r
- }\r
-\r
- public void windowIconified(WindowEvent arg0) {\r
- // TODO Auto-generated method stub\r
-\r
- }\r
-\r
- public void windowDeiconified(WindowEvent arg0) {\r
- // TODO Auto-generated method stub\r
-\r
- }\r
-\r
- public void windowActivated(WindowEvent arg0) {\r
- // TODO Auto-generated method stub\r
-\r
- }\r
-\r
- public void windowDeactivated(WindowEvent arg0) {\r
- // TODO Auto-generated method stub\r
-\r
- }\r
-\r
- public void actionPerformed(ActionEvent arg0) {\r
- // TODO Auto-generated method stub\r
-\r
- }\r
-\r
- /**\r
- Define the actions when exit\r
- \r
- **/\r
- public void onExit() {\r
- ec = new ExitConfirm(this, true);\r
- //\r
- //Show different warning message via different ExitType\r
- //\r
- switch (intExitType) {\r
- case 0:\r
- ec.setSetupMessage();\r
- break;\r
- case 1:\r
- ec.setModuleMessage();\r
- break;\r
- }\r
- ec.setVisible(true);\r
- if (ec.isCancel) {\r
- this.dispose();\r
- System.exit(0);\r
- }\r
- }\r
-\r
- /**\r
- Define the actions when disvisible\r
- \r
- **/\r
- public void onDisvisible() {\r
- ec = new ExitConfirm(this, true);\r
- //\r
- //Show different warning message via different ExitType\r
- //\r
- switch (intExitType) {\r
- case 0:\r
- ec.setSetupMessage();\r
- break;\r
- case 1:\r
- ec.setModuleMessage();\r
- break;\r
- }\r
- ec.setVisible(true);\r
- if (ec.isCancel) {\r
- this.dispose();\r
- }\r
- }\r
- \r
- public int showSaveDialog() {\r
- return JOptionPane.showConfirmDialog(null, "Save all changed files?", "Save", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);\r
- }\r
- \r
- /**\r
- Check the input data is empty or not\r
- \r
- @param strValue The input data which need be checked\r
- \r
- @retval true - The input data is empty\r
- @retval fals - The input data is not empty\r
- \r
- **/\r
- public boolean isEmpty(String strValue) {\r
- return Tools.isEmpty(strValue);\r
- }\r
- \r
- /**\r
- Display the dialog\r
- \r
- **/\r
- public void showDialog() {\r
- this.setVisible(true);\r
- }\r
-\r
-public void componentResized(ComponentEvent arg0) {\r
- // TODO Auto-generated method stub\r
- \r
-}\r
-\r
-public void componentMoved(ComponentEvent arg0) {\r
- // TODO Auto-generated method stub\r
- \r
-}\r
-\r
-public void componentShown(ComponentEvent arg0) {\r
- // TODO Auto-generated method stub\r
- \r
-}\r
-\r
-public void componentHidden(ComponentEvent arg0) {\r
- // TODO Auto-generated method stub\r
- \r
-}\r
-}\r