How to hide default menus in RCP?

◇◆丶佛笑我妖孽 提交于 2019-12-23 21:20:00

问题


I am new in Eclipse RCP plug in development.

I had written one plug-in with my own perspective and added perspective specific menus within it.

My question is how to hide the default menus provided within Eclipse, like Edit, Navigated, Search, Project ?

I tried with using '< extension point="org.eclipse.core.expressions.definitions" >' and putting my view specific condition, withing menu contribution's.

Any help is appreciated.

Best regards,

Mandar Phatak.


回答1:


You need activities. Example from my current project:

<extension
     point="org.eclipse.ui.activities">
  <activity
        id="arm.activity.disabled"
        name="%arm.activity.disabled.name">
     <enabledWhen>
        <with
              variable="selection">
           <count
                 value="-1">
           </count>
        </with>
     </enabledWhen>
  </activity>
  <activityPatternBinding
        activityId="arm.activity.disabled"
        pattern="org\.eclipse\.m2e\..*">
  </activityPatternBinding>
  <activityPatternBinding
        activityId="arm.activity.disabled"
        pattern="org\.eclipse\.search\..*">
  </activityPatternBinding>
  <activityPatternBinding
        activityId="arm.activity.disabled"
        pattern="org\.eclipse\.team\..*">
  </activityPatternBinding>
  <activityPatternBinding
        activityId="arm.activity.disabled"
        pattern="org\.eclipse\.compare.*">
  </activityPatternBinding>
  <activityPatternBinding
        activityId="arm.activity.disabled"
        pattern="org\.eclipse\.help\.ui\.PrefPageHelp.*">
  </activityPatternBinding>
  <activityPatternBinding
        activityId="arm.activity.disabled"
        isEqualityPattern="true"
        pattern="org.eclipse.ui.ide/org.eclipse.ui.preferencePages.Workspace">
  </activityPatternBinding>
  <activityPatternBinding
        activityId="arm.activity.disabled"
        isEqualityPattern="true"
        pattern="org.eclipse.ui.ide/org.eclipse.ui.preferencePages.Perspectives">
  </activityPatternBinding>
</extension>



回答2:


One approach is in your rcp application you have a class that extends ActionBarAdvisor and in the constructor of the class you can do something like this for example to remove the edit menu

configurer.getMenuManager().remove(IWorkbenchActionConstants.M_EDIT);

All common eclipse menus like edit will have a constant defined in the class above, do that for the menu's you want to remove from your application.

This is only one approach I'm sure there might be others but hope this gets what you need.



来源:https://stackoverflow.com/questions/13820533/how-to-hide-default-menus-in-rcp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!