(DM)如何隐藏Eclipse的菜单

来源:百度文库 编辑:神马文学网 时间:2024/05/01 19:35:40
问题:
想达到的目标是:在不同的状态下,显示不同的菜单(例如,不同用户登陆显示不同的菜单)。
解决方法:
在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 :
point="org.eclipse.ui.actionSets">
id="gef.tutorial.stepii.actionSet1"       //  Actionset的ID
label="gef.tutorial.stepii.actionSet1"
visible="true">
class="gef.tutorial.stepii.actions.ActionSetTest"
id="gef.tutorial.stepii.action1"
label="action1"
menubarPath="gef.tutorial.stepii.menu1/aaa"
style="push"
toolbarPath="aaa"/>
id="gef.tutorial.stepii.menu1"
label="menu1">