String groupName = menuPath.substring(
menuPath.lastIndexOf("/") + 1, menuPath.length()); //$NON-NLS-1$
if( groupName.equals( Constants.M_TOOL)){
groupName = "map";
}
IMenuManager targetMenu = manager.findMenuUsingPath(root);
if (targetMenu != null) {
IContributionItem find = targetMenu.find(groupName);
if ( find!=null && find instanceof GroupMarker ){
//targetMenu.appendToGroup(groupName, action); //$NON-NLS-1$
targetMenu.appendToGroup(groupName, tool.getAction());
targetMenu.setVisible(true);
}else{
targetMenu.add(action);
targetMenu.setVisible(true);
}
} else
actionMenu.appendToGroup(actionExt, tool.getAction()); //$NON-NLS-1$
} else {
actionMenu.appendToGroup(actionExt, tool.getAction()); //$NON-NLS-1$
}
}
if (tool.getType() == ToolProxy.MODAL) {
MenuCurrentToolItem menuItem = new MenuCurrentToolItem(tool);
tool.addContribution(menuItem);
actionMenu.appendToGroup("modal.ext", menuItem); //$NON-NLS-1$
}
}
if (actionMenu.getItems().length > 0) {
// Handle left over tools! Place them in the map menu?
String menuPath = "map"; // was Constants.M_TOOL
IMenuManager toolManager = manager.findMenuUsingPath( menuPath );
if( toolManager==null ){
toolManager=new MenuManager(Messages.MenuToolCategory_menu_manager_title,"tools"); //$NON-NLS-1$
manager.add(toolManager);
toolManager.add(new GroupMarker(actionExt)); //$NON-NLS-1$
toolManager.add(new GroupMarker("modal.ext")); //$NON-NLS-1$
}
if( toolManager.find(actionExt)==null ){
toolManager.add(new GroupMarker(actionExt)); //$NON-NLS-1$
}
toolManager.appendToGroup(actionExt, actionMenu); //$NON-NLS-1$
toolManager.setVisible(true);
}
}