Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Eclipse 4 System Events
Eclipse 4 System Events [message #937045] Mon, 08 October 2012 15:56 Go to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Hi, how can I catch system events. For example, I want to catch an event if somebody closes a part like so:

@Inject
@Optional
public void closeHandler(@EventTopic(UIEvents.ALL_SUB_TOPICS) MPart part,
                         @EventTopic(UIEvents.ALL_SUB_TOPICS) Event event) { 
    if (part != null)
	System.out.println(part.isToBeRendered() + " : " + event.getTopic());
    }


I receive the following from the method. The method is in the part that I am closing.

....
true : org/eclipse/e4/ui/LifeCycle/activate
true : org/eclipse/e4/ui/model/application/ApplicationElement/tags/REMOVE
true : org/eclipse/e4/ui/model/application/ApplicationElement/tags/REMOVE
false : org/eclipse/e4/ui/model/ui/ElementContainer/selectedElement/SET
false : org/eclipse/e4/ui/model/ui/UIElement/widget/SET
false : org/eclipse/e4/ui/model/ui/UIElement/renderer/SET
false : org/eclipse/e4/ui/model/application/Contribution/object/SET
false : org/eclipse/e4/ui/model/ui/Context/context/SET
false : org/osgi/service/log/LogEntry/LOG_INFO

What is the exact part close event? Or don't i get it because I am in the part that is closed?

thanks in advance

Wim
Re: Eclipse 4 System Events [message #937753 is a reply to message #937045] Tue, 09 October 2012 08:25 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 482
Registered: December 2010
Location: Germany
Senior Member
You can use @PersistState and @PreDestroy to manage the end of your part life cycle.
Re: Eclipse 4 System Events [message #938304 is a reply to message #937753] Tue, 09 October 2012 18:58 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Thanks for the tip Cristoph but I really want to use the event system.

Re: Eclipse 4 System Events [message #938467 is a reply to message #938304] Tue, 09 October 2012 22:45 Go to previous messageGo to next message
Eclipse UserFriend
eventBroker.subscribe(UIEvents.UIElement.TOPIC_TOBERENDERED, toBeRenderedHandler);

will subscribe you to all unrenderes. Check if the origin ( event.getProperty(UIEvents.EventTags.ELEMENT)) is your part and do what you wish. Try putting this into an addon not in the part itself although I'm not sure of the implications.

For more details see http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java (line 102 builds the handler and line 450 registers it).
Re: Eclipse 4 System Events [message #939478 is a reply to message #938467] Wed, 10 October 2012 19:54 Go to previous message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Thanks Sopot. I will try that.
Previous Topic:XWT and control binding
Next Topic:(Announce) Jeeeyul's Eclipse Theme - Chrome supports Juno SR1 fully now.
Goto Forum:
  


Current Time: Tue Mar 19 10:13:21 GMT 2024

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

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

Back to the top