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); }
@Override public void detach(MPartSashContainerElement element, int x, int y, int width, int height) { // If we're showing through a placehoilder then detach it... if (element.getCurSharedRef() != null) { element = element.getCurSharedRef(); } // Determine the correct parent for the new window MWindow window = getTopLevelWindowFor(element); MPerspective thePersp = getPerspectiveFor(element); MTrimmedWindow newWindow = MBasicFactory.INSTANCE.createTrimmedWindow(); newWindow.setX(x); newWindow.setY(y); newWindow.setWidth(width); newWindow.setHeight(height); element.getParent().getChildren().remove(element); MWindowElement uiRoot = wrapElementForWindow(element); newWindow.getChildren().add(uiRoot); if (thePersp != null) { thePersp.getWindows().add(newWindow); } else if (window != null) { window.getWindows().add(newWindow); } }
toInsert.getParent().getChildren().remove(toInsert); } else {