Search in sources :

Example 1 with ToolBarManager2

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;
}
Also used : ToolBarManager2(org.eclipse.jface.internal.provisional.action.ToolBarManager2) ToolBarContributionItem2(org.eclipse.jface.internal.provisional.action.ToolBarContributionItem2) IContributionItem(org.eclipse.jface.action.IContributionItem) ContributionManager(org.eclipse.jface.action.ContributionManager) SubContributionManager(org.eclipse.jface.action.SubContributionManager) IContributionManager(org.eclipse.jface.action.IContributionManager) IContributionManagerOverrides(org.eclipse.jface.action.IContributionManagerOverrides) GroupMarker(org.eclipse.jface.action.GroupMarker) IToolBarContributionItem(org.eclipse.jface.internal.provisional.action.IToolBarContributionItem) ICoolBarManager(org.eclipse.jface.action.ICoolBarManager)

Aggregations

ContributionManager (org.eclipse.jface.action.ContributionManager)1 GroupMarker (org.eclipse.jface.action.GroupMarker)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1 IContributionManager (org.eclipse.jface.action.IContributionManager)1 IContributionManagerOverrides (org.eclipse.jface.action.IContributionManagerOverrides)1 ICoolBarManager (org.eclipse.jface.action.ICoolBarManager)1 SubContributionManager (org.eclipse.jface.action.SubContributionManager)1 IToolBarContributionItem (org.eclipse.jface.internal.provisional.action.IToolBarContributionItem)1 ToolBarContributionItem2 (org.eclipse.jface.internal.provisional.action.ToolBarContributionItem2)1 ToolBarManager2 (org.eclipse.jface.internal.provisional.action.ToolBarManager2)1