@Override public void add(Component childComponent, int index) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } com.vaadin.ui.Component vComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class); if (ownComponents.contains(childComponent)) { int existingIndex = component.getComponentIndex(vComponent); if (index > existingIndex) { index--; } remove(childComponent); } component.addComponent(vComponent, index); component.setComponentAlignment(vComponent, toVaadinAlignment(childComponent.getAlignment())); // CAUTION here we set this as fragment for nested components if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(this); } else { attachToFrame(childComponent); } if (index == ownComponents.size()) { ownComponents.add(childComponent); } else { ownComponents.add(index, childComponent); } childComponent.setParent(this); }
protected CubaVerticalActionsLayout createFoldersPaneLayout(Component foldersPane, Label foldersLabel) { CubaVerticalActionsLayout layout = new CubaVerticalActionsLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); if (foldersLabel != null) addFoldersLabel(layout, foldersLabel); layout.addComponent(foldersPane); layout.setExpandRatio(foldersPane, 1); layout.addShortcutListener( new ShortcutListenerDelegate("apply" + foldersPane.getCubaId(), ShortcutAction.KeyCode.ENTER, null) .withHandler((sender, target) -> { if (sender == layout) { handleFoldersPaneShortcutAction(foldersPane); } })); return layout; }