I am registering a lifecycle listener in the plugin.xml. It runs ok if I just define a Shell.
e.g.
@PostContextCreate
void postContextCreate(final IEventBroker eventBroker){
System.out.println("CALLED!");
final Shell shell = new Shell(SWT.TOOL | SWT.NO_TRIM);
shell.open();
eventBroker.subscribe(UIEvents.UILifeCycle.ACTIVATE, new EventHandler() {
@Override
public void handleEvent(Event event) {
System.out.println("Closing shell");
shell.close();
shell.dispose();
System.out.println("Closed");
eventBroker.unsubscribe(this);
}
});
But if I change the call to also use a Display:
@PostContextCreate
void postContextCreate(final IEventBroker eventBroker){
System.out.println("CALLED!");
Display display = new Display();
final Shell shell = createSplashShell(display);
shell.open();
while (!shell.isDisposed ()) {
if (!display .readAndDispatch ()) display.sleep ();
}
display.dispose ();
//etc
I get the following exception:
org.eclipse.e4.core.di.InjectionException:
org.eclipse.swt.SWTException: Invalid thread access at
org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
at
org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:229)
at
org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:206)
at
I understand that this exception has to do something with the UI thread but I can not figure out how using Display causes this exception here.
Any help?
As per my understanding, I see that you want to popup a shell when an event occurs.
One display( created by main RCP app) is enough to crate new shell and processing events.