public static boolean processAddition( final MTrimBar trimBar, MTrimContribution contribution, List<MTrimElement> contributions, HashSet<String> existingToolbarIds) { int idx = getIndex(trimBar, contribution.getPositionInParent()); if (idx == -1) { return false; } for (MTrimElement item : contribution.getChildren()) { if (item instanceof MToolBar && existingToolbarIds.contains(item.getElementId())) { // skip this, it's already there continue; } MTrimElement copy = (MTrimElement) EcoreUtil.copy((EObject) item); if (DEBUG) { trace("addTrimContribution " + copy, trimBar.getWidget(), trimBar); // $NON-NLS-1$ } trimBar.getChildren().add(idx++, copy); contributions.add(copy); if (copy instanceof MToolBar && copy.getElementId() != null) { existingToolbarIds.add(copy.getElementId()); } } return true; }
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) { String generatedId = "PartStack@" + Integer.toHexString(stack.hashCode()); // $NON-NLS-1$ 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 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(persp.getElementId())) { toRemove.add((MToolControl) barKid); } } } for (MToolControl toolControl : toRemove) { // Close any open fast view toolControl.setToBeRendered(false); toolControl.getParent().getChildren().remove(toolControl); } }