2012-07-18 67 views

回答

2

嘗試使用在你的ApplicationActionBarAdvisor類的編程解決方案如下:

public class ApplicationActionBarAdvisor extends ActionBarAdvisor { 

    private IWorkbenchAction resetPerspectiveAction; 

    @Override 
    protected void makeActions(IWorkbenchWindow window) { 
     // ... 
     // create and register the actions 
     resetPerspectiveAction = ActionFactory.RESET_PERSPECTIVE.create(window); 
     register(resetPerspectiveAction); 
     // ... 
    } 

    @Override 
    protected void fillMenuBar(IMenuManager menuBar) { 
     // ... 
     // create and fill the window menu 
     MenuManager windowMenu = new MenuManager("&Window", WorkbenchActionConstants.M_WINDOW); 
     menuBar.add(windowMenu); 
     windowMenu.add(resetPerspectiveAction); 
     // ... 
    } 
} 
+0

謝謝大家的響應,Kelibiano。因爲我已經通過plugin.xml添加了菜單,所以您在makeActions()函數中提供的代碼就足夠了。謝謝! – user1056027 2012-07-20 03:20:51

相關問題