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. }
        1. thanks Tom Seidel

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

          thanks again

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

        2. 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

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

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

        4. 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

        5. 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

        6. Great Job Thanks!!!

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

        7. Thanks a lot.

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

        8. 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

        9. cool site man

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

        10. 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

           

        11. posted on 2008-08-01 13:50 單飛 閱讀(791) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 囊谦县| 中江县| 宁晋县| 讷河市| 乐平市| 昌吉市| 阿拉善右旗| 买车| 锡林郭勒盟| 邹平县| 中西区| 清丰县| 云梦县| 乌拉特中旗| 堆龙德庆县| 英吉沙县| 扎囊县| 长宁县| 贡嘎县| 焉耆| 古浪县| 宜君县| 江安县| 清河县| 博爱县| 驻马店市| 乃东县| 凯里市| 清镇市| 双鸭山市| 宿松县| 柘荣县| 六安市| 房产| 兴宁市| 子洲县| 陇川县| 邓州市| 清徐县| 涟水县| 右玉县|