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);
}
}
}
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);
}
}
}
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());
}
}
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);
}
}
}
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);
}
}
}
}
Aggregations