Disable plugin contributions in Eclipse RCP Application

a 夏天 提交于 2019-12-05 00:09:51

问题


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.

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?


回答1:


Take a look at the Eclipse "Activities" API. It allows you to hide contributions based on ID.

A few links:

  • http://wiki.eclipse.org/FAQ_How_do_I_add_activities_to_my_plug-in%3F
  • http://www.vogella.de/blog/2009/07/13/eclipse-activities/
  • http://random-eclipse-tips.blogspot.com/2009/02/eclipse-rcp-removing-unwanted_02.html
  • http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/workbench_scalability.htm



回答2:


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.

You can see an example of removing a contribution in this org.eclipse.ui.tests.menus.MenuBuilder class;

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;
}



回答3:


Equinox transformations can also be used to supply XLST transformations that remove unwanted UI contributions.



来源:https://stackoverflow.com/questions/1415700/disable-plugin-contributions-in-eclipse-rcp-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!