Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Handle workbench exit
Handle workbench exit [message #991971] Thu, 20 December 2012 15:19 Go to next message
Gaetan Pitteloud is currently offline Gaetan PitteloudFriend
Messages: 17
Registered: September 2012
Junior Member
A rather simple question for which I did not find any answer. I have implemented an Exit menu item linked to a command that invokes an exit handler, and I would like this handler to be invoked when the user closes the workbench (top-right X button of the workbench) too.

How do I achieve this ?
Re: Handle workbench exit [message #991977 is a reply to message #991971] Thu, 20 December 2012 15:31 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Hi,

the answer is rather simple and complicated thou.

The first part is simple: You need to register a IWindowCloseHandler to the context of your window.
The second part isn't that simple. It's about the when to put your implementation to the context. It is not possible within a lifecycle hook as this is renderer specific for the window, and therefore the MWindow doesn't exist at that time. Therefore you need to do some kind of workaround to achieve this. I solved it in my projects by doing this the first time a part is created that is always visible within my app. So it shouldn't be called twice.

You can find an example for this here: http://www.vogella.com/articles/EclipseRCP/article.html#context_who

Greez,
Dirk
Re: Handle workbench exit [message #992280 is a reply to message #991977] Fri, 21 December 2012 09:13 Go to previous message
Eclipse UserFriend
There is also a post around some time ago in this forum with a detailed discussion on where to do the registration. Search for IWindowCloseHandler.

As for the implementation you can simply use the EHanlderService and ECommandService to run your handler/command like this :

handlerService.executeHandler(commandService.createCommand("your command id here", null));
Previous Topic:Part / Menus / Menu where does it go?
Next Topic:Add some margin to a PartSash ?
Goto Forum:
  


Current Time: Thu Apr 25 14:38:19 GMT 2024

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

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

Back to the top