views:

155

answers:

1

How do I close an eclipse RCP application on startup, i.e. when the workbench is not yet available? Usually I would use PlatformUI.getWorkbench().close(); but this does not work on startup.

I am doing some checks on startup in one of my plugins Activator classes and I would like to close the application in case the checks fail.

A: 

I have exactly the same problem. The result of calling this close() method in WorkbenchAdvisor (either in initialize(), or preStartup()) is the following exception :

!ENTRY org.eclipse.ui 4 0 2010-05-04 14:15:04.838 !MESSAGE Unhandled event loop exception !STACK 0 java.lang.NullPointerException at org.eclipse.ui.internal.WorkbenchWindow.(WorkbenchWindow.java:375) at org.eclipse.ui.internal.tweaklets.Workbench3xImplementation.createWorkbenchWindow(Workbench3xImplementation.java:31) at org.eclipse.ui.internal.Workbench.newWorkbenchWindow(Workbench.java:1708) at org.eclipse.ui.internal.Workbench.access$14(Workbench.java:1706) at org.eclipse.ui.internal.Workbench$19.runWithException(Workbench.java:1005) at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:133) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3800) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3425) at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803) at org.eclipse.ui.internal.Workbench$27.runWithException(Workbench.java:1361) at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:178) at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150) at org.eclipse.swt.widgets.Display.syncExec(Display.java:4251) at org.eclipse.ui.internal.StartupThreading.runWithoutExceptions(StartupThreading.java:94) at org.eclipse.ui.internal.Workbench.init(Workbench.java:1356) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2312) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at com.fcbm.emedicin.core.EmedicinApplication.start(EmedicinApplication.java:57) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) at org.eclipse.equinox.launcher.Main.main(Main.java:1212)

I also tried in initialize(IWorkbenchConfigurer configurer) using : configurer.emergencyClose() But this leads to the same result...

Any help would be appreciated !

SWT
Have you tried calling close() in WorkbenchWindowAdvisor.preWindowOpen()?
laz
preWindowOpen() is already too late :If I call close() there, some of my parts will still be created.This creation will fail since my initialization code was interrupted earlier...
SWT