Search in sources :

Example 1 with ContributionManager

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));
}
Also used : IMenuService(org.eclipse.ui.menus.IMenuService) IContributionManager(org.eclipse.jface.action.IContributionManager) ContributionManager(org.eclipse.jface.action.ContributionManager)

Example 2 with 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);
    }
}
Also used : IMenuService(org.eclipse.ui.menus.IMenuService) ContributionManager(org.eclipse.jface.action.ContributionManager)

Example 3 with ContributionManager

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);
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) IMenuService(org.eclipse.ui.menus.IMenuService) IContributionManager(org.eclipse.jface.action.IContributionManager) ContributionManager(org.eclipse.jface.action.ContributionManager) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Aggregations

ContributionManager (org.eclipse.jface.action.ContributionManager)3 IMenuService (org.eclipse.ui.menus.IMenuService)3 IContributionManager (org.eclipse.jface.action.IContributionManager)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1