简体   繁体   English

在 Eclipse RCP 应用程序中禁用插件贡献

[英]Disable plugin contributions in Eclipse RCP Application

I frequently had this problem and didn't find a solution yet: Whenever I write a new Eclipse RCP based application and include plugins from the Eclipse platform, I 'inherit' UI contributions from some of those plugins.我经常遇到这个问题并且还没有找到解决方案:每当我编写一个新的基于 Eclipse RCP 的应用程序并包含来自 Eclipse 平台的插件时,我“继承”了其中一些插件的 UI 贡献。

Most of this contributions (menu entries, keyboard shortcuts, property pages) are useful but sometimes I'd rather disabled some of these contributions, just because I really do not need them and they might confuse the users.大多数这些贡献(菜单项、键盘快捷键、属性页)很有用,但有时我宁愿禁用其中的一些贡献,只是因为我真的不需要它们,它们可能会使用户感到困惑。

Does anyone know of the official or a practical way to disable/prohibit selected contributions in Eclipse RCP applications?有没有人知道在 Eclipse RCP 应用程序中禁用/禁止选定贡献的官方或实用方法?

The only method which comes close to do that would be:接近做到这一点的唯一方法是:

IMenuService::removeContributionFactory()

Paul Webster has been calling for a IMenuService::addOverride() to change the visibility of the menu, preventing any contribution, but that idea has not been integrated yet. Paul Webster 一直在呼吁IMenuService::addOverride()来改变菜单的可见性,防止任何贡献,但这个想法还没有被整合。

You can see an example of removing a contribution in this org.eclipse.ui.tests.menus.MenuBuilder class;你可以在这个org.eclipse.ui.tests.menus.MenuBuilder类中看到一个移除贡献的例子;

public static void removeMenuContribution() {
    if (!PlatformUI.isWorkbenchRunning()) {
        return;
    }
    IMenuService menuService = (IMenuService) PlatformUI.getWorkbench()
            .getService(IMenuService.class);
    if (menuService==null) {
        return;
    }
    menuService.removeContributionFactory(viewMenuAddition);
    viewMenuAddition = null;
    menuService.removeContributionFactory(viewToolbarAddition);
    viewMenuAddition = null;
}

Equinox 转换还可用于提供 XLST 转换,以消除不需要的 UI 贡献。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM