Open PartDescriptor on Application Startup [message #1752237] |
Fri, 20 January 2017 08:24 |
Chris Klinger Messages: 2 Registered: January 2017 |
Junior Member |
|
|
Hi everyone,
I have a PartDescriptor in my e4 application and on start up of the application a specific Part using this PartDescriptor should be opened. The Part is opened using a Handler class which is called on UILifeCycle.APP_STARTUP_COMPLETE event using an AddOn.
Infrequently I could observe a "java.lang.IllegalStateException: Application does not have an active window" using this approach. It happens from time to time, without having clear steps to reproduce.
Caused by: java.lang.IllegalStateException: Application does not have an active window
at org.eclipse.e4.ui.internal.workbench.ApplicationPartServiceImpl.getActiveWindowService(ApplicationPartServiceImpl.java:43)
at org.eclipse.e4.ui.internal.workbench.ApplicationPartServiceImpl.findPart(ApplicationPartServiceImpl.java:87)
at org.eclipse.e4.ui.internal.workbench.ApplicationPartServiceImpl.findPart(ApplicationPartServiceImpl.java:87)
at com.my.package.Handler.execute(Handler.java:54)
My Handler#execute code for opening the part looks like (first line here is l. 54 that causes the exception)
MPart part = partService.findPart(PART_ID);
if (Objects.isNull(previewPart)) {
part = partService.createPart(PART_DESCRIPTOR_ID);
part.setElementId(PART_ID);
((MPartSashContainer) partSashContainer).getChildren().add(part);
partService.showPart(part, PartState.CREATE);
}
This handler is called by an AddOn with the following method
@Inject
@Optional
public void notifyApplicationStartUp(@UIEventTopic(UILifeCycle.APP_STARTUP_COMPLETE) Object obj, IEclipseContext context) {
//...
Handler handler = ContextInjectionFactory.make(Handler.class, context);
ContextInjectionFactory.invoke(handler, Execute.class, context);
}
The behavior could be observed on several Windows (7-10) clients.
Does anyone has an idea what causes the exception, something i possible currently miss in my code or another approach how to open the part using the descriptor on start-up?
Thanks and regards, Chris
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01868 seconds