Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » Close application
Close application [message #1228104] Mon, 06 January 2014 07:21 Go to next message
Eclipse UserFriend
Hello,

I am doing an Eclipse application, and I have an issue closing my application properly.
Here is the handler I use to close my application :

public class ExitHandler {
	@Execute
	public void execute(IWorkbench workbench,
			@Named(IServiceConstants.ACTIVE_SHELL) Shell shell){
		if (MessageDialog.openConfirm(shell, "Confirmation",
				"Do you want to exit?")) {
			workbench.close();
		}
	}
}


It works just fine if the user does "File -> Exit"
But it does not work if he clicks on the "red cross" or does Alt+F4.

How can I call my handler for the two last ways ?

Thank you for your help !
Re: Close application [message #1239101 is a reply to message #1228104] Mon, 03 February 2014 06:11 Go to previous messageGo to next message
Eclipse UserFriend
Hello Romain,

For Alt+F4, you need to create keybinding and then attach your command to it.
For "red cross", I think your application should be closing automatically unless you explicitly stop it from being closed.

Its late. But I hope it will help

Regards
Divya
Re: Close application [message #1239116 is a reply to message #1239101] Mon, 03 February 2014 06:56 Go to previous messageGo to next message
Eclipse UserFriend
You need to override the IWindowCloseHandler in the IEclipseContext of the Window. Then you'll get this whenever you try to close in any way.
Re: Close application [message #1239119 is a reply to message #1239116] Mon, 03 February 2014 07:01 Go to previous message
Eclipse UserFriend
And one way to override the IWindowCloseHandler is to listen to the UIEvents.UILifecycle.APP_STARTUP_COMPLETE event in a lifecycle hook.

http://www.eclipse.org/forums/index.php/mv/msg/458123/1017259/#msg_1017259
Previous Topic:own OSGI Service in Eclipse 4 Application
Next Topic:e4 CSS with Toolbars, MenuBar and groups
Goto Forum:
  


Current Time: Thu Jul 24 13:35:48 EDT 2025

Powered by FUDForum. Page generated in 1.07955 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top