1

我在 Eclipse 上创建了一个“带视图的插件”,后来我使用在互联网上找到的教程对其进行了修改。我可以打开它并将其添加到 Java 透视图中,但是当我尝试将它移动到我透视图中的另一个位置时,视图关闭并且我得到一个“未处理的事件循环异常”。

这是堆栈跟踪:

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)

几个小时前,我没有这个错误了,现在又出现了。我该如何解决?

4

1 回答 1

0

确保正确实现了 View 的 setFocus() 方法,即,您必须调用 setFocus() 以获得作为 View 一部分的 SWT 控件。这是一个典型的例子,假设“text”是一个声明为字段的 SWT Text 小部件:

    @Override
    public void setFocus() {
        text.setFocus();
    }

另见:https ://bugs.eclipse.org/bugs/show_bug.cgi?id=110354#c15

于 2020-09-29T06:17:07.497 回答