Probably the earliest you can get the workbench is by subscribing to the application startup complete event UIEvents.UILifeCycle.APP_STARTUP_COMPLETE
with the event broker. However this does not fire until just after the UI is displayed.
Update: The event handler would be something like:
private static final class AppStartupCompleteEventHandler implements EventHandler
{
private final IEclipseContext _context;
AppStartupCompleteEventHandler(final IEclipseContext context)
{
_context = context;
}
@Override
public void handleEvent(final Event event)
{
IWorkbench workbench = _context.get(IWorkbench.class);
workbench.restart();
}
}
Subscribe to this event in the @PostContextCreate method.
@PostContextCreate
public void postContextCreate(IEclipseContext context, IEventBroker eventBroker)
{
eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, new AppStartupCompleteEventHandler(context));
}