Search in sources :

Example 31 with AbstractOrderedLayout

use of com.vaadin.ui.AbstractOrderedLayout in project jmix by jmix-framework.

the class WindowImpl method expand.

@Override
public void expand(Component childComponent) {
    if (getContainer() instanceof AbstractOrderedLayout) {
        AbstractOrderedLayout container = (AbstractOrderedLayout) getContainer();
        container.setExpandRatio(childComponent.unwrapComposition(com.vaadin.ui.Component.class), 1);
        if (getExpandDirection() == ExpandDirection.VERTICAL) {
            childComponent.setHeightFull();
        } else {
            childComponent.setWidthFull();
        }
    } else {
        throw new UnsupportedOperationException();
    }
}
Also used : AbstractComponent(com.vaadin.ui.AbstractComponent) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout)

Example 32 with AbstractOrderedLayout

use of com.vaadin.ui.AbstractOrderedLayout 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)

Example 33 with AbstractOrderedLayout

use of com.vaadin.ui.AbstractOrderedLayout in project jmix by jmix-framework.

the class AbstractCanvasLayout method setWeight.

@Override
public void setWeight(int weight) {
    Layout unwrapThis = this.unwrap(Layout.class);
    HasComponents parent = unwrapThis.getParent();
    if (parent instanceof AbstractOrderedLayout) {
        for (com.vaadin.ui.Component child : parent) {
            if (unwrapThis.equals(child)) {
                ((AbstractOrderedLayout) parent).setExpandRatio(unwrapThis, weight);
            } else if (((AbstractOrderedLayout) parent).getExpandRatio(child) == 0) {
                ((AbstractOrderedLayout) parent).setExpandRatio(child, 1);
            }
        }
    }
}
Also used : Layout(com.vaadin.ui.Layout) DashboardLayout(io.jmix.dashboards.model.visualmodel.DashboardLayout) CanvasLayout(io.jmix.dashboardsui.component.CanvasLayout) HBoxLayout(io.jmix.ui.component.HBoxLayout) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) JmixCssActionsLayout(io.jmix.ui.widget.JmixCssActionsLayout) HasComponents(com.vaadin.ui.HasComponents) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout)

Example 34 with AbstractOrderedLayout

use of com.vaadin.ui.AbstractOrderedLayout in project jmix by jmix-framework.

the class AbstractCanvasLayout method getWeight.

@Override
public int getWeight() {
    Layout unwrapThis = this.unwrap(Layout.class);
    HasComponents parent = unwrapThis.getParent();
    if (parent instanceof AbstractOrderedLayout) {
        int weight = (int) ((AbstractOrderedLayout) parent).getExpandRatio(unwrapThis);
        return weight > 0 ? weight : 1;
    } else {
        return 1;
    }
}
Also used : Layout(com.vaadin.ui.Layout) DashboardLayout(io.jmix.dashboards.model.visualmodel.DashboardLayout) CanvasLayout(io.jmix.dashboardsui.component.CanvasLayout) HBoxLayout(io.jmix.ui.component.HBoxLayout) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) JmixCssActionsLayout(io.jmix.ui.widget.JmixCssActionsLayout) HasComponents(com.vaadin.ui.HasComponents) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout)

Aggregations

AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)34 List (java.util.List)9 VerticalDropLocation (com.vaadin.shared.ui.dd.VerticalDropLocation)8 HorizontalLayout (com.vaadin.ui.HorizontalLayout)8 Label (com.vaadin.ui.Label)7 Collectors (java.util.stream.Collectors)7 Component (com.vaadin.ui.Component)6 ComponentContainer (com.vaadin.ui.ComponentContainer)6 VerticalLayout (com.vaadin.ui.VerticalLayout)6 Map (java.util.Map)6 Entry (java.util.Map.Entry)6 DCharts (org.dussan.vaadin.dcharts.DCharts)6 XYseries (org.dussan.vaadin.dcharts.base.elements.XYseries)6 DataSeries (org.dussan.vaadin.dcharts.data.DataSeries)6 Series (org.dussan.vaadin.dcharts.options.Series)6 Service (org.springframework.stereotype.Service)6 DataContainer (com.hack23.cia.service.api.DataContainer)5 LayoutBoundTransferable (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.events.LayoutBoundTransferable)5 SimpleDateFormat (java.text.SimpleDateFormat)4 Locale (java.util.Locale)4