无法对org. eclipsee .ui.internal. workbenchwindow to org.eclipse.jface. windows . applicationwindow

时间:2023-01-20 20:44:13

This is happening when code is migrated from Eclipse 3.x to 4.5 Mars, Java 6 to Java 8.

这是在从Eclipse 3迁移代码时发生的。x到4.5火星,Java 6到Java 8。

Throws exception while trying to cast to ApplicationWindow in this code:

在尝试在此代码中向ApplicationWindow强制转换时抛出异常:

CoolItem[] coolbarItems = ((ApplicationWindow)getWindowConfigurer().getWindow()).getCoolBarManager().getControl().getItems();

Exception:

例外:

!ENTRY org.eclipse.e4.ui.workbench.swt 4 2 2015-07-16 18:54:00.897

!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.e4.ui.workbench.swt". !STACK 0java.lang.**ClassCastException**: org.eclipse.ui.internal.**WorkbenchWindow cannot be cast to org.eclipse.jface.window.ApplicationWindow** at com.ApplicationWorkbenchWindowAdvisor.setElementPathToolBar(ApplicationWorkbenchWindowAdvisor.java:336) at 

1 个解决方案

#1


1  

Eclipse internals were substantially rewritten for Eclipse 4 and WorkbenchWindow is no longer derived from ApplicationWindow so you cannot do this cast. This was never really part of the defined API anyway.

Eclipse的内部组件已经为Eclipse 4进行了大量重写,而WorkbenchWindow不再从ApplicationWindow派生,因此您无法执行此转换。这从来都不是定义的API的一部分。

To get the cool bar manager use:

要得到cool bar manager的使用:

getWindowConfigurer().getActionBarConfigurer().getCoolBarManager();

#1


1  

Eclipse internals were substantially rewritten for Eclipse 4 and WorkbenchWindow is no longer derived from ApplicationWindow so you cannot do this cast. This was never really part of the defined API anyway.

Eclipse的内部组件已经为Eclipse 4进行了大量重写,而WorkbenchWindow不再从ApplicationWindow派生,因此您无法执行此转换。这从来都不是定义的API的一部分。

To get the cool bar manager use:

要得到cool bar manager的使用:

getWindowConfigurer().getActionBarConfigurer().getCoolBarManager();