private List<EditorReference> getOrderedEditorReferences() { List<EditorReference> editorRefs = new ArrayList<>(); List<MPart> visibleEditors = modelService.findElements(window, CompatibilityEditor.MODEL_ELEMENT_ID, MPart.class); for (MPart editor : visibleEditors) { if (editor.isToBeRendered()) { EditorReference ref = getEditorReference(editor); if (ref != null && !editorRefs.contains(ref)) { editorRefs.add(ref); } } } return editorRefs; }
private List<MPart> getCloseableSiblingParts(MPart part, List<MUIElement> children, final int start, final int end) { // broken out from closeSiblingParts so it can be used to determine how // many closeable siblings are available List<MPart> closeableSiblings = new ArrayList<>(); for (int i = start; i < end; i++) { MUIElement child = children.get(i); // If the element isn't showing skip it if (!child.isToBeRendered()) continue; MPart otherPart = null; if (child instanceof MPart) otherPart = (MPart) child; else if (child instanceof MPlaceholder) { MUIElement otherItem = ((MPlaceholder) child).getRef(); if (otherItem instanceof MPart) otherPart = (MPart) otherItem; } if (otherPart == null) continue; if (part.equals(otherPart)) continue; // skip selected item if (otherPart.isToBeRendered() && isClosable(otherPart)) closeableSiblings.add(otherPart); } return closeableSiblings; }
for (EditorReference reference : sortedReferences) { for (MPart placeholder : placeholders) { if (reference.getModel() == placeholder && placeholder.isToBeRendered()) {
private List<MPart> getCloseableSiblingParts(MPart part) { // broken out from closeSiblingParts so it can be used to determine how // many closeable siblings are available MElementContainer<MUIElement> container = getParent(part); List<MPart> closeableSiblings = new ArrayList<MPart>(); if (container == null) return closeableSiblings; List<MUIElement> children = container.getChildren(); for (MUIElement child : children) { // If the element isn't showing skip it if (!child.isToBeRendered()) continue; MPart otherPart = null; if (child instanceof MPart) otherPart = (MPart) child; else if (child instanceof MPlaceholder) { MUIElement otherItem = ((MPlaceholder) child).getRef(); if (otherItem instanceof MPart) otherPart = (MPart) otherItem; } if (otherPart == null) continue; if (part.equals(otherPart)) continue; // skip selected item if (otherPart.isToBeRendered() && isClosable(otherPart)) closeableSiblings.add(otherPart); } return closeableSiblings; }
@Override public boolean isPartOrPlaceholderInPerspective(String elementId, MPerspective perspective) { List<MPart> findElements = modelService.findElements(perspective, elementId, MPart.class, null); if (!findElements.isEmpty()) { MPart part = findElements.get(0); // if that is a shared part, check the placeholders if (workbenchWindow.getSharedElements().contains(part)) { List<MPlaceholder> placeholders = modelService.findElements(perspective, elementId, MPlaceholder.class, null); for (MPlaceholder mPlaceholder : placeholders) { if (mPlaceholder.isVisible() && mPlaceholder.isToBeRendered()) { return true; } } return false; } // not a shared part return part.isVisible() && part.isToBeRendered(); } return false; }
private void closeSiblingParts(MPart part, boolean skipThisPart) { MElementContainer<MUIElement> container = getParent(part); if (container == null) return; List<MPart> others = getCloseableSiblingParts(part); // add the current part last so that we unrender obscured items first if (!skipThisPart && part.isToBeRendered() && isClosable(part)) { others.add(part); } // add the selected element of the stack at the end, else we may end up // selecting another part when we hide it since it is the selected // element MUIElement selectedElement = container.getSelectedElement(); if (others.remove(selectedElement)) { others.add((MPart) selectedElement); } else if (selectedElement instanceof MPlaceholder) { selectedElement = ((MPlaceholder) selectedElement).getRef(); if (others.remove(selectedElement)) { others.add((MPart) selectedElement); } } EPartService partService = getContextForParent(part).get( EPartService.class); for (MPart otherPart : others) { if (partService.savePart(otherPart, true)) partService.hidePart(otherPart); } }
/** * @return {@code true} if the part should not be rendered or it has a current * shared reference that is not to be rendered <b>or</b> if a * placeholder for the part (in the current perspective) exists and is * not to be rendered. {@code false} otherwise, i.e. if the placeholders * of the part are to be rendered. */ private boolean shouldNotRenderPart(MPart part) { if (!part.isToBeRendered()) { return true; } MPlaceholder curSharedRef = part.getCurSharedRef(); if (curSharedRef != null && !curSharedRef.isToBeRendered()) { return true; } MPlaceholder mPlaceholder = modelService.findPlaceholderFor(window, part); if (mPlaceholder != null && !mPlaceholder.isToBeRendered()) { return true; } return false; }
if (!skipThisPart && part.isToBeRendered() && isClosable(part)) { others.add(part);
/** * Unzooms the shared area if there are no more rendered parts contained * within it. * * @see #unzoomSharedArea(MUIElement) */ private void unzoomSharedArea() { MPerspective curPersp = getPerspectiveStack().getSelectedElement(); if (curPersp == null) return; MPlaceholder eaPH = (MPlaceholder) modelService.find(IPageLayout.ID_EDITOR_AREA, curPersp); for (MPart part : modelService.findElements(eaPH, null, MPart.class, null)) { if (part.isToBeRendered()) { MPlaceholder placeholder = part.getCurSharedRef(); if (placeholder == null || placeholder.isToBeRendered()) { return; } } } setPartState(eaPH, null); }
if (selectedPart != null && selectedPart.isToBeRendered() && getParts().contains(selectedPart)) {
public CTabItem findItemForPart(MPart part) { if (!part.isToBeRendered()) return null;