Search in sources :

Example 1 with ComponentContainer

use of io.jmix.ui.component.ComponentContainer in project jmix by jmix-framework.

the class WebFilter method setFrame.

@Override
public void setFrame(Frame frame) {
    super.setFrame(frame);
    ComponentContainer layout = delegate.getLayout();
    if (layout instanceof BelongToFrame) {
        ((BelongToFrame) layout).setFrame(frame);
    }
    delegate.frameAssigned(frame);
    if (frame != null && frame.getId() == null) {
        LoggerFactory.getLogger(WebFilter.class).warn("Filter is embedded in a frame without ID");
    }
}
Also used : ComponentContainer(io.jmix.ui.component.ComponentContainer)

Example 2 with ComponentContainer

use of io.jmix.ui.component.ComponentContainer in project jmix by jmix-framework.

the class WebFilter method setDelegate.

@Autowired
protected void setDelegate(FilterDelegate delegate) {
    this.delegate = delegate;
    delegate.setFilter(this);
    ComponentContainer layout = delegate.getLayout();
    layout.setParent(this);
    component = layout.unwrapComposition(com.vaadin.ui.Component.class);
    component.setWidth(100, Sizeable.Unit.PERCENTAGE);
    component.addStyleName(FILTER_STYLENAME);
    delegate.setExpandedStateChangeListener(e -> fireExpandStateChange(e.isExpanded(), e.isUserOriginated()));
    delegate.setCaptionChangedListener(this::updateCaptions);
}
Also used : ComponentContainer(io.jmix.ui.component.ComponentContainer) AbstractComponent(io.jmix.ui.component.impl.AbstractComponent) Component(io.jmix.ui.component.Component) Autowired(org.springframework.beans.factory.annotation.Autowired)

Example 3 with ComponentContainer

use of io.jmix.ui.component.ComponentContainer in project jmix by jmix-framework.

the class DashboardModelConverter method modelToContainer.

public CanvasLayout modelToContainer(CanvasFragment fragment, DashboardLayout model) {
    CanvasLayout canvasLayout = null;
    if (model instanceof RootLayout) {
        canvasLayout = factory.createCanvasRootLayout((RootLayout) model);
        initChildren(fragment, model, (ComponentContainer) canvasLayout.getDelegate());
    } else if (model instanceof VerticalLayout) {
        canvasLayout = factory.createCanvasVerticalLayout((VerticalLayout) model);
        initChildren(fragment, model, (ComponentContainer) canvasLayout.getDelegate());
    } else if (model instanceof HorizontalLayout) {
        canvasLayout = factory.createCanvasHorizontalLayout((HorizontalLayout) model);
        initChildren(fragment, model, (ComponentContainer) canvasLayout.getDelegate());
    } else if (model instanceof CssLayout) {
        CssLayout cssLayoutModel = (CssLayout) model;
        canvasLayout = factory.createCssLayout(cssLayoutModel);
        initChildren(fragment, model, (ComponentContainer) canvasLayout.getDelegate());
    } else if (model instanceof WidgetLayout) {
        canvasLayout = factory.createCanvasWidgetLayout(fragment, ((WidgetLayout) model));
    } else if (model instanceof GridLayout) {
        GridLayout gridModel = (GridLayout) model;
        canvasLayout = factory.createCanvasGridLayout(gridModel);
        for (GridArea area : gridModel.getAreas()) {
            GridCellLayout cellLayout = area.getComponent();
            CanvasLayout childGridCanvas = modelToContainer(fragment, cellLayout);
            Integer col2 = area.getCol() + cellLayout.getColSpan();
            Integer row2 = area.getRow() + cellLayout.getRowSpan();
            ((CanvasGridLayout) canvasLayout).addComponent(childGridCanvas, area.getCol(), area.getRow(), col2, row2);
        }
    } else if (model instanceof ResponsiveLayout) {
        ResponsiveLayout respLayoutModel = (ResponsiveLayout) model;
        canvasLayout = factory.createCanvasResponsiveLayout(respLayoutModel);
        List<ResponsiveArea> sortedAreas = respLayoutModel.getAreas().stream().sorted(Comparator.comparing(ResponsiveArea::getOrder)).collect(Collectors.toList());
        for (ResponsiveArea area : sortedAreas) {
            DashboardLayout cellLayout = area.getComponent();
            CanvasLayout childGridCanvas = modelToContainer(fragment, cellLayout);
            childGridCanvas.getModel().setParent(respLayoutModel);
            canvasLayout.addComponent(childGridCanvas);
        }
    }
    if (canvasLayout == null) {
        throw new IllegalStateException("Unknown layout class: " + model.getClass());
    }
    if (model.getStyleName() != null) {
        canvasLayout.addStyleName(model.getStyleName());
    }
    canvasLayout.setWidth(model.getWidthWithUnits());
    canvasLayout.setHeight(model.getHeightWithUnits());
    if (model.getId() != null) {
        canvasLayout.setUuid(model.getId());
    }
    return canvasLayout;
}
Also used : CanvasGridLayout(io.jmix.dashboardsui.component.impl.CanvasGridLayout) ComponentContainer(io.jmix.ui.component.ComponentContainer) CanvasLayout(io.jmix.dashboardsui.component.CanvasLayout)

Aggregations

ComponentContainer (io.jmix.ui.component.ComponentContainer)3 CanvasLayout (io.jmix.dashboardsui.component.CanvasLayout)1 CanvasGridLayout (io.jmix.dashboardsui.component.impl.CanvasGridLayout)1 Component (io.jmix.ui.component.Component)1 AbstractComponent (io.jmix.ui.component.impl.AbstractComponent)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1