use of org.eclipse.jface.action.ContributionManager in project linuxtools by eclipse.
the class UIUtils method registerContributionManager.
/**
* Register the given ContributionManager with the given id. The
* contribution manager gets unregistered on control disposal.
*
* @param id
* the id
* @param contributionManager
* the contribution manager
* @param control
* the control
*
* @see ContributionManager
* @see IMenuService
* @see DisposeListener
*/
public static void registerContributionManager(final String id, final IContributionManager contributionManager, final Control control) {
Assert.isNotNull(id);
Assert.isNotNull(contributionManager);
Assert.isTrue(control != null && !control.isDisposed());
final IMenuService menuService = PlatformUI.getWorkbench().getService(IMenuService.class);
menuService.populateContributionManager((ContributionManager) contributionManager, id);
contributionManager.update(true);
control.addDisposeListener(e -> menuService.releaseContributions((ContributionManager) contributionManager));
}
use of org.eclipse.jface.action.ContributionManager in project egit by eclipse.
the class CommitEditor method addContributions.
private void addContributions(IToolBarManager toolBarManager) {
IMenuService menuService = CommonUtils.getService(getSite(), IMenuService.class);
if (menuService != null && toolBarManager instanceof ContributionManager) {
ContributionManager contributionManager = (ContributionManager) toolBarManager;
// $NON-NLS-1$
String toolbarUri = "toolbar:" + TOOLBAR_HEADER_ID;
menuService.populateContributionManager(contributionManager, toolbarUri);
}
}
use of org.eclipse.jface.action.ContributionManager in project jbosstools-openshift by jbosstools.
the class UIUtils method registerContributionManager.
/**
* Register a {@link ContributionManager}. The contribution manager gets
* unregistered on control disposal
*
* @param id
* the id
* @param contributionManager
* the contribution manager
* @param control
* the control
*
* @see ContributionManager
* @see IMenuService
* @see DisposeListener
*/
public static void registerContributionManager(final String id, final IContributionManager contributionManager, final Control control) {
Assert.isNotNull(id);
Assert.isNotNull(contributionManager);
Assert.isTrue(control != null && !control.isDisposed());
final IMenuService menuService = (IMenuService) PlatformUI.getWorkbench().getService(IMenuService.class);
menuService.populateContributionManager((ContributionManager) contributionManager, id);
contributionManager.update(true);
control.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
menuService.releaseContributions((ContributionManager) contributionManager);
}
});
}
Aggregations