* <li>navigate: forward and backward buttons
* <li>map: an entry for each tool category
* </ul>
*/
public void contributeToMenu( IMenuManager manager ) {
IMenuManager navigateMenu = manager.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
if (navigateMenu == null) {
// I would like to arrange for the Navigate menu to already
// be in place before the ToolManager is kicked into action
// (this is part of the missions to have uDig plugins walk
// softly when being hosted in other RCP applications)
// See UDIGActionBarAdvisor for hosting requirements.
navigateMenu = new MenuManager(
Messages.ToolManager_menu_manager_title, IWorkbenchActionConstants.M_NAVIGATE);
IContributionItem additions = manager.find(IWorkbenchActionConstants.MB_ADDITIONS);
if( additions==null || !(additions instanceof GroupMarker) ){
manager.add(navigateMenu);
}else{
manager.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, navigateMenu);
}
navigateMenu.add(new GroupMarker(IWorkbenchActionConstants.NAV_START));
navigateMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
navigateMenu.add(new GroupMarker(IWorkbenchActionConstants.NAV_END));
}
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
// we are using the global BACK and FORWARD actions here
// and will register "handlers" for these commands
navigateMenu.appendToGroup(IWorkbenchActionConstants.NAV_END,
ActionFactory.BACK.create(window));
navigateMenu.appendToGroup(IWorkbenchActionConstants.NAV_END,
ActionFactory.FORWARD.create(window));
if (!manager.isVisible()){
// since this is the top level menu bar why would it not be visible?
manager.setVisible(true);
}
IMenuManager mapMenu = manager.findMenuUsingPath("map");
if( mapMenu == null ){
// Once again the hosting RCP application should of provided
// us with a Map menu; but let's be careful and make our own here
// if needed.
// See UDIGActionBarAdvisor for hosting requirements.
mapMenu = new MenuManager(Messages.ToolManager_menu_manager_title, "map");
manager.add(mapMenu);
mapMenu.add(new GroupMarker("mapStart"));
mapMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
mapMenu.add(new GroupMarker("mapEnd"));
}
// churn through each category and add stuff as needed
// note we check with the cmdService to see what we if the actionSet
// associated with this cateogry is turned on by the
// current perspective.