Thursday, July 5, 2012

Remove "Convert Line Delimiters" from "File" menu


To remove "Convert Line Delimiters" or any other items from the "File" menu, use the following snippet and provide respective items'-id to "actionSetId".

Snippet:-


        @SuppressWarnings("restriction")
ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry();
@SuppressWarnings("restriction")
IActionSetDescriptor[] actionSets = reg.getActionSets();
// Removing convert line delimiters from File menu.
String actionSetId = "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo";
for (int i = 0; i <actionSets.length; i++)
{
              if (!actionSets[i].getId().equals(actionSetId))
                   continue;
              IExtension ext = actionSets[i].getConfigurationElement()
                                       .getDeclaringExtension();
              reg.removeExtension(ext, new Object[] { actionSets[i] });
}

No comments:

Post a Comment