public CssAllowedValue parseCssAllowedValue(CssProperty property, String value) { for (CssAllowedValue cssAllowedValue : property.getAllowedValues()) { String targetValue = formatCssAllowedValue(property, cssAllowedValue); if (value.equals(targetValue)) { return cssAllowedValue; } } return null; }
public CssAllowedValue parseCssAllowedValue(CssProperty property, String value) { for (CssAllowedValue cssAllowedValue : property.getAllowedValues()) { String targetValue = formatCssAllowedValue(property, cssAllowedValue); if (value.equals(targetValue)) { return cssAllowedValue; } } return null; }
public PropertyEditorType resolveFieldType(CssProperty cssProperty) { if (cssProperty.supportsValueType(CssValueType.COLOR)) { return PropertyEditorType.COLOR; } if (!cssProperty.getAllowedValues().isEmpty()) { return PropertyEditorType.COMBO; } return PropertyEditorType.TEXT; }
public PropertyEditorType resolveFieldType(CssProperty cssProperty) { if (cssProperty.supportsValueType(CssValueType.COLOR)) { return PropertyEditorType.COLOR; } if (!cssProperty.getAllowedValues().isEmpty()) { return PropertyEditorType.COMBO; } return PropertyEditorType.TEXT; }
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; }