private boolean hasVisibleContent(MPartSashContainer sash) { for (MPartSashContainerElement child : sash.getChildren()) { if (child.isVisible()) { return true; } } return false; }
private void combine(MPartSashContainerElement toInsert, MPartSashContainerElement relTo, MPartSashContainer newSash, boolean newFirst, float ratio) { MElementContainer<MUIElement> curParent = relTo.getParent(); if (curParent == null) { // if relTo is a shared element, use its current placeholder MWindow win = getTopLevelWindowFor(relTo); relTo = findPlaceholderFor(win, relTo); curParent = relTo.getParent(); } Assert.isLegal(relTo != null && curParent != null); int index = curParent.getChildren().indexOf(relTo); curParent.getChildren().remove(relTo); if (newFirst) { newSash.getChildren().add(toInsert); newSash.getChildren().add(relTo); } else { newSash.getChildren().add(relTo); newSash.getChildren().add(toInsert); } // Set up the container data before adding the new sash to the model // To raise the granularity assume 100% == 10,000 int adjustedPct = (int) (ratio * 10000); toInsert.setContainerData(Integer.toString(adjustedPct)); relTo.setContainerData(Integer.toString(10000 - adjustedPct)); // add the new sash at the same location curParent.getChildren().add(index, newSash); }
private static boolean hasMoreThenOneVisibleRenderableChild(MPartSashContainerElement elementToCheck) { if (elementToCheck instanceof MPartSashContainer) { int partsToRender = 0; for (MPartSashContainerElement part : ((MPartSashContainer) elementToCheck).getChildren()) { boolean hasMinimizeableChild = hasMoreThenOneVisibleRenderableChild(part); if (hasMinimizeableChild) { return true; } if (isVisible(part)) { partsToRender++; } } if (partsToRender > 1) { return true; } } return false; }
/** * If this window has a primary perspective stack, return it. Otherwise * return null. A primary stack is a single MPerspectiveStack found either * as the window's immediate children or the child under a single * MPartSashContainer. * * @param window * the window * @return the stack or {@code null} */ private MPerspectiveStack getPrimaryPerspectiveStack(MWindow window) { List<MWindowElement> winKids = window.getChildren(); if (winKids.isEmpty()) { return null; } // Check if we have a MPerspectiveStack in window's children if (instanceCount(winKids, MPerspectiveStack.class) == 1) { return firstInstance(winKids, MPerspectiveStack.class); } // Traditional shape of IWorkbenchWindow: // MWindow{ MPartSashContainer{ MPerspectiveStack, MPartStack (intro // + cheatsheets + help)}} if (winKids.size() == 1 && winKids.get(0) instanceof MPartSashContainer) { MPartSashContainer topLevelPSC = (MPartSashContainer) winKids.get(0); if (instanceCount(topLevelPSC.getChildren(), MPerspectiveStack.class) == 1) { return firstInstance(topLevelPSC.getChildren(), MPerspectiveStack.class); } } return null; }
private void addStickyFolder() { MPartStack stickyFolder = modelService.createModelElement(MPartStack.class); stickyFolder.setElementId(StickyViewDescriptor.STICKY_FOLDER_RIGHT); stickyFolder.setContainerData("2500"); //$NON-NLS-1$ stickyFolder.setToBeRendered(false); mainSash.getChildren().add(stickyFolder); }
private MPartStack addDefaultFastViewStack() { MPartStack stack = null; List<String> views = perspReader.getDefaultFastViewBarViewIds(); if (views.size() > 0) { stack = layoutUtils.createStack(DEFAULT_FASTVIEW_STACK, true); MPartSashContainer psc = modelService.createModelElement(MPartSashContainer.class); psc.setHorizontal(true); psc.setContainerData(Integer.toString(5000)); stack.setContainerData(Integer.toString(2500)); psc.getChildren().add(stack); List<MPartSashContainer> list = modelService.findElements(perspective, null, MPartSashContainer.class); if (list == null || list.isEmpty()) { perspective.getChildren().add(psc); } else { int size = list.size(); MPartSashContainer container = list.get(size - 1); container.getChildren().add(psc); } setPartState(stack, org.eclipse.ui.internal.e4.migration.InfoReader.PartState.MINIMIZED); for (String view : views) { addPlaceholderToDefaultFastViewStack(stack, view, null); } } return stack; }
private MElementContainer<? extends MUIElement> getLastContainer() { MElementContainer<? extends MUIElement> searchRoot = getContainer(); @SuppressWarnings("unchecked") List<MUIElement> children = (List<MUIElement>) searchRoot.getChildren(); if (children.size() == 0) { MPartStack stack = modelService.createModelElement(MPartStack.class); children.add(stack); return stack; } MElementContainer<?> lastContainer = getLastContainer(searchRoot, children); if (lastContainer instanceof MPartStack) { return lastContainer; } // No stacks found make one and add it MPartStack stack = modelService.createModelElement(MPartStack.class); stack.setElementId("CreatedByGetLastContainer"); //$NON-NLS-1$ if (children.get(0) instanceof MPartSashContainer) { MPartSashContainer psc = (MPartSashContainer) children.get(0); psc.getChildren().add(stack); } else { // We need a sash so 'insert' the new stack modelService.insert(stack, (MPartSashContainerElement) children.get(0), EModelService.RIGHT_OF, 0.5f); } return stack; }
psc.getChildren().add((MPartSashContainerElement) toInsert); psc.getChildren().add((MPartSashContainerElement) relTo); toInsert.setContainerData("" + ratio); //$NON-NLS-1$ relTo.setContainerData("" + (10000 - ratio)); //$NON-NLS-1$ break; case SWT.RIGHT: psc.getChildren().add((MPartSashContainerElement) relTo); psc.getChildren().add((MPartSashContainerElement) toInsert); relTo.setContainerData("" + ratio); //$NON-NLS-1$ toInsert.setContainerData("" + (10000 - ratio)); //$NON-NLS-1$ break; case SWT.TOP: psc.getChildren().add((MPartSashContainerElement) toInsert); psc.getChildren().add((MPartSashContainerElement) relTo); toInsert.setContainerData("" + ratio); //$NON-NLS-1$ relTo.setContainerData("" + (10000 - ratio)); //$NON-NLS-1$ break; case SWT.BOTTOM: psc.getChildren().add((MPartSashContainerElement) relTo); psc.getChildren().add((MPartSashContainerElement) toInsert); relTo.setContainerData("" + ratio); //$NON-NLS-1$ toInsert.setContainerData("" + (10000 - ratio)); //$NON-NLS-1$
private void split(MUIElement toSplit, MUIElement child, @NonNull DropLocation dropType) { // remove the moved element from its parent child.setParent(null); // remember the index to insert MElementContainer<MUIElement> owner = toSplit.getParent(); int index = owner.getChildren().indexOf(toSplit); // remove the split from the parent owner.getChildren().remove(toSplit); MPartSashContainer container = this.modelService.createModelElement(MPartSashContainer.class); container.setContainerData(toSplit.getContainerData()); MPartStack childContainer = this.modelService.createModelElement(MPartStack.class); childContainer.getChildren().add((MStackElement) child); toSplit.setContainerData(null); childContainer.setContainerData(null); container.setToBeRendered(true); container.setVisible(true); container.setHorizontal(dropType == BasicDropLocation.SPLIT_LEFT || dropType == BasicDropLocation.SPLIT_RIGHT); if( dropType == BasicDropLocation.SPLIT_TOP || dropType == BasicDropLocation.SPLIT_LEFT ) { container.getChildren().add((MPartSashContainerElement) childContainer); container.getChildren().add((MPartSashContainerElement) toSplit); } else { container.getChildren().add((MPartSashContainerElement) toSplit); container.getChildren().add((MPartSashContainerElement) childContainer); } owner.getChildren().add(index, container); }
@Override public void doProcessContent(MPartSashContainer element) { WSash<N> sash = getWidget(element); if( sash == null ) { getLogger().error("Could not find widget for '"+element+"'"); //$NON-NLS-1$//$NON-NLS-2$ return; } List<WLayoutedWidget<MPartSashContainerElement>> list = new ArrayList<WLayoutedWidget<MPartSashContainerElement>>(); for (MPartSashContainerElement e : element.getChildren()) { if (e.isToBeRendered()) { WLayoutedWidget<MPartSashContainerElement> widget = engineCreateWidget(e); if (widget != null && isChildRenderedAndVisible(e)) { list.add(widget); } } } sash.addItems(list); }
stickySash.getChildren().add(perspectiveStack); stickySash.getChildren().add(stickyFolder); stickySash.setSelectedElement(perspectiveStack);
for (MPartSashContainerElement psce : psc.getChildren()) { if (psce instanceof MPartSashContainer && psce.getWidget() instanceof Composite) {
for (MPartSashContainerElement psce : psc.getChildren()) { if (psce instanceof MPartSashContainer && psce.getWidget() instanceof Composite) {
mainSash.getChildren().add(perspectiveStack); mainSash.setSelectedElement(perspectiveStack);