问题
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