Search in sources :

Example 1 with JmixHorizontalActionsLayout

use of io.jmix.ui.widget.JmixHorizontalActionsLayout 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)

Example 2 with JmixHorizontalActionsLayout

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

the class ScrollBoxLayoutImpl 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 && !(getContent() instanceof JmixVerticalActionsLayout)) {
        newContent = new JmixVerticalActionsLayout();
        newContent.setWidth(100, Sizeable.Unit.PERCENTAGE);
    } else if (orientation == Orientation.HORIZONTAL && !(getContent() instanceof JmixHorizontalActionsLayout)) {
        newContent = new JmixHorizontalActionsLayout();
    }
    if (newContent != null) {
        newContent.setMargin((getContent()).getMargin());
        newContent.setSpacing((getContent()).isSpacing());
        newContent.setStyleName(SCROLLBOX_CONTENT_STYLENAME);
        com.vaadin.ui.Component oldContent = component.getComponent(0);
        newContent.setWidth(oldContent.getWidth(), oldContent.getWidthUnits());
        newContent.setHeight(oldContent.getHeight(), oldContent.getHeightUnits());
        component.removeAllComponents();
        component.addComponent(newContent);
        applyScrollBarsPolicy(scrollBarPolicy);
    }
    if (ownComponents.contains(childComponent)) {
        int existingIndex = getContent().getComponentIndex(ComponentsHelper.getComposition(childComponent));
        if (index > existingIndex) {
            index--;
        }
        remove(childComponent);
    }
    com.vaadin.ui.Component vComponent = ComponentsHelper.getComposition(childComponent);
    getContent().addComponent(vComponent, index);
    getContent().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 : JmixVerticalActionsLayout(io.jmix.ui.widget.JmixVerticalActionsLayout) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) JmixHorizontalActionsLayout(io.jmix.ui.widget.JmixHorizontalActionsLayout)

Aggregations

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