Question

I am trying to extending "org.eclipse.ui.startup" extendion point. but it seems in eclipse e4 ,it does not even getting called. is this extension is broken in eclipse e4(Juno)

Was it helpful?

Solution

I had the same problem and couldn't find an answer, but in the process I discovered the LifeCycleHandler which is even better for my purpose. It might be a good alternative for you as well.

Just as with the startup-extension you can reference a handler from your plugin.xml:

<property name="lifeCycleURI" value="platform:/plugin/<plug-in-id>/<path-to-handler-class>" />

In the handler you can use annotations to mark the method that is to be invoked as well as dependency injection:

public class StartupHandler {
    @Inject
    Foo bar;

    @PostContextCreate
    public void startup(IEclipseContext context) {
       // do something
    }
}

You can find a detailed example here: https://marcteufel.wordpress.com/2011/05/05/231/

OTHER TIPS

IStartup#earlyStartup() needs the compatibility layer, so it does not work in a pure E4 Application. (see #1)

To launch a process in a pure E4 Application you should use a lifecycle hook. So:

Reference your ApplicationLifecycle handler class from plugin.xml

<property name="lifeCycleURI" value="platform:/plugin/<plug-in-id>/<path-to-handler-class>" />

write your lifecycle handler class

public class ApplicationLifecycleHandler {

    @PostContextCreate
    public void startup(IEclipseContext context) {
       // do initialization 
    }
}

Add an hook to handle events at Application Startup Complete

@PostContextCreate
public void postContextCreate(final IEventBroker eventBroker, etc .. ) {

    // 
    eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE,
            new EventHandler() {
                @Override
                public void handleEvent(Event event) {
                    // Your code executed at startup,
                    // after application startup is completed
                }
            });

}

(#1) org.eclipse.ui.startup extension doc

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top