public PropertyEditorFieldInfo createField(Map<String,String> propertyMap, CssProperty property) { String propValue = propertyMap.get(property.getName()); return createPropertyField(property, propValue == null ? "" : propValue); }
public CssValue getValue(CssProperty property) { for (CssValue cssValue : this) { if (cssValue.getProperty().equals(property.getName())) { return cssValue; } } return null; }
public CssValue getValue(CssProperty property) { for (CssValue cssValue : this) { if (cssValue.getProperty().equals(property.getName())) { return cssValue; } } return null; }
public PropertyEditorFieldInfo createField(Map<String,String> propertyMap, CssProperty property) { String propValue = propertyMap.get(property.getName()); return createPropertyField(property, propValue == null ? "" : propValue); }
public CssValue setValue(CssProperty property, String value) { CssValue cssValue = getValue(property); if (cssValue == null) { if (value != null && value.length() > 0) { cssValue = new CssValue(property.getName(), value); this.add(cssValue); return cssValue; } return null; } else { if (value != null && value.length() > 0) { cssValue.setValue(value); return cssValue; } else { this.remove(cssValue); return null; } } }
public CssValue setValue(CssProperty property, String value) { CssValue cssValue = getValue(property); if (cssValue == null) { if (value != null && value.length() > 0) { cssValue = new CssValue(property.getName(), value); this.add(cssValue); return cssValue; } return null; } else { if (value != null && value.length() > 0) { cssValue.setValue(value); return cssValue; } else { this.remove(cssValue); return null; } } }
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; }
@Test public void testReadFromMap() { Map<String,String> properties = new HashMap<>(); properties.put(CssProperty.MARGIN_TOP.getName(), "100px"); properties.put("prop1", "v1"); List<CssValue> cssValueList = cssHelper.readCssValues(properties); assertEquals(cssValueList.size(), 1); assertEquals(cssValueList.get(0).getProperty(), "margin-top"); assertEquals(cssValueList.get(0).getValue(), "100px"); }