Hi!
I'm currently developing an application which requires a user login as very first action. I've registered a StartupMonitor which implements applicationRunning() as shown below.
public void applicationRunning()
{
LoginDialog loginDlg = ContextInjectionFactory.make(LoginDialog.class, m_context);
loginDlg.create();
loginDlg.setBlockOnOpen(true);
loginDlg.open();
}
The LoginDialog consists of a name field, a password field and a login button.
This works nearly as expected. The LoginDialog pops up and the user is able to login. If the authentication was successful I fire an Login_Successful_Event which is handled by a @ProcessAdditions Method. The event handler uses EPartService.showPart() to initialize the UI.
The problem: If the LoginDialog is not the active window and you press the login button (assuming name and password are already filled) an exception is thrown in getActiveWindowService().
//org.eclipse.e4.ui.internal.workbench.ApplicationPartServiceImpl
private EPartService getActiveWindowService() {
IEclipseContext activeWindowContext = application.getContext().getActiveChild();
if (activeWindowContext == null) {
throw new IllegalStateException("Application does not have an active window"); //$NON-NLS-1$
}
(...omitted...)
It seems that the active window is not set at this point of the application life cycle.
Is this behavior 'by design'? Should I use another way to implement my login requirement? How?
Or is this a bug? The JavaDoc of applicationRunning() states that the application is completely initialized...
best regards
Markus