Search in sources :

Example 1 with MUIElement

use of org.eclipse.e4.ui.model.application.ui.MUIElement in project nebula.widgets.nattable by eclipse.

the class LifecycleManager method preSave.

@PreSave
void preSave(EModelService modelService, MApplication app) {
    List<String> tags = new ArrayList<>();
    tags.add(CLOSE_ON_SHUTDOWN_TAG);
    List<MPart> elementsWithTags = modelService.findElements(app, null, MPart.class, tags);
    for (MPart part : elementsWithTags) {
        try {
            part.setToBeRendered(false);
            part.setVisible(false);
            MElementContainer<MUIElement> parent = part.getParent();
            parent.getChildren().remove(part);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) ArrayList(java.util.ArrayList) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) PreSave(org.eclipse.e4.ui.workbench.lifecycle.PreSave)

Example 2 with MUIElement

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

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

the class LifeCycleManager method removePortfolioPartsWithoutPersistedFile.

private void removePortfolioPartsWithoutPersistedFile(MApplication app, EPartService partService, EModelService modelService) {
    List<MPart> parts = modelService.findElements(app, MPart.class, EModelService.IN_ACTIVE_PERSPECTIVE, new Selector() {

        @Override
        public boolean select(MApplicationElement element) {
            if (// $NON-NLS-1$
            !"name.abuchen.portfolio.ui.part.portfolio".equals(element.getElementId()))
                return false;
            // $NON-NLS-1$
            return element.getPersistedState().get("file") == null;
        }
    });
    for (MPart part : parts) {
        MElementContainer<MUIElement> parent = part.getParent();
        if (parent.getSelectedElement().equals(part))
            parent.setSelectedElement(null);
        parent.getChildren().remove(part);
    }
}
Also used : MApplicationElement(org.eclipse.e4.ui.model.application.MApplicationElement) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) Selector(org.eclipse.e4.ui.workbench.Selector)

Aggregations

MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)3 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)3 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 Execute (org.eclipse.e4.core.di.annotations.Execute)1 MApplicationElement (org.eclipse.e4.ui.model.application.MApplicationElement)1 MPerspective (org.eclipse.e4.ui.model.application.ui.advanced.MPerspective)1 MPerspectiveStack (org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack)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 MTrimmedWindow (org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow)1 MMenu (org.eclipse.e4.ui.model.application.ui.menu.MMenu)1 Selector (org.eclipse.e4.ui.workbench.Selector)1 PreSave (org.eclipse.e4.ui.workbench.lifecycle.PreSave)1 ClasspathPersistenceProvider (org.whole.lang.codebase.ClasspathPersistenceProvider)1