Search in sources :

Example 1 with CubaOrderedActionsLayout

use of com.haulmont.cuba.web.widgets.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 {
            ((FrameImplementation) 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.widgets.CubaVerticalActionsLayout) FrameImplementation(com.haulmont.cuba.gui.components.sys.FrameImplementation) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) CubaHorizontalActionsLayout(com.haulmont.cuba.web.widgets.CubaHorizontalActionsLayout) CubaOrderedActionsLayout(com.haulmont.cuba.web.widgets.CubaOrderedActionsLayout)

Aggregations

FrameImplementation (com.haulmont.cuba.gui.components.sys.FrameImplementation)1 CubaHorizontalActionsLayout (com.haulmont.cuba.web.widgets.CubaHorizontalActionsLayout)1 CubaOrderedActionsLayout (com.haulmont.cuba.web.widgets.CubaOrderedActionsLayout)1 CubaVerticalActionsLayout (com.haulmont.cuba.web.widgets.CubaVerticalActionsLayout)1 AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)1