9910

          單飛

             :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
          發(fā)現(xiàn)有一些令人討厭的菜單存在自己的RCP程序,我想到的是應(yīng)該能拿到MenuManager類(lèi),然后遍歷一下,去掉Search 菜單,可惜實(shí)在腦袋木了,就google了一下,找到解決的代碼:
          最近越來(lái)越懶了,自我批評(píng)一下: 平時(shí)不練功,關(guān)鍵的時(shí)候就只能靠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 單飛 閱讀(794) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 包头市| 宿松县| 庄浪县| 融水| 巴青县| 平泉县| 留坝县| 彭泽县| 旬邑县| 曲阳县| 射阳县| 肇东市| 宿松县| 天等县| 澄迈县| 昌乐县| 文山县| 资中县| 会东县| 靖西县| 米林县| 伊宁县| 喀什市| 漾濞| 揭阳市| 永春县| 永昌县| 曲阳县| 瓮安县| 黄梅县| 安达市| 沙坪坝区| 鸡东县| 吉木萨尔县| 依安县| 双流县| 广西| 桐城市| 增城市| 泾川县| 金平|