private PropertyEditorFieldInfo createPropertyEditorInfo(Object instance, Field declaredField, PropertyEditorType type) { if (needToExtractValues(instance)) { return new PropertyEditorFieldInfo(declaredField.getName(), extractFieldValue(instance, declaredField), type); } else { return new PropertyEditorFieldInfo(declaredField.getName(), type); } }
private PropertyEditorFieldInfo createPropertyEditorInfo(Object instance, Field declaredField, PropertyEditorType type) { if (needToExtractValues(instance)) { return new PropertyEditorFieldInfo(declaredField.getName(), extractFieldValue(instance, declaredField), type); } else { return new PropertyEditorFieldInfo(declaredField.getName(), type); } }
public static PropertyEditorCategory convertMapToCategory(Map<String, List<String>> map) { if (map != null && !map.keySet().isEmpty()) { String categoryName = map.keySet().iterator().next(); PropertyEditorCategory category = new PropertyEditorCategory(categoryName); List<String> fields = map.get(categoryName); for (String field : fields) { category.withField(new PropertyEditorFieldInfo(field, PropertyEditorType.TEXT)); } return category; } return null; } }
public static PropertyEditorCategory convertMapToCategory(Map<String, List<String>> map) { if (map != null && !map.keySet().isEmpty()) { String categoryName = map.keySet().iterator().next(); PropertyEditorCategory category = new PropertyEditorCategory(categoryName); List<String> fields = map.get(categoryName); for (String field : fields) { category.withField(new PropertyEditorFieldInfo(field, PropertyEditorType.TEXT)); } return category; } return null; } }
@Override public void addBooleanProperty(DisplayerAttributeDef attributeDef, boolean value) { String propName = attrMapI18n.get(attributeDef); category.withField(new PropertyEditorFieldInfo(propName, Boolean.toString(value), BOOLEAN) .withKey(attributeDef.getFullId())); }
@Override public void addBooleanProperty(DisplayerAttributeDef attributeDef, boolean value) { String propName = attrMapI18n.get(attributeDef); category.withField(new PropertyEditorFieldInfo(propName, Boolean.toString(value), BOOLEAN) .withKey(attributeDef.getFullId())); }
@Override public void addColorProperty(DisplayerAttributeDef attributeDef, String color) { String propName = attrMapI18n.get(attributeDef); category.withField(new PropertyEditorFieldInfo(propName, color, COLOR) .withKey(attributeDef.getFullId())); }
@Override public void addColorProperty(DisplayerAttributeDef attributeDef, String color) { String propName = attrMapI18n.get(attributeDef); category.withField(new PropertyEditorFieldInfo(propName, color, COLOR) .withKey(attributeDef.getFullId())); }
@Override public void addListProperty(DisplayerAttributeDef attributeDef, List<String> optionList, String selectedValue) { String propName = attrMapI18n.get(attributeDef); category.withField(new PropertyEditorFieldInfo(propName, selectedValue, COMBO) .withComboValues(optionList) .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 addListProperty(DisplayerAttributeDef attributeDef, List<String> optionList, String selectedValue) { String propName = attrMapI18n.get(attributeDef); category.withField(new PropertyEditorFieldInfo(propName, selectedValue, COMBO) .withComboValues(optionList) .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())); }
private PropertyEditorCategory generatedPropertyEditor() { PropertyEditorCategory category = new PropertyEditorCategory(CommonConstants.INSTANCE.TargetDivConfiguration()); final Map<String, String> parameters = configContext.getComponentProperties(); String selectedID = parameters.get(ID_PARAMETER); category.withField(new PropertyEditorFieldInfo(CommonConstants.INSTANCE.TargetDivPlaceHolder(), selectedID == null ? "" : selectedID, PropertyEditorType.TEXT) .withKey(configContext.hashCode() + ID_PARAMETER)); propertyEditor.addExpandedCategory(category.getName()); return category; }
private PropertyEditorCategory generatedPropertyEditor() { PropertyEditorCategory category = new PropertyEditorCategory(CommonConstants.INSTANCE.TargetDivConfiguration()); final Map<String, String> parameters = configContext.getComponentProperties(); String selectedID = parameters.get(ID_PARAMETER); category.withField(new PropertyEditorFieldInfo(CommonConstants.INSTANCE.TargetDivPlaceHolder(), selectedID == null ? "" : selectedID, PropertyEditorType.TEXT) .withKey(configContext.hashCode() + ID_PARAMETER)); propertyEditor.addExpandedCategory(category.getName()); return category; }
@Test public void createLabelTest() { PropertyEditorFieldInfo field = new PropertyEditorFieldInfo("label", PropertyEditorType.TEXT); PropertyEditorItemLabel label = PropertyEditorHelper.createLabel(field); verify(label).setText("label"); }
@Before public void initialize() { List<PropertyEditorCategory> categories = new ArrayList<>(); category1 = new PropertyEditorCategory("c1"); category1.withField(new PropertyEditorFieldInfo("f1", "v1", PropertyEditorType.TEXT).withKey("f1")); categories.add(category1); category2 = new PropertyEditorCategory("c2"); category2.withField(new PropertyEditorFieldInfo("f2", "v2", PropertyEditorType.TEXT).withKey("f2")); categories.add(category2); when(layoutElement.getProperties()).thenReturn(elementProps); when(layoutElement.getPropertyCategories()).thenReturn(categories); presenter = new LayoutElementPropertiesPresenter(view, cssHelper, propertyChangedEvent, propertyClearAllEvent); presenter.edit(layoutElement); }
@Test public void isAMatchOfEmptyFilterTest() { PropertyEditorFieldInfo field = new PropertyEditorFieldInfo(); assertTrue(PropertyEditorHelper.isAMatchOfFilter("", field)); }
@Test public void sortFieldsByPriority() { PropertyEditorFieldInfo highPriority = new PropertyEditorFieldInfo("highPriority", PropertyEditorType.BOOLEAN).withPriority(1); PropertyEditorFieldInfo lowPriority = new PropertyEditorFieldInfo("lowPriority", PropertyEditorType.BOOLEAN).withPriority(10); PropertyEditorCategory category = new PropertyEditorCategory("cat1", 2) .withField(lowPriority) .withField(highPriority); PropertyEditorEvent event = new PropertyEditorEvent("event", category); assertEquals(highPriority, event.getSortedProperties().get(0).getFields().get(0)); assertEquals(lowPriority, event.getSortedProperties().get(0).getFields().get(1)); } }