2011-03-17 85 views
4

我需要對透視菜單進行全面控制。Eclipse RCP:如何配置透視菜單?

我已經攻入該平臺以禁用上下文菜單:

private void disablePerspectiveToolbarMenu() { 
    PerspectiveBarManager perspectiveBarManager = 
     ((WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getPerspectiveBar(); 
    if (perspectiveBarManager!=null){ 
     ToolBar toolBar = perspectiveBarManager.getControl(); 
     Listener[] listeners = toolBar.getListeners(SWT.MenuDetect); 
     if (listeners != null){ 
      for (Listener listener : listeners){ 
       toolBar.removeListener(SWT.MenuDetect, listener); 
      } 
     } 
    } 
} 

但我也需要控制Perspective菜單的默認內容。有一個始終存在的選項可以訪問透視列表外殼。我需要從菜單中刪除該選項。

令人遺憾的是透視菜單完全不受用戶控制。我只需要將視角添加到菜單中,僅此而已!

謝謝。

enter image description here

+2

我在eclipse網站上(幾個星期前)在PerspectiveBar缺乏控制的情況下打開了一個「功能請求」。 https://bugs.eclipse.org/bugs/show_bug.cgi?id=341030 – marcolopes 2011-04-29 21:10:19

回答

2

有擺脫其他3個潛在選項:設置 org.eclipse.ui.IWorkbenchPreferenceConstants.SHOW_OTHER_IN_PERSPECTIVE_MENU 偏好false在您的RCP應用

  1. 。這可以通過在產品定義中包含plugin_customization.ini文件來完成。

  2. 在您的RCP應用程序中修補工作臺。 看一看 org.eclipse.ui.internal.PerspectiveBarNewContributionItemorg.eclipse.ui.actions.ContributionItemFactory.PERSPECTIVES_SHORTLIST

  3. 不要在你的RCP應用程序的默認 觀點吧。 而是使用org.eclipse.ui.menus, 工具條和openPerspective 命令創建透視條 。
+0

謝謝!我無法通過plugin_customization.ini工作。但將它添加到我的其他初始化中:PlatformUI.getPreferenceStore()。setValue(IWorkbenchPreferenceConstants.SHOW_OTHER_IN_PERSPECTIVE_MENU,false); – marcolopes 2011-04-29 21:05:23

1

我做了一些研究,解決方案沒有按照我的預期工作。最後我發現我的錯誤。

設置屬性在我試過的plugin_customization.ini:

org.eclipse.ui.IWorkbenchPreferenceConstants.SHOW_OTHER_IN_PERSPECTIVE_MENU=false 

但這不是正確的符號!請參閱正確的解決方案,我終於加入plugin_customization.xml

org.eclipse.ui/SHOW_OTHER_IN_PERSPECTIVE_MENU=false 

所以接口或類指定屬性IST不是符號的一部分的名字!

相關問題