Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Close application
Close application [message #1228104] Mon, 06 January 2014 12:21 Go to next message
romain ognier is currently offline romain ognier
Messages: 18
Registered: September 2013
Junior Member
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 11:11 Go to previous messageGo to next message
Divya garg is currently offline Divya garg
Messages: 8
Registered: November 2013
Junior Member
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 11:56 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

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 12:01 Go to previous message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1286
Registered: July 2012
Senior Member
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 Sep 18 01:54:29 GMT 2014

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

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