Hong Yung
Hong Yung

Reputation: 33

How to hide the "Set Encoding..." menu in eclipse

Do you have any idea how to hide the Set Encoding menu in the Edit Menu? I had spend some hard time looking for a way to hide this menu.

I try to dig the plugin.xml in many plugins with no luck to look for this Set Encoding action command.

I can't get the action definition id from plug-in spy that I can use to hide this menu in my developed plugin. I only get the info below:

The active contribution item class:

org.eclipse.ui.texteditor.RetargetTextEditorAction

The contributing plug-in:

org.eclipse.ui.workbench.texteditor (3.5.1.r352_v20100105)

Upvotes: 3

Views: 88

Answers (2)

Balder
Balder

Reputation: 8718

The org.eclipse.ui.edit.text.changeEncoding action is usually added to the Edit menu dynamically by the IEditorActionBarContributor specified for the contriubutorClass attribute of the declared org.eclipse.ui.editors extension point.

E.g. the org.eclipse.ui.DefaultTextEditor gets declared by the org.eclipse.ui.editors plugin itself, and specifies the class TextEditorActionContributor as the contriubutorClass. TextEditorActionContributor does add the ChangeEncoding action like so:

public void init(IActionBars bars) {
    super.init(bars);

    IMenuManager menuManager= bars.getMenuManager();
    IMenuManager editMenu= menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
    if (editMenu != null)
        editMenu.add(fChangeEncodingAction);
}}

So to completely remove this action from the Edit menu, you would need to define your own editors by extending org.eclipse.ui.editors and providing you own implementation of IEditorActionBarContributor.

Upvotes: 1

Fredrik
Fredrik

Reputation: 10656

You must edit the perspective, right click on the toolbar in Eclipse and you should get a context menu with the alternative Customize perspective.... Then go to the tab Menu visibility and disable the menu item you want to hide.

Upvotes: 0

Related Questions