【发布时间】:2015-02-02 15:11:44
【问题描述】:
我在一个项目中工作,使用 Eclipse SWT 应用程序。在所有视图的选项卡上都有默认操作,例如“分离”操作,它获取选项卡并为其创建一个分离的窗口。 在我们的例子中,这会导致以下异常:
Widget has the wrong parent
java.lang.IllegalArgumentException: Widget has the wrong parent
at org.eclipse.swt.SWT.error(SWT.java:4064)
at org.eclipse.swt.SWT.error(SWT.java:3998)
at org.eclipse.swt.SWT.error(SWT.java:3969)
at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
at org.eclipse.swt.widgets.Control.setMenu(Control.java:3159)
at OUR-APPLICATION - Table
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.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Widget.showMenu(Widget.java:1463)
at org.eclipse.swt.widgets.Widget.wmContextMenu(Widget.java:1559)
at org.eclipse.swt.widgets.Table.windowProc(Table.java:5617)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2362)
at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:436)
at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:430)
at org.eclipse.swt.widgets.Table.windowProc(Table.java:5691)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4873)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2459)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3655)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at OUR-APPLICATION.run(Application.java:154)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at OUR-APPLICATION.Application.start(Application.java:107)
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:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
我知道IWorkbenchPreferenceConstants中有一个叫ENABLE_DETACHED_VIEWS的常量,它的默认值为true。
我现在尝试在一般情况下禁用“分离”-Action(也提示如何在一个视图中禁用它,将不胜感激)。有没有一种方法可以覆盖所述常量的默认值,或者有任何其他方法可以从我的选项卡上的右键菜单中删除“分离”操作?
感谢您的帮助
编辑: 我们正在使用 SWT 3.6
【问题讨论】:
-
更完整的堆栈跟踪版本可能会有所帮助
标签: java swt eclipse-rcp