Search code examples
javaeclipse-pluginswteclipse-rcprcp

Disable Eclipse Rename Context Menu


I am working on an RCP application and I want to disable the Rename context menu under File menu. I tried a few approaches but unfortunately none of them worked for me. Following is what I have tried so far.

Using activities

 <extension
     point="org.eclipse.ui.activities">
  <activity
        id="disableRenameContextMenu"
        name="Disable Rename Context Menu">
        <enabledWhen>
           <not>
              <test
                 property="com.session.ui.IsSessionActive">
              </test>
           </not>
     </enabledWhen>
  </activity>
  <activityPatternBinding
        activityId="disableRenameContextMenu"
        pattern="org.eclipse.ui.edit.rename">
  </activityPatternBinding>

Using Perspective Extensions

<extension
     point="org.eclipse.ui.perspectiveExtensions">
  <perspectiveExtension
        targetID="com.perspectives.MyPerspective">
     <hiddenMenuItem
           id="org.eclipse.ui.edit.rename">
     </hiddenMenuItem>
  </perspectiveExtension>

Using Command Handler

<extension
   point="org.eclipse.ui.handlers">
 <handler
    class=""
    commandId="org.eclipse.ui.edit.rename">
 <enabledWhen>
    <not>
        <test
            property="com.session.ui.IsSessionActive">
        </test>
     </not>
 </enabledWhen>

Is there any way I can disable the Rename context menu? Am I doing anything wrong in the above approaches. any help will be highly appreciated.

Thanks


Solution

  • The perspective extension should work but the id in the hiddenMenuItem is the menu id which is not the same as the command id the menu uses.

    For Rename the menu id is 'rename':

    <hiddenMenuItem
       id="rename">
    </hiddenMenuItem>
    

    Menu ids for core menu items are defined in org.eclipse.ui.actions.ActionFactory