Search in sources :

Example 1 with IPresentationEngine

use of org.eclipse.e4.ui.workbench.IPresentationEngine in project eclipse.platform.ui by eclipse-platform.

the class E4Workbench method instantiateRenderer.

/**
 */
public void instantiateRenderer() {
    renderer = appContext.get(IPresentationEngine.class);
    if (renderer == null) {
        String presentationURI = (String) appContext.get(IWorkbench.PRESENTATION_URI_ARG);
        if (presentationURI != null) {
            IContributionFactory factory = appContext.get(IContributionFactory.class);
            renderer = (IPresentationEngine) factory.create(presentationURI, appContext);
            appContext.set(IPresentationEngine.class, renderer);
        }
        if (renderer == null) {
            Logger logger = appContext.get(Logger.class);
            // $NON-NLS-1$
            logger.error("Failed to create the presentation engine for URI: " + presentationURI);
        }
    }
}
Also used : Logger(org.eclipse.e4.core.services.log.Logger) IPresentationEngine(org.eclipse.e4.ui.workbench.IPresentationEngine) IContributionFactory(org.eclipse.e4.core.services.contributions.IContributionFactory)

Example 2 with IPresentationEngine

use of org.eclipse.e4.ui.workbench.IPresentationEngine in project eclipse.platform.ui by eclipse-platform.

the class PartServiceImpl method activate.

private void activate(MPart part, boolean requiresFocus, boolean activateBranch) {
    if (part == null) {
        if (constructed && activePart != null) {
            if (Policy.DEBUG_FOCUS) {
                // $NON-NLS-1$
                Activator.trace(Policy.DEBUG_FOCUS_FLAG, "Deactivated: " + activePart, null);
            }
            firePartDeactivated(activePart);
        }
        activePart = part;
        return;
    }
    if (Policy.DEBUG_FOCUS) {
        // $NON-NLS-1$
        Activator.trace(Policy.DEBUG_FOCUS_FLAG, "Activating " + part, null);
    }
    // Delegate activations to a CompositePart's inner part (if any)
    if (part instanceof MCompositePart) {
        if (part.getContext() != null) {
            IEclipseContext pContext = part.getContext();
            if (pContext.getActiveLeaf() != null) {
                MPart inner = pContext.getActiveLeaf().get(MPart.class);
                if (inner != null) {
                    part = inner;
                }
            }
        }
    }
    // only activate parts that is under our control
    if (!isInContainer(part)) {
        if (Policy.DEBUG_FOCUS) {
            // $NON-NLS-1$
            Activator.trace(Policy.DEBUG_FOCUS_FLAG, "Activation failed, part is not in container: " + part, null);
        }
        return;
    }
    MWindow window = getWindow();
    IEclipseContext windowContext = window.getContext();
    // check if the active part has changed or if we are no longer the active window
    if (windowContext.getParent().getActiveChild() == windowContext && part == activePart) {
        // insert it in the beginning of the activation history, it may not have been inserted
        // pending when this service was instantiated
        partActivationHistory.prepend(part);
        UIEvents.publishEvent(UIEvents.UILifeCycle.ACTIVATE, part);
        if (Policy.DEBUG_FOCUS) {
            // $NON-NLS-1$
            Activator.trace(Policy.DEBUG_FOCUS_FLAG, "Trying to activate already active part: " + part, null);
        }
        return;
    }
    if (contextService != null) {
        contextService.deferUpdates(true);
    }
    if (contextManager != null) {
        contextManager.deferUpdates(true);
    }
    MPart lastActivePart = activePart;
    activePart = part;
    if (constructed && lastActivePart != null && lastActivePart != activePart) {
        if (Policy.DEBUG_FOCUS) {
            // $NON-NLS-1$
            Activator.trace(Policy.DEBUG_FOCUS_FLAG, "Deactivated: " + lastActivePart, null);
        }
        firePartDeactivated(lastActivePart);
    }
    try {
        // record any sibling into the activation history if necessary, this will allow it to be
        // reselected again in the future as it will be an activation candidate in the future,
        // this
        // prevents other unrendered elements from being selected arbitrarily which would cause
        // unwanted bundle activation
        recordStackActivation(part);
        delegateBringToTop(part);
        window.getParent().setSelectedElement(window);
        partActivationHistory.activate(part, activateBranch);
        if (requiresFocus) {
            IPresentationEngine pe = part.getContext().get(IPresentationEngine.class);
            pe.focusGui(part);
        }
        // store the activation time to sort the parts in MRU order
        part.getTransientData().put(PART_ACTIVATION_TIME, Long.valueOf(System.currentTimeMillis()));
        firePartActivated(part);
        UIEvents.publishEvent(UIEvents.UILifeCycle.ACTIVATE, part);
    } finally {
        if (contextService != null) {
            contextService.deferUpdates(false);
        }
        if (contextManager != null) {
            contextManager.deferUpdates(false);
        }
        if (Policy.DEBUG_FOCUS) {
            // $NON-NLS-1$
            Activator.trace(Policy.DEBUG_FOCUS_FLAG, "Activation done: " + part, null);
        }
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) MCompositePart(org.eclipse.e4.ui.model.application.ui.basic.MCompositePart) MWindow(org.eclipse.e4.ui.model.application.ui.basic.MWindow) IPresentationEngine(org.eclipse.e4.ui.workbench.IPresentationEngine)

Example 3 with IPresentationEngine

use of org.eclipse.e4.ui.workbench.IPresentationEngine in project eclipse.platform.ui by eclipse-platform.

the class PerspectiveRenderer method processContents.

@Override
public void processContents(MElementContainer<MUIElement> container) {
    super.processContents(container);
    IPresentationEngine renderer = context.get(IPresentationEngine.class);
    MPerspective persp = (MPerspective) ((MUIElement) container);
    Shell shell = ((Composite) persp.getWidget()).getShell();
    for (MWindow dw : persp.getWindows()) {
        renderer.createGui(dw, shell, persp.getContext());
    }
}
Also used : MPerspective(org.eclipse.e4.ui.model.application.ui.advanced.MPerspective) Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) IPresentationEngine(org.eclipse.e4.ui.workbench.IPresentationEngine) MWindow(org.eclipse.e4.ui.model.application.ui.basic.MWindow)

