9910

单飞

   :: 首页 :: 联系 :: 聚合  :: 管理
发现有一些令人讨厌的菜单存在自己的RCP程序,我想到的是应该能拿到MenuManager类,然后遍历一下,去掉Search 菜单,可惜实在脑袋木了,就google了一下,找到解决的代码:
最近越来越懒了,自我批评一下: 平时不练功,关键的时候就只能靠Google这根救命草了。


http://www.richclient2.eu/2006_03_20/getting-rid-of-convert-line-delimiters-to/

Getting rid of “Convert Line Delimiters to”


20. March 2006
Tom Seidel @ 09:42

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:
  1. ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry();
  2. IActionSetDescriptor[] actionSets = reg.getActionSets();
  3. // removing annoying gotoLastPosition Message.
  4. String actionSetId = "org.eclipse.ui.edit.text.actionSet.navigation"; //$NON-NLS-1$
  5. for (int i = 0; i <actionSets.length; i++)
  6. {
  7.     if (!actionSets[i].getId().equals(actionSetId))
  8.         continue;
  9.         IExtension ext = actionSets[i].getConfigurationElement()
  10.             .getDeclaringExtension();
  11.         reg.removeExtension(ext, new Object[] { actionSets[i] });
  12. }
  13. // Removing convert line delimiters menu.
  14. actionSetId = "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo"; //$NON-NLS-1$
  15. for (int i = 0; i <actionSets.length; i++)
  16. {
  17.     if (!actionSets[i].getId().equals(actionSetId))
  18.         continue;
  19.     IExtension ext = actionSets[i].getConfigurationElement()
  20.             .getDeclaringExtension();
  21.    reg.removeExtension(ext, new Object[] { actionSets[i] });
  22. }
  • thanks Tom Seidel

    we tried it and , its working fine..great job

    thanks again

    Comment by biju — 29. September 2006 @ 09:09

  • Hi,

    thanks for this one - worked great. I enhanced it to get rid of “open file” as well and changed it so that walked only once through the loop. Takes about 15 millisec for three ids - so I think its quite fast :)

    And it seems to work in Eclipse 3.2 as well.

    Cheers,
    Christoph

    Comment by Christoph — 29. September 2006 @ 15:38

  • thanks.
    your tips really help me!
    finally I could remove “org.eclipse.ui.WorkingSetActionSet”

    Comment by aki — 9. April 2007 @ 16:12

  • This was very helpful thanks.

    I refactored it to avoid the duplication (DRY) as follows:

    private void removeExtraneousActions() {

    ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry();

    // removing gotoLastPosition message
    removeStandardAction(reg, “org.eclipse.ui.edit.text.actionSet.navigation”);

    // Removing “Convert Line Delimiters To” menu
    removeStandardAction(reg, “org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo”);
    }

    private void removeStandardAction(ActionSetRegistry reg, String actionSetId) {

    IActionSetDescriptor[] actionSets = reg.getActionSets();

    for (int i = 0; i

    Comment by Edward Garson — 23. April 2007 @ 15:37

  • Ah, there is some filtering going on.

    The implementationof “removeStandardAction” is like the original for loop.

    Have fun

    Comment by Edward Garson — 23. April 2007 @ 15:38

  • Great Job Thanks!!!

    Comment by GC — 9. July 2007 @ 17:18

  • Thanks a lot.

    Comment by Thanker — 28. December 2007 @ 21:08

  • Hi, i try to get rid of the”Open File” menu in the menubar which appeared with the “Convert Line Delimiters to”, how can i do this??
    I can’t fing the “actionSetId”

    Comment by cansen — 5. March 2008 @ 08:49

  • cool site man

    Comment by ben — 6. March 2008 @ 20:44

  • The actionsetid can be found in the plugin “org.eclipse.ui.ide” as extension at the “org.eclipse.ui.actionSets” extensionpoint. Its id is “org.eclipse.ui.actionSet.openFiles”

    Greets, Mike

     

  • posted on 2008-08-01 13:50 单飞 阅读(788) 评论(0)  编辑  收藏

    只有注册用户登录后才能发表评论。


    网站导航: