Java - Eclipse-RCP

IStartup - load plugin early

When a plugin expands the extensionpoint org.eclipse.ui.startup, the plugin is loaded immediately after the initialization of the workbench.

package com.sowas.javawiki.startup;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
 
public class MyStartup implements IStartup {
   public void earlyStartup() {
      IWorkbench workbench = PlatformUI.getWorkbench();
      workbench.getDisplay().syncExec(new Runnable() {
         public void run() {
            System.out.println("MyStartup started.");
         }
      });
   }
}




If there shall occur UI-accesses in the earlyStartup()-method, so this must happen as follows:

public void earlyStartup() {
   final IWorkbench workbench = PlatformUI.getWorkbench();
   workbench.getDisplay().asyncExec(new Runnable() {
      public void run() {
         IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
            if (window != null) {
               // ...
            }
         }
   });
}
 

Eigene Werkzeuge
Werkzeuge

gratis Counter by GOWEB
seit 9.10.2007