删除“文件,编辑,...等”; Eclipse RCP应用程序中的菜单 [英] Remove "File, edit,...etc" menus from Eclipse RCP application
问题描述
我想从我的RCP应用程序中删除文件,编辑,源,重构等菜单。
我可以使用 hideActionSet()
吗?还是应该怎么做?
I want to remove the File, edit, Source, Refactor, etc. menus from my RCP application
Can I use hideActionSet()
? or what should I do ?
推荐答案
是的;在您的 ApplicationWorkbenchWindowAdvisor 中,覆盖 postWindowOpen()。
That's right; in your ApplicationWorkbenchWindowAdvisor, override postWindowOpen().
棘手的问题通常是弄清楚您要删除的操作集的名称,但是您可以使用旧的备用ALT-SHIFT-F2( 插件菜单间谍),然后单击要删除的菜单项之一。
The tricky bit is usually figuring out the names of the actionsets that you want to remove, but you can use the old standby ALT-SHIFT-F2 (the default keybinding for 'Plugin-in Menu Spy') and click on one of the menu items that you want to remove.
请注意,如果菜单项被禁用,间谍将不会为您提供任何信息。
public void postWindowOpen() {
runApplicationWorkbenchDelegate();
// remove unwanted UI contributions that eclipse makes by default
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (int i = 0; i < windows.length; ++i) {
IWorkbenchPage page = windows[i].getActivePage();
if (page != null) {
// hide generic 'File' commands
page.hideActionSet("org.eclipse.ui.actionSet.openFiles");
// hide 'Convert Line Delimiters To...'
page.hideActionSet("org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo");
// hide 'Search' commands
page.hideActionSet("org.eclipse.search.searchActionSet");
// hide 'Annotation' commands
page.hideActionSet("org.eclipse.ui.edit.text.actionSet.annotationNavigation");
// hide 'Forward/Back' type navigation commands
page.hideActionSet("org.eclipse.ui.edit.text.actionSet.navigation");
}
}
}
这篇关于删除“文件,编辑,...等”; Eclipse RCP应用程序中的菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!