Example 4 with IPresentationEngine

use of org.eclipse.e4.ui.workbench.IPresentationEngine in project eclipse.platform.ui by eclipse-platform.

the class SWTPartRenderer method processContents.

@Override
public void processContents(MElementContainer<MUIElement> container) {
    // EMF gives us null lists if empty
    if (container == null)
        return;
    // Process any contents of the newly created ME
    List<MUIElement> parts = container.getChildren();
    if (parts != null) {
        // loading a legacy app will add children to the window while it is
        // being rendered.
        // this is *not* the correct place for this
        // hope that the ADD event will pick up the new part.
        IPresentationEngine renderer = context.get(IPresentationEngine.class);
        for (int i = 0; i < parts.size(); i++) {
            MUIElement childME = parts.get(i);
            renderer.createGui(childME);
        }
    }
}
Also used : MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) IPresentationEngine(org.eclipse.e4.ui.workbench.IPresentationEngine)

Example 5 with IPresentationEngine

use of org.eclipse.e4.ui.workbench.IPresentationEngine in project eclipse.platform.ui by eclipse-platform.

the class WBWRenderer method processContents.

/*
	 * Processing the contents of a Workbench window has to take into account
	 * that there may be trim elements contained in its child list. Since the
	 */
@Override
public void processContents(MElementContainer<MUIElement> me) {
    if (!(((MUIElement) me) instanceof MWindow)) {
        return;
    }
    MWindow wbwModel = (MWindow) ((MUIElement) me);
    super.processContents(me);
    // Populate the main menu
    IPresentationEngine renderer = context.get(IPresentationEngine.class);
    if (wbwModel.getMainMenu() != null) {
        renderer.createGui(wbwModel.getMainMenu(), me.getWidget(), null);
        Shell shell = (Shell) me.getWidget();
        shell.setMenuBar((Menu) wbwModel.getMainMenu().getWidget());
    }
    // create Detached Windows
    for (MWindow dw : wbwModel.getWindows()) {
        renderer.createGui(dw, me.getWidget(), wbwModel.getContext());
    }
    // Populate the trim (if any)
    if (wbwModel instanceof MTrimmedWindow) {
        Shell shell = (Shell) wbwModel.getWidget();
        MTrimmedWindow tWindow = (MTrimmedWindow) wbwModel;
        List<MTrimBar> trimBars = new ArrayList<>(tWindow.getTrimBars());
        for (MTrimBar trimBar : trimBars) {
            renderer.createGui(trimBar, shell, wbwModel.getContext());
            // limbo shell wheb visible=false
            if (!trimBar.isVisible()) {
                trimBar.setVisible(true);
                trimBar.setVisible(false);
            }
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) MTrimmedWindow(org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow) ArrayList(java.util.ArrayList) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) MTrimBar(org.eclipse.e4.ui.model.application.ui.basic.MTrimBar) MWindow(org.eclipse.e4.ui.model.application.ui.basic.MWindow) IPresentationEngine(org.eclipse.e4.ui.workbench.IPresentationEngine)

Aggregations

IPresentationEngine (org.eclipse.e4.ui.workbench.IPresentationEngine)28 MWindow (org.eclipse.e4.ui.model.application.ui.basic.MWindow)13 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)11 Test (org.junit.Test)8 MPartStack (org.eclipse.e4.ui.model.application.ui.basic.MPartStack)7 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)5 IContributionFactory (org.eclipse.e4.core.services.contributions.IContributionFactory)5 MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)5 Shell (org.eclipse.swt.widgets.Shell)5 MPartSashContainer (org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer)4 MMenu (org.eclipse.e4.ui.model.application.ui.menu.MMenu)4 ArrayList (java.util.ArrayList)3 AbstractPartRenderer (org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer)3 MToolBar (org.eclipse.e4.ui.model.application.ui.menu.MToolBar)3 IRendererFactory (org.eclipse.e4.ui.workbench.swt.factories.IRendererFactory)3 MApplicationElement (org.eclipse.e4.ui.model.application.MApplicationElement)2 MPerspective (org.eclipse.e4.ui.model.application.ui.advanced.MPerspective)2 MTrimmedWindow (org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow)2 MenuManagerRenderer (org.eclipse.e4.ui.workbench.renderers.swt.MenuManagerRenderer)2 ToolBarManagerRenderer (org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer)2