* @return the tool bar manager
*/
public IToolBarManager getToolBarManager() {
// by pass the sub coolBar and use the real cool bar.
ICoolBarManager coolBarManager = getCastedParent().getCoolBarManager();
if (coolBarManager == null) {
return null;
}
// add the editor group if the app did not add it already,
// otherwise the references to it below will fail
if (coolBarManager.find(IWorkbenchActionConstants.GROUP_EDITOR) == null) {
coolBarManager.add(new GroupMarker(
IWorkbenchActionConstants.GROUP_EDITOR));
}
if (toolBarContributionItem == null) {
IContributionItem foundItem = coolBarManager.find(type);
if ((foundItem instanceof IToolBarContributionItem)) {
toolBarContributionItem = (IToolBarContributionItem) foundItem;
coolItemToolBarMgr = toolBarContributionItem.getToolBarManager();
if (coolItemToolBarMgr == null) {
coolItemToolBarMgr = actionBarPresentation.createToolBarManager();
toolBarContributionItem = actionBarPresentation.createToolBarContributionItem(
coolItemToolBarMgr, type);
// Add editor item to group
coolBarManager.prependToGroup(
IWorkbenchActionConstants.GROUP_EDITOR,
toolBarContributionItem);
}
} else {
coolItemToolBarMgr = actionBarPresentation.createToolBarManager();
if ((coolBarManager instanceof ContributionManager)
&& (foundItem instanceof PlaceholderContributionItem)) {
PlaceholderContributionItem placeholder = (PlaceholderContributionItem) foundItem;
toolBarContributionItem = createToolBarContributionItem(coolItemToolBarMgr, placeholder);
// Restore from a placeholder
((ContributionManager) coolBarManager).replaceItem(type,
toolBarContributionItem);
} else {
toolBarContributionItem = actionBarPresentation.createToolBarContributionItem(
coolItemToolBarMgr, type);
// Add editor item to group
coolBarManager.prependToGroup(
IWorkbenchActionConstants.GROUP_EDITOR,
toolBarContributionItem);
}
}
((ContributionManager)coolItemToolBarMgr).setOverrides(new Overrides());