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; }
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; }
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); } }
if (!skipThisPart && part.isToBeRendered() && isClosable(part)) { others.add(part);
MPart part = (MPart) ((uiElement instanceof MPart) ? uiElement : ((MPlaceholder) uiElement).getRef()); if (!check && !isClosable(part)) { return false;
/** * Closes the part that's backed by the given widget. * * @param widget * the part that owns this widget * @param check * <tt>true</tt> if the part should be checked to see if it has * been defined as being not closeable for users, <tt>false</tt> * if this check should not be performed * @return <tt>true</tt> if the part was closed, <tt>false</tt> otherwise */ private boolean closePart(Widget widget, boolean check) { MUIElement uiElement = (MUIElement) widget.getData(AbstractPartRenderer.OWNING_ME); MPart part = (MPart) ((uiElement instanceof MPart) ? uiElement : ((MPlaceholder) uiElement).getRef()); if (!check && !isClosable(part)) { return false; } IEclipseContext partContext = part.getContext(); IEclipseContext parentContext = getContextForParent(part); // a part may not have a context if it hasn't been rendered IEclipseContext context = partContext == null ? parentContext : partContext; // ask user to save if necessary and close part if it is not dirty EPartService partService = context.get(EPartService.class); if (partService.savePart(part, true)) { partService.hidePart(part); return true; } // the user has canceled the save operation, so the part is not closed return false; }
if (isClosable(part)) { createMenuItem(menu, SWTRenderersMessages.menuClose, e -> closePart(menu)); closeableElements++;
if (isClosable(part)) { MenuItem menuItemClose = new MenuItem(menu, SWT.NONE); menuItemClose.setText(SWTRenderersMessages.menuClose);
if (part != null && isClosable(part)) { createFlags |= SWT.CLOSE;
if (part != null && isClosable(part)) { createFlags |= SWT.CLOSE;