public PropertyEditorFieldInfo createField(Map<String,String> propertyMap, CssProperty property) { String propValue = propertyMap.get(property.getName()); return createPropertyField(property, propValue == null ? "" : propValue); }
public String getName() { return this.toString().toLowerCase().replace('_', '-'); }
public CssAllowedValue parseCssAllowedValue(String property, String value) { CssProperty cssProperty = CssProperty.get(property); if (cssProperty != null) { return parseCssAllowedValue(cssProperty, value); } 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 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 static CssProperty get(String property) { if (ALL_NAMES.contains(property)) { return valueOf(property.toUpperCase().replace('-', '_')); } 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 List<PropertyFieldValidator> getValidators(CssProperty property) { List<PropertyFieldValidator> result = new ArrayList<>(); for (CssValueType cssValueType : property.getSupportedValueTypes()) { PropertyFieldValidator validator = valueTypeValidatorMap.get(cssValueType); if (validator != null) { result.add(validator); } } return result; }
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 PropertyEditorType resolveFieldType(CssProperty cssProperty) { if (cssProperty.supportsValueType(CssValueType.COLOR)) { return PropertyEditorType.COLOR; } if (!cssProperty.getAllowedValues().isEmpty()) { return PropertyEditorType.COMBO; } return PropertyEditorType.TEXT; }
public static CssProperty get(String property) { if (ALL_NAMES.contains(property)) { return valueOf(property.toUpperCase().replace('-', '_')); } 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 List<PropertyFieldValidator> getValidators(CssProperty property) { List<PropertyFieldValidator> result = new ArrayList<>(); for (CssValueType cssValueType : property.getSupportedValueTypes()) { PropertyFieldValidator validator = valueTypeValidatorMap.get(cssValueType); if (validator != null) { result.add(validator); } } return result; }
public CssValue getValue(CssProperty property) { for (CssValue cssValue : this) { if (cssValue.getProperty().equals(property.getName())) { return cssValue; } } return null; }
public String getName() { return this.toString().toLowerCase().replace('_', '-'); }
public CssAllowedValue parseCssAllowedValue(String property, String value) { CssProperty cssProperty = CssProperty.get(property); if (cssProperty != null) { return parseCssAllowedValue(cssProperty, value); } return null; }
public CssValue getValue(CssProperty property) { for (CssValue cssValue : this) { if (cssValue.getProperty().equals(property.getName())) { return cssValue; } } return null; }
public String formatCssAllowedValue(CssProperty property, CssAllowedValue value) { String i18nKey = property.toString() + "__" + value.toString(); return CssAllowedValueConstants.INSTANCE.getString(i18nKey); }
public List<CssValue> readCssValues(Map<String,String> propertyMap) { if (propertyMap == null || propertyMap.isEmpty()) { return new ArrayList<>(); } return propertyMap.entrySet().stream() .filter(entry -> CssProperty.get(entry.getKey()) != null) .map(entry -> new CssValue(entry.getKey(), entry.getValue())) .collect(Collectors.toList()); }
public PropertyEditorFieldInfo createField(Map<String,String> propertyMap, CssProperty property) { String propValue = propertyMap.get(property.getName()); return createPropertyField(property, propValue == null ? "" : propValue); }