Search in sources :

Example 1 with MMenu

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

the class E4ModelProcessor method createFileMenu.

protected MMenu createFileMenu() {
    MMenu fileMenu = MMenuFactory.INSTANCE.createMenu();
    fileMenu.setLabel("File");
    List<MMenuElement> menuItems = fileMenu.getChildren();
    menuItems.add(createHandledMenuItem("save", "Save", "org.eclipse.ui.file.save", "platform:/plugin/org.whole.product.e4.lw/icons/save_edit.png"));
    menuItems.add(createHandledMenuItem("quit", "Quit", "org.eclipse.ui.file.exit"));
    menuItems.add(createHandledMenuItem("revert", "Revert", "org.eclipse.ui.file.revert"));
    return fileMenu;
}
Also used : MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu) MMenuElement(org.eclipse.e4.ui.model.application.ui.menu.MMenuElement)

Example 2 with MMenu

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

the class E4ModelProcessor method initialize.

@Execute
protected void initialize() throws CoreException {
    try {
        ClasspathPersistenceProvider pp = new ClasspathPersistenceProvider("org/whole/product/e4/lw/WorkspaceConfiguration.xwl");
        InterpreterOperation.interpret(XmlBuilderPersistenceKit.instance().readModel(pp));
        MUIElement placeholderWindow = modelService.find(PLACEHOLDER_WINDOW_ID, application);
        if (placeholderWindow == null || !placeholderWindow.getParent().getChildren().remove(placeholderWindow))
            throw new IllegalStateException("Unable to remove placeholder window with id: '" + PLACEHOLDER_WINDOW_ID + "'");
        MTrimmedWindow window = MBasicFactory.INSTANCE.createTrimmedWindow();
        window.setLabel("Whole Language Workbench Window");
        window.setX(500);
        window.setY(20);
        window.setWidth(800);
        window.setHeight(1000);
        MMenu mainMenu = MMenuFactory.INSTANCE.createMenu();
        mainMenu.setElementId("menu:org.eclipse.ui.main.menu");
        mainMenu.getChildren().add(createFileMenu());
        mainMenu.getChildren().add(createEditMenu());
        mainMenu.getChildren().add(createHelpMenu());
        window.setMainMenu(mainMenu);
        MTrimBar trimBar = MBasicFactory.INSTANCE.createTrimBar();
        trimBar.setSide(SideValue.TOP);
        trimBar.getChildren().add(createToolBar());
        window.getTrimBars().add(trimBar);
        MPerspectiveStack perspectiveStack = MAdvancedFactory.INSTANCE.createPerspectiveStack();
        MPerspective perspective = MAdvancedFactory.INSTANCE.createPerspective();
        perspective.setLabel("P1");
        MPartSashContainer partSashContainer = MBasicFactory.INSTANCE.createPartSashContainer();
        partSashContainer.setHorizontal(false);
        MPartStack partStack = MBasicFactory.INSTANCE.createPartStack();
        MPart part = MBasicFactory.INSTANCE.createPart();
        part.setContributionURI("bundleclass://org.whole.lang.e4.ui/org.whole.lang.e4.ui.parts.E4GraphicalPart");
        part.setLabel("Part1a");
        part.setCloseable(true);
        Map<String, String> persistedState = part.getPersistedState();
        persistedState.put("basePersistenceKitId", "org.whole.lang.xml.codebase.XmlBuilderPersistenceKit");
        persistedState.put("filePath", "/BaseProject/src/org/whole/lang/ExampleModel.xwl");
        persistedState.put("overridePersistenceKitId", "org.whole.lang.xml.codebase.XmlBuilderPersistenceKit");
        partStack.getChildren().add(part);
        partSashContainer.getChildren().add(partStack);
        perspective.getChildren().add(partSashContainer);
        perspectiveStack.getChildren().add(perspective);
        window.getChildren().add(perspectiveStack);
        application.getChildren().add(window);
    } catch (Exception e) {
        System.out.println("Unable to configure the initial workspace");
        e.printStackTrace();
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) MTrimBar(org.eclipse.e4.ui.model.application.ui.basic.MTrimBar) MPerspectiveStack(org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack) MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu) CoreException(org.eclipse.core.runtime.CoreException) MPerspective(org.eclipse.e4.ui.model.application.ui.advanced.MPerspective) MTrimmedWindow(org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) MPartSashContainer(org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer) Execute(org.eclipse.e4.core.di.annotations.Execute)

