Source:
<code>public void switchPerspective(MPerspective perspective) { Assert.isNotNull(perspective); MWindow window = getWindow(); if (window != null && isInContainer(window, perspective)) { perspective.getParent().setSelectedElement(perspective); List<MPart> newPerspectiveParts = modelService.findElements(perspective, null, MPart.class, null); if (newPerspectiveParts.contains(activePart) && partActivationHistory.isValid(perspective, activePart)) { MPart target = activePart; IEclipseContext activeChild = activePart.getContext().getParent().getActiveChild(); if (activeChild != null) { activeChild.deactivate(); } if (target.getContext() != null <START> && target.getContext().getParent() == perspective.getContext()) { <END> target.getContext().activateBranch(); } else { perspective.getContext().activate(); } modelService.bringToTop(target); activate(target, true, false); return; } MPart newActivePart = perspective.getContext().getActiveLeaf().get(MPart.class); if (newActivePart == null) { MPart candidate = partActivationHistory.getActivationCandidate(perspective); if (candidate != null) { modelService.bringToTop(candidate); activate(candidate, true, false); return; } } if (newActivePart == null) { modelService.bringToTop(perspective); perspective.getContext().activate(); } else { if ((modelService.getElementLocation(newActivePart) & EModelService.IN_SHARED_AREA) != 0) { if (newActivePart.getParent().getSelectedElement() != newActivePart) { newActivePart = (MPart) newActivePart.getParent().getSelectedElement(); } } activate(newActivePart, true, false); } } }</code><technical_language>This check fails in case of split editors, target parent is MCompositePart. I guess more general algorithm search target context parents if is perspective context</technical_language>

Target:
public void switchPerspective(MPerspective perspective) { Assert.isNotNull(perspective); MWindow window = getWindow(); if (window != null && isInContainer(window, perspective)) { perspective.getParent().setSelectedElement(perspective); List<MPart> newPerspectiveParts = modelService.findElements(perspective, null, MPart.class, null); if (newPerspectiveParts.contains(activePart) && partActivationHistory.isValid(perspective, activePart)) { MPart target = activePart; IEclipseContext activeChild = activePart.getContext().getParent().getActiveChild(); if (activeChild != null) { activeChild.deactivate(); } if (target.getContext() != null && target.getContext().get(MPerspective.class) != null && target.getContext().get(MPerspective.class).getContext() == perspective.getContext()) { target.getContext().activateBranch(); } else { perspective.getContext().activate(); } modelService.bringToTop(target); activate(target, true, false); return; } MPart newActivePart = perspective.getContext().getActiveLeaf().get(MPart.class); if (newActivePart == null) { MPart candidate = partActivationHistory.getActivationCandidate(perspective); if (candidate != null) { modelService.bringToTop(candidate); activate(candidate, true, false); return; } } if (newActivePart == null) { modelService.bringToTop(perspective); perspective.getContext().activate(); } else { if ((modelService.getElementLocation(newActivePart) & EModelService.IN_SHARED_AREA) != 0) { if (newActivePart.getParent().getSelectedElement() != newActivePart) { newActivePart = (MPart) newActivePart.getParent().getSelectedElement(); } } activate(newActivePart, true, false); } } }