use of org.eclipse.e4.ui.model.application.ui.advanced.MArea in project eclipse.platform.ui by eclipse-platform.
the class ModelServiceImpl method resetPerspectiveModel.
private void resetPerspectiveModel(MPerspective persp, MWindow window, boolean removeSharedPlaceholders) {
if (persp == null) {
return;
}
if (removeSharedPlaceholders) {
// Remove any views (Placeholders) from the shared area
EPartService ps = window.getContext().get(EPartService.class);
List<MArea> areas = findElements(window, null, MArea.class, null);
if (areas.size() == 1) {
MArea area = areas.get(0);
// Strip out the placeholders in visible stacks
List<MPlaceholder> phList = findElements(area, null, MPlaceholder.class, null);
for (MPlaceholder ph : phList) {
ps.hidePart((MPart) ph.getRef());
ph.getParent().getChildren().remove(ph);
}
// Prevent shared stacks ids from clashing with the ones in the perspective
List<MPartStack> stacks = findElements(area, null, MPartStack.class, null);
for (MPartStack stack : stacks) {
// $NON-NLS-1$
String generatedId = "PartStack@" + Integer.toHexString(stack.hashCode());
stack.setElementId(generatedId);
}
// Also remove any min/max tags on the area (or its placeholder)
MUIElement areaPresentation = area;
if (area.getCurSharedRef() != null) {
areaPresentation = area.getCurSharedRef();
}
areaPresentation.getTags().remove(IPresentationEngine.MAXIMIZED);
areaPresentation.getTags().remove(IPresentationEngine.MINIMIZED);
areaPresentation.getTags().remove(IPresentationEngine.MINIMIZED_BY_ZOOM);
}
}
// Remove any minimized stacks for this perspective
// $NON-NLS-1$ //$NON-NLS-2$
String perspectiveSuffix = "(" + persp.getElementId() + ")";
List<MTrimBar> bars = findElements(window, null, MTrimBar.class, null);
List<MToolControl> toRemove = new ArrayList<>();
for (MTrimBar bar : bars) {
for (MUIElement barKid : bar.getChildren()) {
if (!(barKid instanceof MToolControl)) {
continue;
}
String id = barKid.getElementId();
if (id != null && id.contains(perspectiveSuffix)) {
toRemove.add((MToolControl) barKid);
}
}
}
for (MToolControl toolControl : toRemove) {
// Close any open fast view
toolControl.setToBeRendered(false);
toolControl.getParent().getChildren().remove(toolControl);
}
}
use of org.eclipse.e4.ui.model.application.ui.advanced.MArea in project eclipse.platform.ui by eclipse-platform.
the class ModelServiceImpl method isLastEditorStack.
@Override
public boolean isLastEditorStack(MUIElement stack) {
if (!(stack instanceof MPartStack)) {
return false;
}
// is it in the shared area?
MUIElement parent = stack.getParent();
while (parent != null && !(parent instanceof MArea)) {
parent = parent.getParent();
}
if (parent == null) {
return false;
}
// OK, it's in the area, is it the last TBR one ?
MArea area = (MArea) parent;
List<MPartStack> stacks = findElements(area, null, MPartStack.class, null);
int count = 0;
for (MPartStack aStack : stacks) {
if (aStack.isToBeRendered()) {
count++;
}
}
return count < 2 && stack.isToBeRendered();
}
use of org.eclipse.e4.ui.model.application.ui.advanced.MArea in project eclipse.platform.ui by eclipse-platform.
the class ModelServiceImpl method getElementLocation.
@Override
public int getElementLocation(MUIElement element) {
if (element == null) {
return NOT_IN_UI;
}
// If the element is shared then use its current placeholder
if (element.getCurSharedRef() != null) {
element = element.getCurSharedRef();
}
int location = NOT_IN_UI;
MUIElement curElement = element;
while (curElement != null) {
Object container = ((EObject) curElement).eContainer();
if (!(container instanceof MUIElement))
return NOT_IN_UI;
if (container instanceof MApplication) {
if (location != NOT_IN_UI)
return location;
return OUTSIDE_PERSPECTIVE;
} else if (container instanceof MPerspective) {
MPerspective perspective = (MPerspective) container;
MUIElement perspParent = perspective.getParent();
if (perspParent == null) {
location = NOT_IN_UI;
} else if (perspective.getParent().getSelectedElement() == perspective) {
location |= IN_ACTIVE_PERSPECTIVE;
} else {
location |= IN_ANY_PERSPECTIVE;
}
} else if (container instanceof MTrimBar) {
location = IN_TRIM;
} else if (container instanceof MArea) {
location = IN_SHARED_AREA;
}
curElement = (MUIElement) container;
}
return NOT_IN_UI;
}
use of org.eclipse.e4.ui.model.application.ui.advanced.MArea in project eclipse.platform.ui by eclipse-platform.
the class PartActivationHistory method getNextActivationCandidate.
MPart getNextActivationCandidate(Collection<MPart> validParts, MPart part) {
MArea area = isInArea(part);
if (area != null) {
// focus should stay in the area if possible
MPart candidate = getSiblingActivationCandidate(part);
if (candidate != null) {
return candidate;
}
// no sibling candidate, find another part in the area to activate
candidate = findActivationCandidate(modelService.findElements(area, null, MPart.class), part);
if (candidate != null) {
return candidate;
}
}
// check activation history, since the history is global, we need to filter it down first
Collection<MPart> validCandidates = new ArrayList<>();
for (MPart validPart : generalActivationHistory) {
if (validParts.contains(validPart)) {
validCandidates.add(validPart);
}
}
MPart candidate = findActivationCandidate(validCandidates, part);
return candidate == null ? getActivationCandidate(part) : candidate;
}
use of org.eclipse.e4.ui.model.application.ui.advanced.MArea in project eclipse.platform.ui by eclipse-platform.
the class PlaceholderResolver method resolvePlaceholderRef.
@Override
public void resolvePlaceholderRef(MPlaceholder ph, MWindow refWin) {
if (ph.getRef() != null)
return;
// Must give us the window that you are resolving for...
Assert.isLegal(refWin != null);
// ..and it must be a 'top level' window
MUIElement refParent = refWin.getParent();
Assert.isLegal(refParent instanceof MApplication);
// So we already have a matching shared element ?
List<MUIElement> sharedElements = refWin.getSharedElements();
for (MUIElement se : sharedElements) {
if (ph.getElementId().equals(se.getElementId())) {
ph.setRef(se);
return;
}
}
// Hack to make the 3.x compatibility layer work
if (ph.getElementId().equals("org.eclipse.ui.editorss")) {
// $NON-NLS-1$
// This code is for the eclipse compatibility layer...
MArea sharedArea = AdvancedFactoryImpl.eINSTANCE.createArea();
// sharedArea.setLabel("Editor Area"); //$NON-NLS-1$
MPartStack editorStack = BasicFactoryImpl.eINSTANCE.createPartStack();
// $NON-NLS-1$
editorStack.getTags().add("org.eclipse.e4.primaryDataStack");
// $NON-NLS-1$
editorStack.getTags().add("EditorStack");
// $NON-NLS-1$
editorStack.setElementId("org.eclipse.e4.primaryDataStack");
sharedArea.getChildren().add(editorStack);
sharedArea.setElementId(ph.getElementId());
refWin.getSharedElements().add(sharedArea);
ph.setRef(sharedArea);
return;
}
// Assume that the placeholder is to a shared 'part'
EPartService ps = refWin.getContext().get(EPartService.class);
MPart newReferencedPart = ps.createPart(ph.getElementId());
if (newReferencedPart != null) {
refWin.getSharedElements().add(newReferencedPart);
ph.setRef(newReferencedPart);
return;
}
// SHould we log / show an exception here ?
}
Aggregations