我突然在我的RCP应用程序的菜单栏中“运行”和“搜索”。无论如何要删除它们吗?
答案 0 :(得分:8)
首先,请检查 this thread (以及Contributing Actions to the Eclipse Workbench中使用的文章“this thread”):
诀窍是“
check the launcher config
” - 即使在完全全新安装Eclipse 3.1.1之后,除了我自己的插件之外,我的WS中没有任何其他内容,令人烦恼的额外菜单和恼人的错误“编辑最后位置“仍然存在。然后我按照你的建议去了启动器配置,它有很多残余(由Eclipse自动创建) - 所以我取消选择所有,选择我的插件,然后点击“
Add Required
”强>;用WS运行 - 很棒!
删除“平台”功能可以解决所有问题 - 这是一个非常难以找到的非常简单的修复方法!
这就是说,一般来说,隐藏一些动作贡献你可以尝试,比如在this thread中:
1 /隐藏ActionSet扩展点定义的菜单/ coolbar。
IWorkbenchPage.hideActionSet(actionSetId)
IWorkbenchPage.hideActionSet("org.eclipse.search.menu");
2 /隐藏其菜单:
MenuManager mbManager = ((ApplicationWindow)page.getWorkbenchWindow()).getMenuBarManager();
for (int i=0; i<mbManager.getItems().length; i++){
IContributionItem item=mbManager.getItems()[i];
if (item.getId().equals("org.eclipse.search.menu")){
item.setVisible(false);
}
}
或者您可以尝试this thread,通过PerspectiveListener
隐藏任何视角:
我通过浏览依赖的eclipse插件获得的动作ID ..搜索
ActionSets
package ch.post.pf.gui.prototyp.sesam.pstonline;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.IPerspectiveListener;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
public class ActionWiper implements IStartup, IPerspectiveListener {
private static final String[] ACTIONS_2_WIPE = new String[] {
"org.eclipse.search.searchActionSet",
"org.eclipse.ui.edit.text.actionSet.presentation",
"org.eclipse.ui.edit.text.actionSet.openExternalFile",
"org.eclipse.ui.edit.text.actionSet.annotationNavigation",
"org.eclipse.ui.edit.text.actionSet.navigation",
"org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo",
"org.eclipse.update.ui.softwareUpdates" };
public void earlyStartup() {
IWorkbenchWindow[] windows = PlatformUI.getWorkbench()
.getWorkbenchWindows();
for (int i = 0; i < windows.length; i++) {
IWorkbenchPage page = windows[i].getActivePage();
if (page != null) {
wipeActions(page);
}
windows[i].addPerspectiveListener(this);
}
}
private void wipeActions(IWorkbenchPage page) {
for (int i = 0; i < ACTIONS_2_WIPE.length; i++) {
wipeAction(page, ACTIONS_2_WIPE[i]);
}
}
private void wipeAction(final IWorkbenchPage page, final String actionsetId) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
page.hideActionSet(actionsetId);
}
});
}
public void perspectiveActivated(IWorkbenchPage page,
IPerspectiveDescriptor perspective) {
wipeActions(page);
}
public void perspectiveChanged(IWorkbenchPage page,
IPerspectiveDescriptor perspective, String changeId) {
}
}
并删除首选项:
随着
PreferenceManager
我甚至摆脱了不受欢迎的偏好.. :)PREFERENCES_2_WIPE
字符串必须是您想要摆脱的主要类别的ID。像 “org.eclipse.ui.preferencePages.Workbench” - &gt;显示为常规
PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager();
for (int i = 0; i < PREFERENCES_2_WIPE.length; i++) {
pm.remove(PREFERENCES_2_WIPE[i]);
}
答案 1 :(得分:3)
对我来说,这有用(希望它可以帮到你):
<extension
point="org.eclipse.ui.activities">
<activity
id="someid.remove"
name="RemoveSearchMenu">
<enabledWhen>
<with
variable="activePartId">
<equals
value="someidr.RemoveSearchMenu1">
</equals>
</with></enabledWhen>
</activity>
<activityPatternBinding
activityId="someid.remove"
pattern="org.eclipse.search.*">
</activityPatternBinding>