当我编写一个eclipse插件时,我有一个奇怪的问题。当我点击仪表板上的按钮(如GMF)时,它会打开一个包含WizardNewFileCreationPage的向导对话框。当我使用eclipse 3.7.1时,它运行良好,但是当我使用eclipse Indigo Service Release 1时,会发生错误。这是错误消息。
!ENTRY org.eclipse.ui 4 0 2012-03-28 20:52:22.646
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
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:4140)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
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(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: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: java.lang.NullPointerException
at org.eclipse.ui.dialogs.WizardNewFileCreationPage.initialPopulateContainerNameField(WizardNewFileCreationPage.java:688)
at org.eclipse.ui.dialogs.WizardNewFileCreationPage.createControl(WizardNewFileCreationPage.java:247)
at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174)
at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736)
at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:608)
at org.eclipse.jface.window.Window.create(Window.java:431)
at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1089)
at edu.fdu.spl.views.SPLPanel$4$1.run(SPLPanel.java:191)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
... 23 more
这是mouselistener中的代码
Display.getDefault().asyncExec(new Runnable() {
public void run() {
GoalModelCreatewizard wizard = new GoalModelCreatewizard();
Shell sh = Display.getCurrent().getActiveShell();
// sh.open();
// Shell sh= new Shell(display);
WizardDialog dialog = new WizardDialog(sh, wizard);
dialog.setTitle("ContainerSelectionDialog 11111111");
System.out.println("asdaa2");
if (dialog == null) {
System.out.println("asadsa");
}
dialog.create();
if (dialog.open() == WizardDialog.OK) {
System.out.println("asasd");
}
}
});
如何解决这个错误?