Interface IStartup


public interface IStartup
Plug-ins that register a startup extension will be activated after the Workbench initializes and have an opportunity to run code that can't be implemented using the normal contribution mechanisms.

Users can disable the execution of specific extensions in their workspace's preferences via
General -> Startup and Shutdown -> Plug-ins activated on startup.

Instead of implementing this interface and registering the implementation as Eclipse-Extension, handlers that want to be notified upon application start-up can be registered declaratively as OSGi EventHandler service for the UIEvents.UILifeCycle.APP_STARTUP_COMPLETE event.
Such an event-handler is always executed and cannot be disabled via a preferences.

For example a class
 public class MyStartupHandler implements IStartup {
        @Override
        public void earlyStartup() {
                // do handling...
        }
 }
 
can be rewritten to
 @Component(service = EventHandler.class)
 @EventTopics(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE)
 public class MyStartupHandler implements EventHandler {
        @Override
        public void handleEvent(Event event) {
                // do handling...
        }
 }
 

Processing of OSGi declarative services annotations has to be enabled for the containing Plug-in and it has to import the package org.osgi.service.event and org.osgi.service.event.propertytypes as well as a dependency to org.eclipse.e4.ui.workbench. At the same time the registration of the handler as Eclipse Extension for the org.eclipse.ui.startup extension-point can be removed.

Since:
2.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Will be called in a separate thread after the workbench initializes.
  • Method Details

    • earlyStartup

      void earlyStartup()
      Will be called in a separate thread after the workbench initializes.

      Note that most workbench methods must be called in the UI thread since they may access SWT. For example, to obtain the current workbench window, use:

       
       IWorkbench workbench = PlatformUI.getWorkbench();
       workbench.getDisplay().asyncExec(new Runnable() {
         public void run() {
           IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
           if (window != null) {
             // do something
           }
         }
       });
       
       
      See Also: