Search in sources :

Example 1 with MToolBarElement

use of org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement in project whole by wholeplatform.

the class E4ModelProcessor method createToolBar.

private MToolBar createToolBar() {
    MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar();
    toolBar.setElementId("toolbar:org.eclipse.ui.main.toolbar");
    List<MToolBarElement> toolItems = toolBar.getChildren();
    toolItems.add(createHandledToolItem("save", "Save", "org.eclipse.ui.file.save", "platform:/plugin/org.whole.product.e4.lw/icons/save_edit.png"));
    toolItems.add(createHandledToolItem("quit", "Quit", "org.eclipse.ui.file.exit"));
    toolItems.add(createHandledToolItem("revert", "Revert", "org.eclipse.ui.file.revert"));
    toolItems.add(createHandledToolItem("generateJava", "Generate Java", "org.whole.lang.e4.ui.command::generateJava"));
    return toolBar;
}
Also used : MToolBar(org.eclipse.e4.ui.model.application.ui.menu.MToolBar) MToolBarElement(org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement)

Example 2 with MToolBarElement

use of org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement in project aero.minova.rcp by minova-afis.

the class WFCDetailPart method createToolItemInPartToolbar.

private ButtonAccessor createToolItemInPartToolbar(aero.minova.rcp.form.model.xsd.Button btn) {
    // Kein Gruppenname: Element nur in Toolbar, kein Menü
    if (btn.getGroup() == null) {
        MHandledToolItem handledToolItem = eModelService.createModelElement(MHandledToolItem.class);
        fillMHandledItemWithValues(handledToolItem, btn);
        mPart.getToolbar().getChildren().add(handledToolItem);
        return new ButtonAccessor(handledToolItem);
    }
    // Menü für Gruppennamen finden
    MMenu groupMenu = null;
    if (btn.getGroup() != null) {
        for (MToolBarElement element : mPart.getToolbar().getChildren()) {
            if (btn.getGroup().equalsIgnoreCase(element.getPersistedState().get(Constants.GROUP_NAME))) {
                groupMenu = ((MHandledToolItem) element).getMenu();
                break;
            }
        }
    }
    MHandledToolItem handledToolItem = null;
    // Erstes Vorkommen des Gruppennamens: Element in Toolbar, Menü muss noch erstellt werden
    if (groupMenu == null) {
        handledToolItem = eModelService.createModelElement(MHandledToolItem.class);
        fillMHandledItemWithValues(handledToolItem, btn);
        mPart.getToolbar().getChildren().add(handledToolItem);
        groupMenu = eModelService.createModelElement(MMenu.class);
        handledToolItem.getPersistedState().put(Constants.GROUP_NAME, btn.getGroup());
        handledToolItem.setMenu(groupMenu);
    }
    // Wenn Gruppenname gegeben ist soll der Button immer auch in das Dropdown-Menü
    MHandledMenuItem menuEntry = eModelService.createModelElement(MHandledMenuItem.class);
    fillMHandledItemWithValues(menuEntry, btn);
    groupMenu.getChildren().add(menuEntry);
    return new ButtonAccessor(handledToolItem, menuEntry);
}
Also used : ButtonAccessor(aero.minova.rcp.rcp.accessor.ButtonAccessor) MHandledMenuItem(org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem) MToolBarElement(org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement) MHandledToolItem(org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem) MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu)

Example 3 with MToolBarElement

use of org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement in project aero.minova.rcp by minova-afis.

the class BlockHandler method init.

private void init(MPart part) {
    this.mPart = part;
    this.detail = (WFCDetailPart) part.getObject();
    this.keyLong = detail.getDetail().getField("KeyLong");
    this.blocked = detail.getDetail().getField("Blocked");
    blocked.addValueChangeListener(this);
    // Knopf finden
    for (MToolBarElement item : mPart.getToolbar().getChildren()) {
        if (item.getElementId().equals("aero.minova.rcp.rcp.handledtoolitem.block")) {
            blockedToolItem = (HandledToolItemImpl) item;
        }
    }
    firstCall = false;
}
Also used : MToolBarElement(org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement)

