分享

(DM)如何隐藏Eclipse的菜单

 jinzq 2007-04-19
问题:
想达到的目标是:在不同的状态下,显示不同的菜单(例如,不同用户登陆显示不同的菜单)。

解决方法:
在WorkbenchWindowAdvisor的postWindowOpen()中添加如下代码 :

 public void postWindowOpen() {
       
        IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
                   configurer.getWindow().getActivePage().hideActionSet("gef.tutorial.stepii.actionSet1");//IworkbenchPage.hideActionset();
    }

IworkbenchPage.hideActionset(String actionSetID);这个方法有个参数是Actionset的ID,知道ID就可以隐藏了。

Actionset的ID :
   <extension
         point="org.eclipse.ui.actionSets">
      <actionSet
            id="gef.tutorial.stepii.actionSet1"       //  Actionset的ID
            label="gef.tutorial.stepii.actionSet1"
            visible="true">
         <action
               class="gef.tutorial.stepii.actions.ActionSetTest"
               id="gef.tutorial.stepii.action1"
               label="action1"
               menubarPath="gef.tutorial.stepii.menu1/aaa"
               style="push"
               toolbarPath="aaa"/>
         <menu
               id="gef.tutorial.stepii.menu1"
               label="menu1">
         </menu>
      </actionSet>
   </extension>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多