Search in sources :

Example 1 with CubaOrderedActionsLayout

use of com.haulmont.cuba.web.toolkit.ui.CubaOrderedActionsLayout in project cuba by cuba-platform.

the class WebGroupBox method add.

@Override
public void add(Component childComponent, int index) {
    if (childComponent.getParent() != null && childComponent.getParent() != this) {
        throw new IllegalStateException("Component already has parent");
    }
    AbstractOrderedLayout newContent = null;
    if (orientation == Orientation.VERTICAL && !(component.getContent() instanceof CubaVerticalActionsLayout)) {
        newContent = new CubaVerticalActionsLayout();
    } else if (orientation == Orientation.HORIZONTAL && !(component.getContent() instanceof CubaHorizontalActionsLayout)) {
        newContent = new CubaHorizontalActionsLayout();
    }
    if (newContent != null) {
        newContent.setStyleName("c-groupbox-inner");
        component.setContent(newContent);
        CubaOrderedActionsLayout currentContent = (CubaOrderedActionsLayout) component.getContent();
        newContent.setMargin(currentContent.getMargin());
        newContent.setSpacing(currentContent.isSpacing());
    }
    if (ownComponents.contains(childComponent)) {
        int existingIndex = getComponentContent().getComponentIndex(WebComponentsHelper.getComposition(childComponent));
        if (index > existingIndex) {
            index--;
        }
        remove(childComponent);
    }
    com.vaadin.ui.Component vComponent = WebComponentsHelper.getComposition(childComponent);
    getComponentContent().addComponent(vComponent, index);
    getComponentContent().setComponentAlignment(vComponent, WebWrapperUtils.toVaadinAlignment(childComponent.getAlignment()));
    if (frame != null) {
        if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) {
            ((BelongToFrame) childComponent).setFrame(frame);
        } else {
            frame.registerComponent(childComponent);
        }
    }
    if (index == ownComponents.size()) {
        ownComponents.add(childComponent);
    } else {
        ownComponents.add(index, childComponent);
    }
    childComponent.setParent(this);
}
Also used : CubaVerticalActionsLayout(com.haulmont.cuba.web.toolkit.ui.CubaVerticalActionsLayout) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) CubaHorizontalActionsLayout(com.haulmont.cuba.web.toolkit.ui.CubaHorizontalActionsLayout) CubaOrderedActionsLayout(com.haulmont.cuba.web.toolkit.ui.CubaOrderedActionsLayout)

Aggregations

CubaHorizontalActionsLayout (com.haulmont.cuba.web.toolkit.ui.CubaHorizontalActionsLayout)1 CubaOrderedActionsLayout (com.haulmont.cuba.web.toolkit.ui.CubaOrderedActionsLayout)1 CubaVerticalActionsLayout (com.haulmont.cuba.web.toolkit.ui.CubaVerticalActionsLayout)1 AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)1