本文介绍了在RCP应用程序中添加软件包浏览器会导致某些图标丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的eclispe rcp应用程序中,我添加了一个包浏览器,添加了org.eclipse.jdt.ui





当我使用我的rcp应用程序时,当我通过新建项目向导创建一个新的项目添加一个一般项目,该项目被正确地创建,但是没有加载包资源管理器视图中的相应图标。



我要添加什么插件对我的应用程序看到所有的(平台)图标正确吗?



非常感谢

解决方案

这是Eclipse RCP应用程序中的已知问题。





解决的办法是向您的ApplicationWorkbenchAdvisor.java添加一些代码



以下是RCP中有关此问题的更多文档





在此代码示例中,我添加了项目浏览器和问题视图的图像。



这是我必须添加到我的初始化方法...

  public void initialize (IWorkbenchConfigurer configurer){
super.initialize(configurer);

//这里有一些代码执行一些典型的RCP配置
configurer.setSaveAndRestore(true);
PlatformUI.getPreferenceStore()。setValue(
IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,false);

//这里是关于代码的工作
/ *
*这是一个黑客,可以在Project Explorer中显示项目树图标。
*这是在Eclipse帮助文档中描述的。
*
* 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,
真正);

declareWorkbenchImage(
configurer,
ideBundle,
IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED,
ICONS_PATH +obj16 / cprj_obj.gif,
真正);

declareWorkbenchImage(
configurer,
ideBundle,
IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW,
ICONS_PATH +eview16 / problems_view.gif,
true) ;

declareWorkbenchImage(
configurer,
ideBundle,
IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW_ERROR,
ICONS_PATH +eview16 / problems_view_error.gif,
true) ;


declareWorkbenchImage(
configurer,
ideBundle,
IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW_WARNING,
ICONS_PATH +eview16 / problems_view_warning.gif,
true);

declareWorkbenchImage(
configurer,
ideBundle,
IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH,
ICONS_PATH +obj16 / error_tsk.gif,
true) ;

declareWorkbenchImage(
configurer,
ideBundle,
IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH,
ICONS_PATH +obj16 / warn_tsk.gif,
true) ;

/ *
*此方法中的黑客结束...
* /
}

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);
}

希望这有帮助。



谢谢!


In my eclispe rcp application I added a package explorer adding org.eclipse.jdt.ui

When I use my rcp-app, as I create a new Project by "New Project Wizard" to add a "General Project", the project is correctely created, but the corresponding icon in package explorer view is not loaded.

What is the plugin I have to add to my application to see that all the (platform) Icons correctly ?

Thanks a lot

解决方案

This is a known issue in Eclipse RCP applications.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=234252

The work around is to add some code to your ApplicationWorkbenchAdvisor.java

Here's some more documentation about this issue in RCP

http://help.eclipse.org/ganymede/topic/org.eclipse.platform.doc.isv/guide/cnf_rcp.htm

In this code example, I've added the images for the Project Explorer and the Problems View.

Here's what I had to add to my initialize method...

  public void initialize(IWorkbenchConfigurer configurer) {
     super.initialize(configurer);

     // here's some of my code that does some typical RCP  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);

    declareWorkbenchImage(
            configurer, 
            ideBundle, 
            IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW, 
            ICONS_PATH + "eview16/problems_view.gif", 
            true);

    declareWorkbenchImage(
            configurer, 
            ideBundle, 
            IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW_ERROR, 
            ICONS_PATH + "eview16/problems_view_error.gif", 
            true);


    declareWorkbenchImage(
            configurer, 
            ideBundle, 
            IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEMS_VIEW_WARNING, 
            ICONS_PATH + "eview16/problems_view_warning.gif", 
            true);

    declareWorkbenchImage(
            configurer, 
            ideBundle, 
            IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH, 
            ICONS_PATH + "obj16/error_tsk.gif", 
            true);

    declareWorkbenchImage(
            configurer, 
            ideBundle, 
            IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH, 
            ICONS_PATH + "obj16/warn_tsk.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);
}

Hope this helps.

Thanks!

这篇关于在RCP应用程序中添加软件包浏览器会导致某些图标丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 20:17