Search in sources :

Example 1 with MToolBar

use of org.eclipse.e4.ui.model.application.ui.menu.MToolBar 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 MToolBar

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

the class IconRendering method subscribeTopicChildrenChanged.

@Inject
@Optional
void subscribeTopicChildrenChanged(@UIEventTopic(UIEvents.ElementContainer.TOPIC_CHILDREN) Event event) {
    Object objElement = event.getProperty(UIEvents.EventTags.ELEMENT);
    // only care of added elements
    if (!UIEvents.isADD(event)) {
        return;
    }
    // Ensure that this event is for a MMenuItem or MToolBar
    if (!(objElement instanceof MMenuElement && !(objElement instanceof MPopupMenu)) && !(objElement instanceof MToolBar)) {
        return;
    }
    // Ensure that it's a View part's menu or toolbar
    MUIElement uiElement = (MUIElement) objElement;
    MUIElement parent = modelService.getContainer(uiElement);
    if (!(parent instanceof MPart)) {
        return;
    }
    MPart part = (MPart) parent;
    ImageUtil.updateIconsForPart(part);
    if (uiElement instanceof MToolBar) {
        MToolBar toolbar = (MToolBar) uiElement;
        ImageUtil.updateIconsForToolbarItems(toolbar);
    }
}
Also used : MToolBar(org.eclipse.e4.ui.model.application.ui.menu.MToolBar) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MPopupMenu(org.eclipse.e4.ui.model.application.ui.menu.MPopupMenu) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) MMenuElement(org.eclipse.e4.ui.model.application.ui.menu.MMenuElement) Inject(javax.inject.Inject) Optional(org.eclipse.e4.core.di.annotations.Optional)

Example 3 with MToolBar

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

the class PartImpl method basicSetToolbar.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetToolbar(MToolBar newToolbar, NotificationChain msgs) {
    MToolBar oldToolbar = toolbar;
    toolbar = newToolbar;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, BasicPackageImpl.PART__TOOLBAR, oldToolbar, newToolbar);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : MToolBar(org.eclipse.e4.ui.model.application.ui.menu.MToolBar) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 4 with MToolBar

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

the class ProgrammaticProgressView method createViewMenu.

private void createViewMenu() {
    MHandledToolItem clearAllButton = modelService.createModelElement(MHandledToolItem.class);
    clearAllButton.setIconURI(CLEAR_ALL_ICON_URI);
    clearAllButton.setCommand(clearAllCommand);
    MToolBar toolBar = modelService.createModelElement(MToolBar.class);
    toolBar.getChildren().add(clearAllButton);
    part.setToolbar(toolBar);
    MHandledMenuItem clearAllMenuItem = modelService.createModelElement(MHandledMenuItem.class);
    // $NON-NLS-1$
    clearAllMenuItem.setLabel("Clear All");
    clearAllMenuItem.setIconURI(CLEAR_ALL_ICON_URI);
    clearAllMenuItem.setCommand(clearAllCommand);
    MHandledMenuItem preferencesMenuItem = modelService.createModelElement(MHandledMenuItem.class);
    // $NON-NLS-1$
    preferencesMenuItem.setLabel("Preferences");
    preferencesMenuItem.setCommand(showPreferencesCommand);
    MMenu menu = modelService.createModelElement(MMenu.class);
    // required //$NON-NLS-1$
    menu.getTags().add("ViewMenu");
    menu.getChildren().add(clearAllMenuItem);
    menu.getChildren().add(preferencesMenuItem);
    part.getMenus().add(menu);
}
Also used : MToolBar(org.eclipse.e4.ui.model.application.ui.menu.MToolBar) MHandledMenuItem(org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem) MHandledToolItem(org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem) MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu)

Example 5 with MToolBar

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

the class PartDescriptorImpl method basicSetToolbar.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetToolbar(MToolBar newToolbar, NotificationChain msgs) {
    MToolBar oldToolbar = toolbar;
    toolbar = newToolbar;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, BasicPackageImpl.PART_DESCRIPTOR__TOOLBAR, oldToolbar, newToolbar);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : MToolBar(org.eclipse.e4.ui.model.application.ui.menu.MToolBar) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

MToolBar (org.eclipse.e4.ui.model.application.ui.menu.MToolBar)71 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)24 ToolBarManager (org.eclipse.jface.action.ToolBarManager)21 MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)20 MTrimBar (org.eclipse.e4.ui.model.application.ui.basic.MTrimBar)17 MWindow (org.eclipse.e4.ui.model.application.ui.basic.MWindow)16 IToolBarManager (org.eclipse.jface.action.IToolBarManager)16 MToolBarElement (org.eclipse.e4.ui.model.application.ui.menu.MToolBarElement)15 Test (org.junit.Test)15 ToolBarManagerRenderer (org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer)13 IContributionItem (org.eclipse.jface.action.IContributionItem)13 Control (org.eclipse.swt.widgets.Control)12 Composite (org.eclipse.swt.widgets.Composite)11 Inject (javax.inject.Inject)10 Optional (org.eclipse.e4.core.di.annotations.Optional)10 MPlaceholder (org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder)10 ArrayList (java.util.ArrayList)9 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)9 AbstractPartRenderer (org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer)9 MElementContainer (org.eclipse.e4.ui.model.application.ui.MElementContainer)9