Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Listen to MPart close events(Be able to perform operations when a part is closed)
Listen to MPart close events [message #1385996] Thu, 12 June 2014 18:56 Go to next message
Thomas Muller is currently offline Thomas MullerFriend
Messages: 9
Registered: September 2011
Junior Member
Hi all,

in my E4 RCP application, I create programmatically some specific instances of a domain model and I then display them in read-only MParts (which I reuse from an Eclipse 4 RCP third-party plugin [i.e. which I can't modify the source]).

Now, when the user closes one of these MPart, I would like to perform some operations on the instance it corresponds to. I have stored the association between an MPart and the model instance it corresponds to.

In order to perform these operations, I thus would like to get the notification that the part in which I'm interested in, is closed.
Could you please tell me what is the best way to acheive that?

I've read and tried the code from http://www.eclipse.org/forums/index.php/t/332286/
but :
1. the handler by my side is not triggered when any part is closed... is there some extra dependencies missing?
2. this code is quite old now, and quite complex. Is it still relevant though? Is it something more straightforward?
3. the topic is UIEvents.UIElement.TOPIC_TOBERENDERED and does not seem to be valid to me, as a part can be deactivated when it is put under another although not closed. Isn't it anything properly related to a "CLOSE" event?

Many thanks in advance.

Re: Listen to MPart close events [message #1386049 is a reply to message #1385996] Fri, 13 June 2014 08:28 Go to previous messageGo to next message
Eclipse UserFriend
You can add a @PreDestroy method on the part itself and either act there or publish an event and act elsewhere. The second alternative is pretty straightforward: eventBroker.post(topic, data); on the @PreDestroy and a method annotated with @Inject @UIEventTopic(topic) elsewhere.
Re: Listen to MPart close events [message #1386054 is a reply to message #1386049] Fri, 13 June 2014 08:53 Go to previous messageGo to next message
Thomas Muller is currently offline Thomas MullerFriend
Messages: 9
Registered: September 2011
Junior Member
Hi Sopot, many thanks for your answer.
This would be the thing if I could modify the MPart code. However, as I said in my first message: "I reuse the MPart from an Eclipse 4 RCP third-party plugin [i.e. which I can't modify the source])."

Is there any alternative according to this constraint?
Re: Listen to MPart close events [message #1386810 is a reply to message #1386054] Fri, 20 June 2014 17:09 Go to previous message
Eric Moffatt is currently offline Eric MoffattFriend
Messages: 118
Registered: July 2009
Senior Member

You could also listen to the model for 'widget' or 'object' changes, check if it's your part and going null would indicate that it's closed. An alternative would be do get the view's control and add a dispose listener to it (that way the control will still be 'live' when you get called).
Previous Topic:Eclipse 4 RCP applications - Creating a Feature Product including all of its plugin dependencies
Next Topic:MinMaxAddon and Buttons
Goto Forum:
  


Current Time: Fri Apr 26 08:10:34 GMT 2024

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

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

Back to the top