private void setupFieldValidators(final String propertyName, final PropertyEditorFieldInfo fieldInfo) { final List<PropertyFieldValidator> propertyFieldValidators = new ArrayList<>(); preference.getPropertyValidators(propertyName).stream() .forEach(validator -> propertyFieldValidators.add(new PropertyFieldValidator() { private ValidationResult validationResult; @Override public boolean validate(Object value) { validationResult = validator.validate(value); return validationResult.isValid(); } @Override public String getValidatorErrorMessage() { final List<String> validationMessages = validationResult.getMessagesBundleKeys(); if (!validationResult.isValid() && !validationMessages.isEmpty()) { return translationService.format(validationMessages.get(0)); } return ""; } })); final int validatorsSize = propertyFieldValidators.size(); final PropertyFieldValidator[] emptyValidatorsArray = new PropertyFieldValidator[validatorsSize]; final PropertyFieldValidator[] validators = propertyFieldValidators.toArray(emptyValidatorsArray); fieldInfo.withValidators(validators); }
private void setupFieldValidators(final String propertyName, final PropertyEditorFieldInfo fieldInfo) { final List<PropertyFieldValidator> propertyFieldValidators = new ArrayList<>(); preference.getPropertyValidators(propertyName).stream() .forEach(validator -> propertyFieldValidators.add(new PropertyFieldValidator() { private ValidationResult validationResult; @Override public boolean validate(Object value) { validationResult = validator.validate(value); return validationResult.isValid(); } @Override public String getValidatorErrorMessage() { final List<String> validationMessages = validationResult.getMessagesBundleKeys(); if (!validationResult.isValid() && !validationMessages.isEmpty()) { return translationService.format(validationMessages.get(0)); } return ""; } })); final int validatorsSize = propertyFieldValidators.size(); final PropertyFieldValidator[] emptyValidatorsArray = new PropertyFieldValidator[validatorsSize]; final PropertyFieldValidator[] validators = propertyFieldValidators.toArray(emptyValidatorsArray); fieldInfo.withValidators(validators); }
@Override public void addTextProperty(DisplayerAttributeDef attributeDef, String value, PropertyFieldValidator... validators) { String propName = attrMapI18n.get(attributeDef); category.withField(new PropertyEditorFieldInfo(propName, value, TEXT) .withValidators(validators) .withKey(attributeDef.getFullId())); }
@Override public void addTextProperty(String propId, String propName, String value, PropertyFieldValidator... validators) { category.withField(new PropertyEditorFieldInfo(propName, value, TEXT) .withValidators(validators) .withKey(propId)); }
@Override public void addTextProperty(DisplayerAttributeDef attributeDef, String value, PropertyFieldValidator... validators) { String propName = attrMapI18n.get(attributeDef); category.withField(new PropertyEditorFieldInfo(propName, value, TEXT) .withValidators(validators) .withKey(attributeDef.getFullId())); }
@Override public void addTextProperty(String propId, String propName, String value, PropertyFieldValidator... validators) { category.withField(new PropertyEditorFieldInfo(propName, value, TEXT) .withValidators(validators) .withKey(propId)); }
public PropertyEditorFieldInfo createPropertyField(CssProperty property, String value) { String displayName = propertyNameMapI18n.get(property); String helpText = propertyHelpMapI18n.get(property); PropertyEditorType propType = resolveFieldType(property); List<PropertyFieldValidator> validators = getValidators(property); List<CssAllowedValue> allowedValues = property.getAllowedValues(); CssAllowedValue allowedValue = parseCssAllowedValue(property, value); String currentValue = allowedValue != null ? formatCssAllowedValue(property, allowedValue) : value; PropertyEditorFieldInfo field = new PropertyEditorFieldInfo(displayName, currentValue, propType) .withKey(property.getName()); if (helpText != null) { field.withHelpInfo("", helpText); } if (validators != null && !validators.isEmpty()) { field.withValidators(validators); } if (allowedValues != null && !allowedValues.isEmpty()) { field.withComboValues(allowedValues.stream() .map(v -> formatCssAllowedValue(property, v)) .collect(Collectors.toList())); } return field; }
public PropertyEditorFieldInfo createPropertyField(CssProperty property, String value) { String displayName = propertyNameMapI18n.get(property); String helpText = propertyHelpMapI18n.get(property); PropertyEditorType propType = resolveFieldType(property); List<PropertyFieldValidator> validators = getValidators(property); List<CssAllowedValue> allowedValues = property.getAllowedValues(); CssAllowedValue allowedValue = parseCssAllowedValue(property, value); String currentValue = allowedValue != null ? formatCssAllowedValue(property, allowedValue) : value; PropertyEditorFieldInfo field = new PropertyEditorFieldInfo(displayName, currentValue, propType) .withKey(property.getName()); if (helpText != null) { field.withHelpInfo("", helpText); } if (validators != null && !validators.isEmpty()) { field.withValidators(validators); } if (allowedValues != null && !allowedValues.isEmpty()) { field.withComboValues(allowedValues.stream() .map(v -> formatCssAllowedValue(property, v)) .collect(Collectors.toList())); } return field; }