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); }
void handleChildrenRemove(@NonNull MPartSashContainer parent, Collection<MPartSashContainerElement> elements) { Iterator<MPartSashContainerElement> iterator = elements.iterator(); while (iterator.hasNext()) { MPartSashContainerElement element = (MPartSashContainerElement) iterator.next(); if (element.isToBeRendered() && element.getWidget() != null) { hideChild(parent, element); } } checkSelectedElement(parent); }
private boolean hasVisibleContent(MPartSashContainer sash) { for (MPartSashContainerElement child : sash.getChildren()) { if (child.isVisible()) { return true; } } return false; }
@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); } }
private void correctSelectedElements() { List<MPartSashContainerElement> perspChildren = perspective.getChildren(); if (perspective.getSelectedElement() == null && !perspChildren.isEmpty()) { for (MPartSashContainerElement child : perspChildren) { if (child.isToBeRendered()) { perspective.setSelectedElement(child); break; } } } for (MPartSashContainerElement child : perspChildren) { correctSelectedElements(child); } }
@Override public void insert(MPartSashContainerElement toInsert, MPartSashContainerElement relTo, int where, float ratio) { assert (toInsert != null && relTo != null); if (ratio >= 1) { warn("EModelService#insert() expects the ratio to be between (0,100)"); //$NON-NLS-1$ ratio = ratio / 100; // reduce it } assert(ratio > 0 && ratio < 1); // determine insertion order boolean insertBefore = where == ABOVE || where == LEFT_OF; boolean horizontal = where == LEFT_OF || where == RIGHT_OF; MPartSashContainer newSash = BasicFactoryImpl.eINSTANCE.createPartSashContainer(); newSash.setHorizontal(horizontal); // Maintain the existing weight in the new sash newSash.setContainerData(relTo.getContainerData()); combine(toInsert, relTo, newSash, insertBefore, ratio); }
@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); }
void handleChildrenRemove(@NonNull MCompositePart parent, Collection<MPartSashContainerElement> elements) { Iterator<MPartSashContainerElement> iterator = elements.iterator(); while (iterator.hasNext()) { MPartSashContainerElement element = iterator.next(); if (element.isToBeRendered() && element.getWidget() != null) { hideChild(parent, element); } } checkSelectedElement(parent); }
List<WLayoutedWidget<MPartSashContainerElement>> list = new ArrayList<WLayoutedWidget<MPartSashContainerElement>>(); for (MPartSashContainerElement e : element.getChildren()) { if (e.isToBeRendered()) { WLayoutedWidget<MPartSashContainerElement> w = engineCreateWidget(e); if (w != null && isChildRenderedAndVisible(e)) {
void handleChildrenAddition(@NonNull MPartSashContainer parent, Collection<MPartSashContainerElement> elements) { Iterator<MPartSashContainerElement> iterator = elements.iterator(); while (iterator.hasNext()) { MPartSashContainerElement element = (MPartSashContainerElement) iterator.next(); if (element.isToBeRendered()) { if (element.getWidget() == null) { engineCreateWidget(element); } else { childRendered(parent, element); } } } }
if (e.isToBeRendered()) { WLayoutedWidget<MPartSashContainerElement> widget = engineCreateWidget(e); if (widget != null && isChildRenderedAndVisible(e)) {