Search in sources :

Example 1 with JmixOrderedActionsLayout

use of io.jmix.ui.widget.JmixOrderedActionsLayout in project jmix by jmix-framework.

the class GroupBoxImpl 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 JmixVerticalActionsLayout)) {
        newContent = new JmixVerticalActionsLayout();
    } else if (orientation == Orientation.HORIZONTAL && !(component.getContent() instanceof JmixHorizontalActionsLayout)) {
        newContent = new JmixHorizontalActionsLayout();
    }
    if (newContent != null) {
        newContent.setStyleName("jmix-groupbox-inner");
        component.setContent(newContent);
        JmixOrderedActionsLayout currentContent = (JmixOrderedActionsLayout) component.getContent();
        newContent.setMargin(currentContent.getMargin());
        newContent.setSpacing(currentContent.isSpacing());
    }
    if (ownComponents.contains(childComponent)) {
        int existingIndex = getComponentContent().getComponentIndex(ComponentsHelper.getComposition(childComponent));
        if (index > existingIndex) {
            index--;
        }
        remove(childComponent);
    }
    com.vaadin.ui.Component vComponent = ComponentsHelper.getComposition(childComponent);
    getComponentContent().addComponent(vComponent, index);
    getComponentContent().setComponentAlignment(vComponent, WrapperUtils.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 : JmixOrderedActionsLayout(io.jmix.ui.widget.JmixOrderedActionsLayout) JmixVerticalActionsLayout(io.jmix.ui.widget.JmixVerticalActionsLayout) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) JmixHorizontalActionsLayout(io.jmix.ui.widget.JmixHorizontalActionsLayout)

Aggregations

AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)1 JmixHorizontalActionsLayout (io.jmix.ui.widget.JmixHorizontalActionsLayout)1 JmixOrderedActionsLayout (io.jmix.ui.widget.JmixOrderedActionsLayout)1 JmixVerticalActionsLayout (io.jmix.ui.widget.JmixVerticalActionsLayout)1