Search in sources :

Example 1 with MDirectMenuItem

use of org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem in project ibex_gui by ISISComputingGroup.

the class EditConfigurationsHandler method aboutToShow.

/**
 * Generate the menu item as the menu is about to be shown.
 *
 * It must be dynamic because the menu has a different label depending on
 * the state of the config pv.
 *
 * @param items
 *            menu items to add to
 */
@AboutToShow
public void aboutToShow(List<MMenuElement> items) {
    String menuText;
    String tooltipText;
    if (canWrite) {
        menuText = EDIT_MENU_TEXT;
        tooltipText = editTooltip;
    } else {
        menuText = READ_ONLY_TEXT;
        tooltipText = viewTooltip;
    }
    MDirectMenuItem dynamicItem = MMenuFactory.INSTANCE.createDirectMenuItem();
    dynamicItem.setLabel(menuText);
    dynamicItem.setTooltip(tooltipText);
    dynamicItem.setMnemonics(MENU_MNEMONIC);
    // Plugin in which this menu item exists
    dynamicItem.setContributorURI(BundleConstants.getPlatformPlugin());
    dynamicItem.setContributionURI(BundleConstants.getClassURI(getClass()));
    items.add(dynamicItem);
}
Also used : MDirectMenuItem(org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem) AboutToShow(org.eclipse.e4.ui.di.AboutToShow)

Example 2 with MDirectMenuItem

use of org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem in project portfolio by buchen.

the class NewTransactionMenuContribution method create.

private MMenuElement create(PortfolioPart part, Class<? extends AbstractTransactionDialog> dialog, Object parameter) {
    MDirectMenuItem menuItem = modelService.createModelElement(MDirectMenuItem.class);
    // $NON-NLS-1$
    menuItem.setLabel(parameter.toString() + "...");
    // $NON-NLS-1$
    menuItem.setContributorURI("platform:/plugin/" + PortfolioPlugin.PLUGIN_ID);
    menuItem.setContributionURI(// $NON-NLS-1$//$NON-NLS-2$
    "bundleclass://" + PortfolioPlugin.PLUGIN_ID + "/" + NewTransactionHandler.class.getName());
    menuItem.getTransientData().put(PortfolioPart.class.getName(), part);
    menuItem.getTransientData().put(AbstractTransactionDialog.class.getName(), dialog);
    menuItem.getTransientData().put(UIConstants.Parameter.NAME, parameter);
    return menuItem;
}
Also used : AbstractTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AbstractTransactionDialog) PortfolioPart(name.abuchen.portfolio.ui.editor.PortfolioPart) MDirectMenuItem(org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem)

Example 3 with MDirectMenuItem

use of org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem in project portfolio by buchen.

the class SelectReportingCurrencyMenuContribution method createMenu.

private MMenuElement createMenu(CurrencyUnit currency, PortfolioPart part) {
    MDirectMenuItem menuItem = modelService.createModelElement(MDirectMenuItem.class);
    menuItem.setLabel(currency.getLabel());
    menuItem.setType(ItemType.CHECK);
    // $NON-NLS-1$
    menuItem.setContributorURI("platform:/plugin/" + PortfolioPlugin.PLUGIN_ID);
    menuItem.setContributionURI(// $NON-NLS-1$//$NON-NLS-2$
    "bundleclass://" + PortfolioPlugin.PLUGIN_ID + "/" + SelectReportingCurrencyHandler.class.getName());
    menuItem.getTransientData().put(CurrencyUnit.class.getName(), currency);
    menuItem.getTransientData().put(PortfolioPart.class.getName(), part);
    return menuItem;
}
Also used : CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) PortfolioPart(name.abuchen.portfolio.ui.editor.PortfolioPart) MDirectMenuItem(org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem)

Example 4 with MDirectMenuItem

use of org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem in project osgifx by amitjoy.

the class EventReceiveMenuContributionHandler method prepareMenu.

private void prepareMenu(final List<MMenuElement> items, final boolean value) {
    final MDirectMenuItem eventActionMenu;
    if (value) {
        eventActionMenu = createEventActionMenu(Type.STOP);
    } else {
        eventActionMenu = createEventActionMenu(Type.START);
    }
    items.add(eventActionMenu);
}
Also used : MDirectMenuItem(org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem)

Example 5 with MDirectMenuItem

use of org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem in project eclipse.platform.ui by eclipse-platform.

the class RenderedElementUtil method createRenderedMenuItem.

/**
 * Create a 'rendered' menu item instance
 *
 * @return the new instance
 */
public static MMenuItem createRenderedMenuItem() {
    final MDirectMenuItem object = MMenuFactory.INSTANCE.createDirectMenuItem();
    object.getTags().add(RENDERED_TAG);
    return object;
}
Also used : MDirectMenuItem(org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem)

Aggregations

MDirectMenuItem (org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem)16 MMenu (org.eclipse.e4.ui.model.application.ui.menu.MMenu)6 MHandledMenuItem (org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem)5 PortfolioPart (name.abuchen.portfolio.ui.editor.PortfolioPart)3 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)3 AboutToShow (org.eclipse.e4.ui.di.AboutToShow)3 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)3 MPartStack (org.eclipse.e4.ui.model.application.ui.basic.MPartStack)3 MWindow (org.eclipse.e4.ui.model.application.ui.basic.MWindow)3 IContributionItem (org.eclipse.jface.action.IContributionItem)3 Test (org.junit.Test)3 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)2 EHandlerService (org.eclipse.e4.core.commands.EHandlerService)2 IContributionFactory (org.eclipse.e4.core.services.contributions.IContributionFactory)2 MDynamicMenuContribution (org.eclipse.e4.ui.model.application.ui.menu.MDynamicMenuContribution)2 MMenuItem (org.eclipse.e4.ui.model.application.ui.menu.MMenuItem)2 MToolBar (org.eclipse.e4.ui.model.application.ui.menu.MToolBar)2 MToolControl (org.eclipse.e4.ui.model.application.ui.menu.MToolControl)2 EPartService (org.eclipse.e4.ui.workbench.modeling.EPartService)2 MenuManager (org.eclipse.jface.action.MenuManager)2