use of io.jmix.ui.xml.layout.ComponentLoader in project jmix by jmix-framework.
the class GridLayoutLoader method createSubComponents.
protected void createSubComponents(GridLayout gridLayout, Element element, int row) {
LayoutLoader loader = getLayoutLoader();
int col = 0;
for (Element subElement : element.elements()) {
ComponentLoader componentLoader = loader.createComponent(subElement);
pendingLoadComponents.add(componentLoader);
Component subComponent = componentLoader.getResultComponent();
String colspan = subElement.attributeValue("colspan");
String rowspan = subElement.attributeValue("rowspan");
if (col >= spanMatrix.length) {
Map<String, Object> params = new HashMap<>();
params.put("Grid ID", gridLayout.getId());
String rowId = element.attributeValue("id");
if (StringUtils.isNotEmpty(rowId)) {
params.put("Row ID", rowId);
} else {
params.put("Row Index", row);
}
throw new GuiDevelopmentException("Grid column count is less than number of components in grid row", context, params);
}
while (spanMatrix[col][row]) {
col++;
}
if (StringUtils.isEmpty(colspan) && StringUtils.isEmpty(rowspan)) {
addSubComponent(gridLayout, subComponent, col, row, col, row);
} else {
int cSpan = 1;
int rSpan = 1;
if (StringUtils.isNotEmpty(colspan)) {
cSpan = Integer.parseInt(colspan);
if (cSpan < 1) {
throw new GuiDevelopmentException("GridLayout colspan can not be less than 1", context, "colspan", cSpan);
}
if (cSpan == 1) {
LoggerFactory.getLogger(GridLayoutLoader.class).warn("Do not use colspan=\"1\", it will have no effect");
}
}
if (StringUtils.isNotEmpty(rowspan)) {
rSpan = Integer.parseInt(rowspan);
if (rSpan < 1) {
throw new GuiDevelopmentException("GridLayout rowspan can not be less than 1", context, "rowspan", rSpan);
}
if (rSpan == 1) {
LoggerFactory.getLogger(GridLayoutLoader.class).warn("Do not use rowspan=\"1\", it will have no effect");
}
}
fillSpanMatrix(col, row, cSpan, rSpan);
int endColumn = col + cSpan - 1;
int endRow = row + rSpan - 1;
addSubComponent(gridLayout, subComponent, col, row, endColumn, endRow);
}
col++;
}
}
use of io.jmix.ui.xml.layout.ComponentLoader in project jmix by jmix-framework.
the class LayoutLoader method createComponent.
public ComponentLoader createComponent(Element element) {
ComponentLoader loader = getLoader(element);
loader.createComponent();
return loader;
}
Aggregations