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; }
@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); }
toInsert.setContainerData("" + ratio); //$NON-NLS-1$ relTo.setContainerData("" + (10000 - ratio)); //$NON-NLS-1$ psc.setHorizontal(true); break; case SWT.RIGHT: relTo.setContainerData("" + ratio); //$NON-NLS-1$ toInsert.setContainerData("" + (10000 - ratio)); //$NON-NLS-1$ psc.setHorizontal(true); break; case SWT.TOP: toInsert.setContainerData("" + ratio); //$NON-NLS-1$ relTo.setContainerData("" + (10000 - ratio)); //$NON-NLS-1$ psc.setHorizontal(false); break; case SWT.BOTTOM: relTo.setContainerData("" + ratio); //$NON-NLS-1$ toInsert.setContainerData("" + (10000 - ratio)); //$NON-NLS-1$ psc.setHorizontal(false); break;
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); }
perspectives = new ArrayList<>(); mainSash = modelService.createModelElement(MPartSashContainer.class); mainSash.setHorizontal(true);
stickySash.setHorizontal(true);