Example 3 with MMenu

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

the class E4ModelProcessor method createHelpMenu.

protected MMenu createHelpMenu() {
    MMenu helpMenu = MMenuFactory.INSTANCE.createMenu();
    helpMenu.setLabel("File");
    helpMenu.getChildren().add(createHandledMenuItem("about", "About", "org.eclipse.ui.help.aboutAction"));
    helpMenu.getChildren().add(createHandledMenuItem("preferences", "Preferences", "org.eclipse.ui.window.preferences"));
    return helpMenu;
}
Also used : MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu)

Example 4 with MMenu

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

the class CopyMenuToNewWindowAddon method onEvent.

@Inject
@Optional
public void onEvent(@UIEventTopic(UIEvents.Window.TOPIC_ALL) Event event) {
    if (UIEvents.isADD(event)) {
        MTrimmedWindow origin = (MTrimmedWindow) event.getProperty(EventTags.ELEMENT);
        MTrimmedWindow window = (MTrimmedWindow) event.getProperty(EventTags.NEW_VALUE);
        MMenu mainMenu = (MMenu) EcoreUtil.copy((EObject) origin.getMainMenu());
        mainMenu.setVisible(true);
        window.setMainMenu(mainMenu);
    }
}
Also used : MTrimmedWindow(org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow) EObject(org.eclipse.emf.ecore.EObject) MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu) Inject(javax.inject.Inject) Optional(org.eclipse.e4.core.di.annotations.Optional)

Example 5 with MMenu

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

the class E4ModelProcessor method createEditMenu.

protected MMenu createEditMenu() {
    MMenu editMenu = MMenuFactory.INSTANCE.createMenu();
    editMenu.setLabel("Edit");
    List<MMenuElement> menuItems = editMenu.getChildren();
    menuItems.add(createHandledMenuItem("undo", "Undo", "org.eclipse.ui.edit.undo"));
    menuItems.add(createHandledMenuItem("redo", "Redo", "org.eclipse.ui.edit.redo"));
    menuItems.add(MMenuFactory.INSTANCE.createMenuSeparator());
    menuItems.add(createHandledMenuItem("cut", "Cut", "org.eclipse.ui.edit.cut"));
    menuItems.add(createHandledMenuItem("copy", "Copy", "org.eclipse.ui.edit.copy"));
    menuItems.add(createHandledMenuItem("paste", "Paste", "org.eclipse.ui.edit.paste"));
    menuItems.add(createHandledMenuItem("delete", "Delete", "org.eclipse.ui.edit.delete"));
    menuItems.add(createHandledMenuItem("selectAll", "Select All", "org.eclipse.ui.edit.selectAll"));
    menuItems.add(createHandledMenuItem("findReplace", "Find/Replace...", "org.eclipse.ui.edit.findReplace"));
    return editMenu;
}
Also used : MMenu(org.eclipse.e4.ui.model.application.ui.menu.MMenu) MMenuElement(org.eclipse.e4.ui.model.application.ui.menu.MMenuElement)

Aggregations

MMenu (org.eclipse.e4.ui.model.application.ui.menu.MMenu)6 MMenuElement (org.eclipse.e4.ui.model.application.ui.menu.MMenuElement)3 MTrimmedWindow (org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow)2 Inject (javax.inject.Inject)1 CoreException (org.eclipse.core.runtime.CoreException)1 Execute (org.eclipse.e4.core.di.annotations.Execute)1 Optional (org.eclipse.e4.core.di.annotations.Optional)1 MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)1 MPerspective (org.eclipse.e4.ui.model.application.ui.advanced.MPerspective)1 MPerspectiveStack (org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack)1 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)1 MPartSashContainer (org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer)1 MPartStack (org.eclipse.e4.ui.model.application.ui.basic.MPartStack)1 MTrimBar (org.eclipse.e4.ui.model.application.ui.basic.MTrimBar)1 MWindow (org.eclipse.e4.ui.model.application.ui.basic.MWindow)1 EObject (org.eclipse.emf.ecore.EObject)1 ClasspathPersistenceProvider (org.whole.lang.codebase.ClasspathPersistenceProvider)1