This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 412554 - Events posted by IEventBroker are not received in @UIEventTopic method
Summary: Events posted by IEventBroker are not received in @UIEventTopic method
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.4 M1   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-08 19:15 EDT by Jakub Czerny CLA
Modified: 2014-05-30 13:55 EDT (History)
5 users (show)

See Also:


Attachments
demo project (4.79 KB, application/zip)
2013-07-08 19:17 EDT, Jakub Czerny CLA
no flags Details
demo project v2 (5.37 KB, application/zip)
2013-07-11 05:28 EDT, Jakub Czerny CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Czerny CLA 2013-07-08 19:15:13 EDT
Events send (or posted) by IEventBroker are not received in methods the argument of which is annotated with @UIEventTopic.

Steps to reproduce:
1. Import attached project into workspace (of Eclipse 4.3, e4 0.14 or nightly)
2. Run plugin project as 'Eclipse application'.
3. Select 'send' in main menu.

Expected result:
Broker in menu button handler (class MenuHandler) posts a message that is received by Receiver.onMessage() method.

Actual result:
broker.post() is called in MenuHandler. However Receiver.onMessage() is not. According to log messages in console view the Redeiver class is properly initialized (constructor is called).

Bug appears after upgrade to Eclipse 4.3, e4 0.14. It works fine with Eclipse 4.2 and e4 0.13.
Comment 1 Jakub Czerny CLA 2013-07-08 19:17:42 EDT
Created attachment 233249 [details]
demo project

forgotten sample project in attachement
Comment 2 Lars Vogel CLA 2013-07-10 06:06:28 EDT
You are using new to create your Receiver instance. This way it is not registered with the framework as receiver. Try 
Receiver receiver = ContextInjectionFactory.make(Receiver.class,
				context);
Comment 3 Jakub Czerny CLA 2013-07-11 05:28:37 EDT
Created attachment 233358 [details]
demo project v2

I've slightly altered the demo project. Receiver is now registrated by following code:

Receiver receiver = ContextInjectionFactory.make(Receiver.class, context);
context.set(Receiver.class, receiver);

It works with Juno and doesn't work with Kepler.
(Direct event handling (IEventBroker.subscribe()) works on boths versions)
Comment 4 Paul Webster CLA 2013-07-18 13:11:38 EDT
In org.iczerny.message.MenuHandler you can't use @Inject (can't use it in general on handlers).

You have to use 
@Execute
public void execute(IEventBroker broker) {
...
}

But even with that, it still doesn't work in the case where you instantiate a class with a processor.  The UIEventObjectSupplier is being created as a side effect in the org.eclipse.e4.ui.internal.workbench.swt.E4Application.loadApplicationModel(IApplicationContext, IEclipseContext) processing, but the needs ContextInjectionFactory.setDefault(appContext); called before it is injected otherwise it doesn't have a uiSync object.

One possible solution is to move ContextInjectionFactory.setDefault(appContext); towards the beginning of org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(IApplicationContext, Display)

PW
Comment 5 Thomas Schindl CLA 2013-07-18 14:08:49 EDT
There's a request and patch in bug 413149 for moving the default supplier setting towards the beginning of the E4Application
Comment 6 Paul Webster CLA 2013-09-10 15:04:23 EDT
Looks like this was fixed in M1 by bug 413149

PW
Comment 7 Eric Moffatt CLA 2014-05-30 13:55:14 EDT
PW, should we mark this one a DUP of  bug 413149 ?