这是 Eclipse RCP 应用程序中的一个已知问题。
https://bugs.eclipse.org/bugs/show_bug.cgi?id=234252
解决方法是在 ApplicationWorkbenchAdvisor.java 中添加一些代码
这里有更多关于 RCP 中这个问题的文档
http://help.eclipse.org/ganymede/topic/org.eclipse.platform.doc.isv/guide/cnf_rcp.htm
我已将此代码添加到我的初始化方法中,以便让图像显示在项目资源管理器中,因此如果这些图像与这些。
public void initialize(IWorkbenchConfigurer configurer) {
super.initialize(configurer);
// here's some of my code that does some typical RCP type configuration
configurer.setSaveAndRestore(true);
PlatformUI.getPreferenceStore().setValue(
IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, false);
// here is the work around code
/*
* This is a hack to get Project tree icons to show up in the Project Explorer.
* It is descriped in the Eclipse Help Documents here.
*
* http://help.eclipse.org/ganymede/topic/org.eclipse.platform.doc.isv/guide/cnf_rcp.htm
*
*/
IDE.registerAdapters();
final String ICONS_PATH = "icons/full/";
Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
declareWorkbenchImage(
configurer,
ideBundle,
IDE.SharedImages.IMG_OBJ_PROJECT,
ICONS_PATH + "obj16/prj_obj.gif",
true);
declareWorkbenchImage(
configurer,
ideBundle,
IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED,
ICONS_PATH + "obj16/cprj_obj.gif",
true);
/*
* End of hack in this method...
*/
}
private void declareWorkbenchImage(IWorkbenchConfigurer configurer_p, Bundle ideBundle, String symbolicName, String path, boolean shared)
{
URL url = ideBundle.getEntry(path);
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
configurer_p.declareImage(symbolicName, desc, shared);
}
希望这会有所帮助。
谢谢!