2012-04-27 75 views
2

如何将PackageExplorerView的所有工具栏和功能添加到eclipse RCP应用程序中?我使用PackageExplorer视图ID来显示PackageExplorer视图。它显示了rcp应用程序中的视图。但是在PackageExplorer视图中创建项目后,它不会显示创建的项目的项目图标。如何重新解决这个问题?显示项目资源管理器视图及其对RCP的功能

+0

可能是[在RCP应用程序中添加软件包浏览器导致丢失某些图标]副本(http://stackoverflow.com/q/8277902/150166)。 – 2012-04-27 07:42:26

回答

4

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

希望这会有所帮助。

谢谢!

相关问题