use of com.haulmont.cuba.gui.components.data.ValueSourceProvider in project cuba by cuba-platform.
the class FormLoader method loadColumns.
protected void loadColumns(Form resultComponent, Element element) {
ValueSourceProvider valueSourceProvider = resultComponent.getValueSourceProvider();
if (element.elements("column").isEmpty()) {
Iterable<ComponentPosition> rootComponents = loadComponents(element, null, null);
Iterable<ComponentPosition> dynamicAttributeComponents = loadDynamicAttributeComponents(valueSourceProvider, null);
for (ComponentPosition component : Iterables.concat(rootComponents, dynamicAttributeComponents)) {
resultComponent.add(component.getComponent(), 0, component.getColSpan(), component.getRowSpan());
}
} else {
List<Element> columnElements = element.elements("column");
if (element.elements().size() > columnElements.size()) {
String fieldGroupId = resultComponent.getId();
Map<String, Object> params = Strings.isNullOrEmpty(fieldGroupId) ? Collections.emptyMap() : ParamsMap.of("Form ID", fieldGroupId);
throw new GuiDevelopmentException("Form component elements have to be placed within its column.", context, params);
}
resultComponent.setColumns(columnElements.size());
int colIndex = 0;
for (Element columnElement : columnElements) {
String columnWidth = loadThemeString(columnElement.attributeValue("width"));
String flexAttr = columnElement.attributeValue("flex");
Float flex = null;
if (!Strings.isNullOrEmpty(flexAttr)) {
flex = Float.parseFloat(flexAttr);
resultComponent.setColumnFlex(colIndex, flex);
}
Iterable<ComponentPosition> columnComponents = loadComponents(columnElement, columnWidth, flex);
if (colIndex == 0) {
columnComponents = Iterables.concat(columnComponents, loadDynamicAttributeComponents(valueSourceProvider, columnWidth));
}
for (ComponentPosition component : columnComponents) {
resultComponent.add(component.getComponent(), colIndex, component.getColSpan(), component.getRowSpan());
}
loadChildrenCaptionAlignment(resultComponent, columnElement, colIndex);
loadChildrenCaptionWidth(resultComponent, columnElement, colIndex);
colIndex++;
}
}
}
Aggregations