use of org.eclipse.jface.internal.provisional.action.ToolBarManager2 in project eclipse.platform.ui by eclipse-platform.
the class EditorActionBars method getToolBarManager.
/**
* Returns the tool bar manager. If items are added or removed from the manager
* be sure to call <code>updateActionBars</code>. Overridden to support
* CoolBars.
*
* @return the tool bar manager
*/
@Override
public IToolBarManager getToolBarManager() {
// by pass the sub coolBar and use the real cool bar.
ICoolBarManager coolBarManager = getCastedParent().getCoolBarManager();
if (coolBarManager == null) {
return null;
}
// 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 = new ToolBarManager2(SWT.FLAT);
toolBarContributionItem = new ToolBarContributionItem2(coolItemToolBarMgr, type);
// Add editor item to group
coolBarManager.prependToGroup(IWorkbenchActionConstants.GROUP_EDITOR, toolBarContributionItem);
}
} else {
coolItemToolBarMgr = new ToolBarManager2(SWT.FLAT);
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 = new ToolBarContributionItem2(coolItemToolBarMgr, type);
// Add editor item to group
coolBarManager.prependToGroup(IWorkbenchActionConstants.GROUP_EDITOR, toolBarContributionItem);
}
}
((ContributionManager) coolItemToolBarMgr).setOverrides(new Overrides());
toolBarContributionItem.setVisible(getActive());
coolItemToolBarMgr.markDirty();
}
return coolItemToolBarMgr;
}
Aggregations