Skip to main content

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 ognierFriend
Messages: 21
Registered: September 2013
Junior Member

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 {
	public void execute(IWorkbench workbench,
			@Named(IServiceConstants.ACTIVE_SHELL) Shell shell){
		if (MessageDialog.openConfirm(shell, "Confirmation",
				"Do you want to exit?")) {

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 gargFriend
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

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 CelaFriend
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 FauthFriend
Messages: 2814
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.
Previous Topic:own OSGI Service in Eclipse 4 Application
Next Topic:e4 CSS with Toolbars, MenuBar and groups
Goto Forum:

Current Time: Mon Jun 21 01:10:44 GMT 2021

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

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

Back to the top