我有一个 CTabFolder,其中包含一些一次性选项卡,每个选项卡都包含一个 TreeViewer。我希望每个查看器都有一个 DragSupport。所以很自然地我使用了这个方法TreeViewer#addDragSupport
。一切都按预期工作,除了当我关闭 shell 并且 SWT 尝试处理所有小部件时。
发生的异常是:
org.eclipse.swt.SWTException: Widget is disposed
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.widgets.Widget.error(Unknown Source)
at org.eclipse.swt.widgets.Widget.checkWidget(Unknown Source)
at org.eclipse.swt.widgets.Widget.removeListener(Unknown Source)
at org.eclipse.swt.dnd.DragSource.onDispose(Unknown Source)
at org.eclipse.swt.dnd.DragSource.access$1(Unknown Source)
at org.eclipse.swt.dnd.DragSource$2.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Widget.dispose(Unknown Source)
at org.eclipse.swt.dnd.DragSource$1.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Widget.dispose(Unknown Source)
at org.eclipse.jface.viewers.ContentViewer.handleDispose(ContentViewer.java:172)
at org.eclipse.jface.viewers.StructuredViewer.handleDispose(StructuredViewer.java:2328)
at org.eclipse.jface.viewers.ContentViewer$2.widgetDisposed(ContentViewer.java:214)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Widget.dispose(Unknown Source)
at org.eclipse.jface.viewers.ContentViewer.handleDispose(ContentViewer.java:172)
at org.eclipse.jface.viewers.StructuredViewer.handleDispose(StructuredViewer.java:2328)
at org.eclipse.jface.viewers.ContentViewer$2.widgetDisposed(ContentViewer.java:214)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Widget.dispose(Unknown Source)
at org.eclipse.jface.viewers.ContentViewer.handleDispose(ContentViewer.java:172)
at org.eclipse.jface.viewers.StructuredViewer.handleDispose(StructuredViewer.java:2328)
at org.eclipse.jface.viewers.ContentViewer$2.widgetDisposed(ContentViewer.java:214)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Widget.dispose(Unknown Source)
at org.eclipse.jface.viewers.ContentViewer.handleDispose(ContentViewer.java:172)
at org.eclipse.jface.viewers.StructuredViewer.handleDispose(StructuredViewer.java:2328)
at org.eclipse.jface.viewers.ContentViewer$2.widgetDisposed(ContentViewer.java:214)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Composite.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Canvas.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Decorations.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Shell.releaseChildren(Unknown Source)
at org.eclipse.swt.widgets.Widget.release(Unknown Source)
at org.eclipse.swt.widgets.Widget.dispose(Unknown Source)
at org.eclipse.swt.widgets.Decorations.dispose(Unknown Source)
at org.eclipse.swt.widgets.Shell.dispose(Unknown Source)
at org.eclipse.jface.window.Window.close(Window.java:335)
at org.eclipse.jface.window.ApplicationWindow.close(ApplicationWindow.java:307)
at org.eclipse.jface.window.Window.handleShellCloseEvent(Window.java:741)
at org.eclipse.jface.window.Window$3.shellClosed(Window.java:687)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Decorations.closeWidget(Unknown Source)
at org.eclipse.swt.widgets.Decorations.WM_CLOSE(Unknown Source)
at org.eclipse.swt.widgets.Control.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Canvas.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Decorations.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Shell.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Display.windowProc(Unknown Source)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(Unknown Source)
at org.eclipse.swt.widgets.Shell.callWindowProc(Unknown Source)
at org.eclipse.swt.widgets.Control.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Canvas.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Decorations.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Shell.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Display.windowProc(Unknown Source)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(Unknown Source)
at org.eclipse.swt.widgets.Shell.callWindowProc(Unknown Source)
at org.eclipse.swt.widgets.Control.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Canvas.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Decorations.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Shell.windowProc(Unknown Source)
at org.eclipse.swt.widgets.Display.windowProc(Unknown Source)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
这似乎有点广泛。似乎 SWT 在处理后试图从树中删除 DragListener。我真的不明白这怎么可能。
我不认为我在实现 Source/Target 和 Transfer 类型时犯了错误,因为拖放就像一个魅力。
将拖动支持添加到包含在一次性小部件中的 TreeViewer 时,是否可能需要考虑任何陷阱?
如果您需要代码示例,请告诉我。