2012-04-27 33 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); 
} 

希望這會有所幫助。

謝謝!

相關問題