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)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 江孜县| 策勒县| 云南省| 青海省| 梁平县| 台中县| 当涂县| 年辖:市辖区| 漳州市| 罗田县| 许昌县| 贵溪市| 彩票| 保亭| 柯坪县| 汝州市| 商丘市| 蓬莱市| 饶河县| 饶阳县| 越西县| 永康市| 青龙| 淮北市| 大姚县| 天台县| 离岛区| 嘉定区| 新丰县| 宜川县| 乌兰察布市| 台东市| 兴和县| 德清县| 龙州县| 邵阳市| 大竹县| 凌云县| 和静县| 东乡族自治县| 黄龙县|