Reputation: 1442
I am trying to make an eclipse RCP aplication runnable from the command line. The fitst part is okay, I can parse cmdline arguments and do what I want. But after that I would like to shutdown the application. What is the correct way to achieve this?
I was trying this: PlatformUI.getWorkbench().close();
But got this:
org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)
at org.eclipse.swt.SWT.error(SWT.java:4282)
at org.eclipse.swt.SWT.error(SWT.java:4197)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212)
at org.eclipse.swt.widgets.Display.release(Display.java:3263)
at org.eclipse.swt.graphics.Device.dispose(Device.java:249)
at uk.ac.bolton.archimate.editor.Application.start(Application.java:65)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
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:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: org.eclipse.swt.SWTException: Widget is disposed
at org.eclipse.swt.SWT.error(SWT.java:4282)
at org.eclipse.swt.SWT.error(SWT.java:4197)
at org.eclipse.swt.SWT.error(SWT.java:4168)
at org.eclipse.swt.widgets.Widget.error(Widget.java:466)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:403)
at org.eclipse.swt.browser.Browser.checkWidget(Browser.java:195)
at org.eclipse.swt.browser.Browser.addProgressListener(Browser.java:386)
at org.rulez.magwas.styledhtml.EventLog$1.run(EventLog.java:80)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
... 18 more
This is how I do deeds at startup:
protected void refreshPluginActions() {
if (!PlatformUI.isWorkbenchRunning()) {
return;
}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
runcmd();
}
});
}
Upvotes: 0
Views: 1195
Reputation: 29139
You are using the correct API for this purpose. Based on your stack trace, it looks like there is a bug in org.rulez.magwas.styledhtml.EventLog class that's causing it to try to update something in the UI during shutdown. A typical solution is to make sure that the code in question performs Widget.isDisposed() call prior to attempting to manipulate the UI and bail out safely if the widget in question is disposed already.
Upvotes: 1