Example 4 with MToolBarElement

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

the class ContributionsAnalyzer method processAddition.

public static boolean processAddition(final MToolBar toolBarModel, MToolBarContribution toolBarContribution, List<MToolBarElement> contributions, HashSet<String> existingSeparatorNames) {
    int idx = getIndex(toolBarModel, toolBarContribution.getPositionInParent());
    if (idx == -1) {
        return false;
    }
    for (MToolBarElement item : toolBarContribution.getChildren()) {
        if (item instanceof MToolBarSeparator && existingSeparatorNames.contains(item.getElementId())) {
            // skip this, it's already there
            continue;
        }
        MToolBarElement copy = (MToolBarElement) EcoreUtil.copy((EObject) item);
        if (DEBUG) {
            // $NON-NLS-1$
            trace("addToolBarContribution " + copy, toolBarModel.getWidget(), toolBarModel);
        }
        toolBarModel.getChildren().add(idx++, copy);
        contributions.add(copy);
        if (copy instanceof MToolBarSeparator && copy.getElementId() != null) {
            existingSeparatorNames.add(copy.getElementId());
        }
    }
    return true;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) MToolBarElement(org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement) MToolBarSeparator(org.eclipse.e4.ui.model.application.ui.menu.MToolBarSeparator)

Example 5 with MToolBarElement

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

the class ToolBarContributionRecord method computeVisibility.

public boolean computeVisibility(HashSet<ToolBarContributionRecord> recentlyUpdated, MToolBarElement item, ExpressionContext exprContext) {
    boolean currentVisibility = isVisible;
    if (item instanceof MToolBarSeparator) {
        ArrayList<ToolBarContributionRecord> list = renderer.getList(item);
        if (list != null) {
            Iterator<ToolBarContributionRecord> cr = list.iterator();
            while (!currentVisibility && cr.hasNext()) {
                ToolBarContributionRecord rec = cr.next();
                if (!recentlyUpdated.contains(rec)) {
                    rec.updateIsVisible(exprContext);
                    recentlyUpdated.add(rec);
                }
                currentVisibility |= rec.isVisible;
            }
        }
    }
    if (currentVisibility && item.getPersistedState().get(MenuManagerRenderer.VISIBILITY_IDENTIFIER) != null) {
        String identifier = item.getPersistedState().get(MenuManagerRenderer.VISIBILITY_IDENTIFIER);
        Object rc = exprContext.eclipseContext.get(identifier);
        if (rc instanceof Boolean) {
            currentVisibility = ((Boolean) rc).booleanValue();
        }
    }
    if (currentVisibility && item.getVisibleWhen() != null) {
        boolean val = ContributionsAnalyzer.isVisible(item.getVisibleWhen(), exprContext);
        currentVisibility = val;
    }
    return currentVisibility;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) MToolBarSeparator(org.eclipse.e4.ui.model.application.ui.menu.MToolBarSeparator)

Aggregations

MToolBarElement (org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement)28 IContributionItem (org.eclipse.jface.action.IContributionItem)15 IToolBarManager (org.eclipse.jface.action.IToolBarManager)9 ToolBarManager (org.eclipse.jface.action.ToolBarManager)9 MToolBar (org.eclipse.e4.ui.model.application.ui.menu.MToolBar)8 Inject (javax.inject.Inject)7 Optional (org.eclipse.e4.core.di.annotations.Optional)7 MHandledToolItem (org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem)7 MToolBarSeparator (org.eclipse.e4.ui.model.application.ui.menu.MToolBarSeparator)6 EObject (org.eclipse.emf.ecore.EObject)6 ArrayList (java.util.ArrayList)4 MApplication (org.eclipse.e4.ui.model.application.MApplication)4 MToolItem (org.eclipse.e4.ui.model.application.ui.menu.MToolItem)4 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)3 MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)3 MToolControl (org.eclipse.e4.ui.model.application.ui.menu.MToolControl)3 IToolBarContributionItem (org.eclipse.jface.internal.provisional.action.IToolBarContributionItem)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2