發現有一些令人討厭的菜單存在自己的RCP程序,我想到的是應該能拿到MenuManager類,然后遍歷一下,去掉Search 菜單,可惜實在腦袋木了,就google了一下,找到解決的代碼:
最近越來越懶了,自我批評一下: 平時不練功,關鍵的時候就只能靠Google這根救命草了。
http://www.richclient2.eu/2006_03_20/getting-rid-of-convert-line-delimiters-to/
20. March 2006
If you're having dependencies to org.eclipse.ui.ide
and you launch your RCP you'll automatically get an entry in the menu-bar that is called "Convert Line Delimiters to" and also "Last Edit Location", although you don't need it. To remove this entries place the following lines in your ApplicationActionBarAdvisor
JAVA:
-
ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry();
-
IActionSetDescriptor[] actionSets = reg.getActionSets();
-
// removing annoying gotoLastPosition Message.
-
String actionSetId =
"org.eclipse.ui.edit.text.actionSet.navigation";
//$NON-NLS-1$
-
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
] });
-
}
-
// Removing convert line delimiters menu.
-
actionSetId = "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo"; //$NON-NLS-1$
-
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
] });
-
}