我在Eclipse上创建了一个“带有视图的插件”,后来我使用我在互联网上找到的教程进行了修改。我可以打开它并将其添加到Java Perspective,但是当我尝试将其移动到我的透视图中的另一个位置时,视图关闭并且我得到“未处理的事件循环异常”。
这是堆栈跟踪:
java.lang.NullPointerException
at org.eclipse.ui.internal.FastViewPane.hideView(FastViewPane.java:582)
at org.eclipse.ui.internal.Perspective.hideFastView(Perspective.java:571)
at org.eclipse.ui.internal.Perspective.setActiveFastView(Perspective.java:1933)
at org.eclipse.ui.internal.Perspective.setActiveFastView(Perspective.java:1952)
at org.eclipse.ui.internal.Perspective.toggleFastView(Perspective.java:2365)
at org.eclipse.ui.internal.WorkbenchPage.toggleFastView(WorkbenchPage.java:3972)
at org.eclipse.ui.internal.WorkbenchPage.hideFastView(WorkbenchPage.java:3960)
at org.eclipse.ui.internal.FastViewPane$2.dragStart(FastViewPane.java:156)
at org.eclipse.ui.internal.FastViewPane$2.dragStart(FastViewPane.java:136)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation$1.handleEvent(TabbedStackPresentation.java:118)
at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:269)
at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:282)
at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.handleDragStarted(AbstractTabFolder.java:366)
at org.eclipse.ui.internal.presentations.util.AbstractTabFolder$2.handleEvent(AbstractTabFolder.java:67)
at org.eclipse.ui.presentations.PresentationUtil.handleMouseMove(PresentationUtil.java:110)
at org.eclipse.ui.presentations.PresentationUtil.access$4(PresentationUtil.java:95)
at org.eclipse.ui.presentations.PresentationUtil$2.handleEvent(PresentationUtil.java:63)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
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)
几个小时前,我不再有这个错误了,现在又重新出现了。 我该如何解决?
答案 0 :(得分:1)
确保正确实现了View的setFocus()方法,即,您必须为其中的View一部分的SWT控件调用setFocus()。 这是一个典型的示例,假设'text'是声明为字段的SWT Text小部件:
@Override
public void setFocus() {
text.setFocus();
}
另请参阅:https://bugs.eclipse.org/bugs/show_bug.cgi?id=110354#c15