显示项目资源管理器视图及其对RCP的功能

use*_*967 2 eclipse-plugin eclipse-rcp

如何添加PackageExplorerView的所有工具栏和功能来使RCP应用程序黯淡?我使用PackageExplorer视图ID来显示PackageExplorer视图。它显示了rcp应用程序中的视图。但是,在PackageExplorer视图中创建项目后,它没有显示所创建项目的项目图标。如何解决这个问题?

twi*_*ham 5

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

我已将此代码添加到我的initialize方法中,以使图像显示在Project Explorer中,因此,如果这些图像与这些图像不同,则需要跟踪正确的图像以添加到Package Explorer。

  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);
}
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助。

谢谢!

  • 在较新的eclipse版本中,一项重要更改使其起作用。包含的图像不再是gif,而只是png。因此,将所有地方(例如,“ obj16 / prj_obj.gif”)更改为“ obj16 / prj_obj.png”和所有其他图像,它将起作用。来源https://www.eclipse.org/forums/index.php/t/1088678/ (2认同)