Search in sources :

Example 6 with ComponentPosition

use of com.haulmont.cuba.gui.components.form.ComponentPosition in project cuba by cuba-platform.

the class WebForm method addComponentInternal.

protected void addComponentInternal(Component childComponent, int column, int row, int colSpan, int rowSpan) {
    List<ComponentPosition> componentPositions = columnComponentMapping.get(column);
    int insertIndex = calculateInsertIndex(column, row, componentPositions);
    componentPositions.add(insertIndex, new ComponentPosition(childComponent, colSpan, rowSpan));
    managedComponentAssigned(childComponent);
}
Also used : ComponentPosition(com.haulmont.cuba.gui.components.form.ComponentPosition)

Example 7 with ComponentPosition

use of com.haulmont.cuba.gui.components.form.ComponentPosition in project cuba by cuba-platform.

the class WebForm method detectRowsCount.

protected int detectRowsCount(int column, boolean isCheckAreas) {
    List<ComponentPosition> componentPositions = columnComponentMapping.get(column);
    // Calculate rows count considering row spans
    int rowsCount = componentPositions.stream().map(ComponentPosition::getRowSpan).reduce(Integer::sum).orElse(0);
    List<ComponentArea> componentAreas = isCheckAreas ? calculateComponentAreas() : Collections.emptyList();
    // then increase rows count by its row span value
    for (int i = 0; i < column; i++) {
        List<ComponentPosition> positions = columnComponentMapping.get(i);
        for (ComponentPosition position : positions) {
            if (i + position.getColSpan() > column) {
                // Even though a component from a previous column overlaps current column
                // it still can be above a current component
                ComponentArea area = findComponentArea(componentAreas, position);
                if (area == null || rowsCount >= area.getStartRow()) {
                    rowsCount += position.getRowSpan();
                }
            }
        }
    }
    return rowsCount;
}
Also used : ComponentPosition(com.haulmont.cuba.gui.components.form.ComponentPosition) ComponentArea(com.haulmont.cuba.gui.components.form.ComponentArea)

Example 8 with ComponentPosition

use of com.haulmont.cuba.gui.components.form.ComponentPosition in project cuba by cuba-platform.

the class WebForm method remove.

@Override
public void remove(Component childComponent) {
    for (List<ComponentPosition> components : columnComponentMapping) {
        ComponentPosition toRemove = findComponentPosition(components, childComponent);
        if (toRemove != null) {
            components.remove(toRemove);
            reattachColumnFields();
            component.setRows(detectRowsCount());
            childComponent.setParent(null);
            break;
        }
    }
}
Also used : ComponentPosition(com.haulmont.cuba.gui.components.form.ComponentPosition)

Aggregations

ComponentPosition (com.haulmont.cuba.gui.components.form.ComponentPosition)8 MetaClass (com.haulmont.chile.core.model.MetaClass)2 DynamicAttributesUtils.getCategoryAttribute (com.haulmont.cuba.core.app.dynamicattributes.DynamicAttributesUtils.getCategoryAttribute)2 CategoryAttribute (com.haulmont.cuba.core.entity.CategoryAttribute)2 HasValueSource (com.haulmont.cuba.gui.components.data.HasValueSource)2 ContainerValueSourceProvider (com.haulmont.cuba.gui.components.data.value.ContainerValueSourceProvider)2 ComponentArea (com.haulmont.cuba.gui.components.form.ComponentArea)2 ArrayList (java.util.ArrayList)2 Element (org.dom4j.Element)2 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 GuiDevelopmentException (com.haulmont.cuba.gui.GuiDevelopmentException)1 ValueSourceProvider (com.haulmont.cuba.gui.components.data.ValueSourceProvider)1 EntityValueSource (com.haulmont.cuba.gui.components.data.meta.EntityValueSource)1 ComponentLoader (com.haulmont.cuba.gui.xml.layout.ComponentLoader)1 LayoutLoader (com.haulmont.cuba.gui.xml.layout.LayoutLoader)1