Problem using StartupMonitor to show a login dialog [message #798212] |
Tue, 14 February 2012 06:39  |
Eclipse User |
|
|
|
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
|
|
|
|
Re: Problem using StartupMonitor to show a login dialog [message #798261 is a reply to message #798241] |
Tue, 14 February 2012 07:57   |
Eclipse User |
|
|
|
I register my implementation of StartupMonitor as a service in the Activator of the containing bundle.
public void start(BundleContext context) throws Exception
{
(...)
IEclipseContext eclipseCtx = EclipseContextFactory.getServiceContext(context);
LoginStartupMonitor lsm = new LoginStartupMonitor(eclipseCtx);
s_loginMonitorRegistration = context.registerService(StartupMonitor.class, lsm, monitorProps);
(...)
}
The handler, which handles the Login_Successful_Event, is registered during @ProcessAdditions but executed later:
@ProcessAdditions
public void processAddtions(IEclipseContext context, IEventBroker evtBroker, final EPartService partService,
ISessionService sessionService, final ISystemUIService sysUIService)
{
(...)
evtBroker.subscribe(ISessionService.EVENT_LOGIN_SUCCESSFUL, new EventHandler()
{
@Override
public void handleEvent(Event evt)
{
String strTopic = evt.getTopic();
// Login-Event
if (ISessionService.EVENT_LOGIN_SUCCESSFUL.equals(strTopic)) {
// NavigatorPart und ResultsPart anzeigen
partService.showPart(NavigatorPart.ID, PartState.CREATE);
partService.showPart(NavigatorPart.ID, PartState.VISIBLE);
sysUIService.startScreenMonitoring();
}
}
(...)
Maybe the place to register the handler is not the most adequate, but it will be executed at a later point of time.
What I want to achieve is, that the workbench is empty besides the login dialog. If authentication succeeded the workbench should be populated with some standard views. Later I'd like to restore the previous state of the workbench.
Markus
|
|
|
Re: Problem using StartupMonitor to show a login dialog [message #798282 is a reply to message #798261] |
Tue, 14 February 2012 08:33   |
Eclipse User |
|
|
|
So I get this right you want to show the workbench while the login
dialog is displayed? Why don't you block in @ProcessAdditions until the
user is logged in, modify the model directly afterwards and the let the
workbench start proceed?
Tom
Am 14.02.12 13:57, schrieb Markus Stier:
> I register my implementation of StartupMonitor as a service in the
> Activator of the containing bundle.
>
>
> public void start(BundleContext context) throws Exception
> {
> (...)
> IEclipseContext eclipseCtx =
> EclipseContextFactory.getServiceContext(context);
> LoginStartupMonitor lsm = new LoginStartupMonitor(eclipseCtx);
> s_loginMonitorRegistration =
> context.registerService(StartupMonitor.class, lsm, monitorProps);
> (...)
> }
>
>
> The handler, which handles the Login_Successful_Event, is registered
> during @ProcessAdditions but executed later:
>
>
> @ProcessAdditions
> public void processAddtions(IEclipseContext context, IEventBroker
> evtBroker, final EPartService partService,
> ISessionService sessionService, final ISystemUIService
> sysUIService)
> {
> (...)
>
> evtBroker.subscribe(ISessionService.EVENT_LOGIN_SUCCESSFUL, new
> EventHandler()
> {
>
> @Override
> public void handleEvent(Event evt)
> {
> String strTopic = evt.getTopic();
>
> // Login-Event
> if
> (ISessionService.EVENT_LOGIN_SUCCESSFUL.equals(strTopic)) {
> // NavigatorPart und ResultsPart anzeigen
> partService.showPart(NavigatorPart.ID,
> PartState.CREATE);
> partService.showPart(NavigatorPart.ID,
> PartState.VISIBLE);
>
> sysUIService.startScreenMonitoring();
> }
> }
> (...)
>
>
> Maybe the place to register the handler is not the most adequate, but it
> will be executed at a later point of time.
>
> What I want to achieve is, that the workbench is empty besides the login
> dialog. If authentication succeeded the workbench should be populated
> with some standard views. Later I'd like to restore the previous state
> of the workbench.
>
> Markus
>
>
|
|
|
Re: Problem using StartupMonitor to show a login dialog [message #798311 is a reply to message #798282] |
Tue, 14 February 2012 09:19  |
Eclipse User |
|
|
|
Yes, I want to show an empty workbench window as 'background' and the login dialog in front of it.
To my understanding @ProcessAdditions is executed right before model elements are rendered. Which counts for the workbench window too.
Blocking in @ProcessAdditions won't give me the required UI feeling.
Markus
|
|
|
Powered by
FUDForum. Page generated in 0.05519 seconds