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);
}
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;
}
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;
}
}
}
Aggregations