在 RCP 应用程序中添加包资源管理器会导致丢失一些图标

发布于 2024-12-18 04:07:50 字数 268 浏览 1 评论 0原文

在我的 eclispe rcp 应用程序中,我添加了一个包资源管理器,添加了 org.eclipse.jdt.ui

在此处输入图像描述

当我使用我的rcp-app,当我通过“新建项目向导”创建一个新项目以添加“常规项目”时,该项目已正确创建,但包资源管理器视图中的相应图标未加载。

我必须添加到我的应用程序中才能正确查看所有(平台)图标的插件是什么?

多谢

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

enter image description here

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情绪 2024-12-25 04:07:51

您必须在 WorkbenchAdvisor#initialize(IWorkbenchConfigurer) 方法中手动注册一些适配器。

调用此方法(您将在包 org.eclipse.ui.ide.application 中找到 IDE 类)

org.eclipse.ui.ide.IDE.registerAdapters();

You have to register some adapters in your WorkbenchAdvisor#initialize(IWorkbenchConfigurer) method manually.

Call in this method (you'll find the IDE class in bundle org.eclipse.ui.ide.application

org.eclipse.ui.ide.IDE.registerAdapters();
乱了心跳 2024-12-25 04:07:50

这是 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

在此代码示例中,我添加了 Project Explorer 和 Problems View 的图像。

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

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

希望这有帮助。

谢谢!

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!

染年凉城似染瑾 2024-12-25 04:07:50

您可能应该使用项目资源管理器而不是包资源管理器。 Package Explorer 是特定于 Java 的,Project Explorer 可以执行 Java 和其他所有操作。

以下是更多信息: http:// /help.eclipse.org/indigo/topic/org.eclipse.platform.doc.isv/guide/cnf.htm

You should probably using the Project Explorer rather than the Package Explorer. The Package Explorer is Java-specific, the Project Explorer can do Java and everything else.

Here is some more information: http://help.eclipse.org/indigo/topic/org.eclipse.platform.doc.isv/guide/cnf.htm

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文