List of usage examples for org.eclipse.jface.action SubContributionManager getParent
public IContributionManager getParent()
From source file:org.apache.sling.ide.eclipse.ui.dnd.assistant.StatusLineUtils.java
License:Apache License
private static void doSetErrorMessage(final String message) { final IStatusLineManager statusLineManager = getStatusLineManager(); if (statusLineManager != null) { Display.getDefault().syncExec(new Runnable() { @Override// w w w . j ava2 s. c om public void run() { if (statusLineManager instanceof SubContributionManager) { SubContributionManager sub = (SubContributionManager) statusLineManager; StatusLineManager parent = (StatusLineManager) sub.getParent(); parent.setErrorMessage(message); parent.update(true); } else { statusLineManager.setErrorMessage(message); statusLineManager.update(true); } } }); } }
From source file:org.eclipse.ui.internal.EditorActionBars.java
License:Open Source License
/** * Dispose the contributions.// ww w .ja v a 2 s .c o m */ public void dispose() { super.dispose(); if (editorContributor != null) { editorContributor.dispose(); } if (extensionContributor != null) { extensionContributor.dispose(); } /* * Dispose of the contribution item, but also make sure that no one else * is holding on to it. In this case, go through the SubCoolBarManager * to its parent (the real CoolBarManager), and replace the reference * with a placeholder. */ if (toolBarContributionItem != null) { // Create a placeholder and place it in the cool bar manager. ICoolBarManager coolBarManager = getCoolBarManager(); if (coolBarManager instanceof SubContributionManager) { SubContributionManager subManager = (SubContributionManager) coolBarManager; IContributionManager manager = subManager.getParent(); if (manager instanceof CoolBarToTrimManager) { CoolBarToTrimManager trimManager = (CoolBarToTrimManager) manager; trimManager.remove(toolBarContributionItem); } else if (manager instanceof ContributionManager) { final IContributionItem replacementItem = new PlaceholderContributionItem( toolBarContributionItem); boolean succeeded = ((ContributionManager) manager).replaceItem(replacementItem.getId(), replacementItem); if (!succeeded && DEBUG_TOOLBAR_DISPOSAL) { System.out.println("FAILURE WHILE DISPOSING EditorActionBars"); //$NON-NLS-1$ System.out.println( "Could not replace " + replacementItem.getId() + " in the contribution manager."); //$NON-NLS-1$ //$NON-NLS-2$ } } else if (DEBUG_TOOLBAR_DISPOSAL) { System.out.println("FAILURE WHILE DISPOSING EditorActionBars"); //$NON-NLS-1$ System.out.println("The manager was not a ContributionManager."); //$NON-NLS-1$ System.out.println("It was a " + manager.getClass().getName()); //$NON-NLS-1$ } } else if (DEBUG_TOOLBAR_DISPOSAL) { System.out.println("FAILURE WHILE DISPOSING EditorActionBars"); //$NON-NLS-1$ System.out.println("The coolBarManager was not a SubContributionManager"); //$NON-NLS-1$ System.out.println("It was a " + coolBarManager.getClass().getName()); //$NON-NLS-1$ } // Dispose of the replaced item. toolBarContributionItem.dispose(); } toolBarContributionItem = null; // Remove actions if (coolItemToolBarMgr != null) { coolItemToolBarMgr.removeAll(); } coolItemToolBarMgr = null; editorHandlerExpression = null; }