use of com.haulmont.cuba.gui.components.Field in project cuba by cuba-platform.
the class BulkEditorLoader method loadValidators.
protected void loadValidators(BulkEditor component, Element element) {
List<Element> validatorElements = Dom4j.elements(element, "validator");
if (!validatorElements.isEmpty()) {
List<Field.Validator> modelValidators = new ArrayList<>();
Map<String, Field.Validator> fieldValidators = new LinkedHashMap<>();
for (Element validatorElement : validatorElements) {
Field.Validator validator = loadValidator(validatorElement);
String field = validatorElement.attributeValue("field");
if (StringUtils.isNotBlank(field)) {
fieldValidators.put(field, validator);
} else {
modelValidators.add(validator);
}
}
if (!fieldValidators.isEmpty()) {
component.setFieldValidators(fieldValidators);
}
if (!modelValidators.isEmpty()) {
component.setModelValidators(modelValidators);
}
}
}
use of com.haulmont.cuba.gui.components.Field in project cuba by cuba-platform.
the class AttributeAccessSupport method visitComponent.
protected void visitComponent(DatasourceComponent component, boolean reset) {
Datasource datasource = component.getDatasource();
MetaPropertyPath propertyPath = component.getMetaPropertyPath();
if (datasource == null || datasource.getState() != Datasource.State.VALID || propertyPath == null || datasource.getItem() == null) {
return;
}
if (reset) {
component.setVisible(security.isEntityAttrReadPermitted(datasource.getMetaClass(), propertyPath.toString()));
component.setEditable(security.isEntityAttrUpdatePermitted(datasource.getMetaClass(), propertyPath.toString()));
if (component instanceof Field) {
((Field) component).setRequired(propertyPath.getMetaProperty().isMandatory());
}
}
ComponentState componentState = calculateComponentState(datasource.getItem(), propertyPath);
if (componentState.hidden) {
component.setVisible(false);
}
if (componentState.readOnly) {
component.setEditable(false);
}
if (component instanceof Field) {
if (componentState.required && component.isEditable() && component.isVisible()) {
((Field) component).setRequired(true);
}
}
}
Aggregations