/** * Capture & process the modification events sent by the property editor */ protected void onPropertyEditorChange(@Observes PropertyEditorChangeEvent event) { PropertyEditorFieldInfo property = event.getProperty(); if (property.getEventId().equalsIgnoreCase(PROPERTY_EDITOR_ID)) { String attrKey = property.getKey(); String attrValue = event.getNewValue(); presenter.onAttributeChanged(attrKey, attrValue); } } }
private Enum<?> getEnumValue(PropertyEditorChangeEvent event, Object currentValue) { String selectedValue = event.getProperty().getCurrentStringValue(); Object[] enumConstants = ((Enum<?>) currentValue).getDeclaringClass().getEnumConstants(); Enum<?> enumValue = Arrays.stream(enumConstants) .filter(e -> e.toString().equals(selectedValue)) .map(e -> (Enum<?>) e) .findFirst().orElseThrow(RuntimeException::new); return enumValue; }
@Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (validate(property, checkBox.getValue().toString())) { checkBox.clearOldValidationErrors(); property.setCurrentStringValue(checkBox.getValue().toString()); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, checkBox.getValue().toString())); } else { checkBox.setValidationError(getValidatorErrorMessage(property, checkBox.getValue().toString())); checkBox.setValue(Boolean.valueOf(property.getCurrentStringValue())); } } });
private Enum<?> getEnumValue(PropertyEditorChangeEvent event, Object currentValue) { String selectedValue = event.getProperty().getCurrentStringValue(); Object[] enumConstants = ((Enum<?>) currentValue).getDeclaringClass().getEnumConstants(); Enum<?> enumValue = Arrays.stream(enumConstants) .filter(e -> e.toString().equals(selectedValue)) .map(e -> (Enum<?>) e) .findFirst().orElseThrow(RuntimeException::new); return enumValue; }
private void firePropertyChangedEvent(final String eventId) { final PropertyEditorFieldInfo propertyInfo = mock(PropertyEditorFieldInfo.class); doReturn(eventId).when(propertyInfo).getEventId(); doReturn("property").when(propertyInfo).getKey(); formPresenter.propertyChanged(new PropertyEditorChangeEvent(propertyInfo, "newValue")); }
/** * Capture & process the modification events sent by the property editor */ protected void onPropertyEditorChange(@Observes PropertyEditorChangeEvent event) { PropertyEditorFieldInfo property = event.getProperty(); if (property.getEventId().equalsIgnoreCase(PROPERTY_EDITOR_ID)) { String attrKey = property.getKey(); String attrValue = event.getNewValue(); presenter.onPropertyChanged(attrKey, attrValue); } } }
public void observeEditComponentEventFromPropertyEditor(@Observes PropertyEditorChangeEvent event) { PropertyEditorFieldInfo property = event.getProperty(); if (property.getEventId().equalsIgnoreCase(EditTargetDiv.PROPERTY_EDITOR_KEY)) { configContext.setComponentProperty(ID_PARAMETER, property.getCurrentStringValue()); } } }
private void firePropertyChangedEvent(final String eventId) { final PropertyEditorFieldInfo propertyInfo = mock(PropertyEditorFieldInfo.class); doReturn(eventId).when(propertyInfo).getEventId(); doReturn("property").when(propertyInfo).getKey(); formPresenter.propertyChanged(new PropertyEditorChangeEvent(propertyInfo, "newValue")); }
/** * Capture & process the modification events sent by the property editor */ protected void onPropertyEditorChange(@Observes PropertyEditorChangeEvent event) { PropertyEditorFieldInfo property = event.getProperty(); if (property.getEventId().equalsIgnoreCase(PROPERTY_EDITOR_ID)) { String attrKey = property.getKey(); String attrValue = event.getNewValue(); presenter.onPropertyChanged(attrKey, attrValue); } } }
public void observeEditComponentEventFromPropertyEditor(@Observes PropertyEditorChangeEvent event) { PropertyEditorFieldInfo property = event.getProperty(); if (property.getEventId().equalsIgnoreCase(EditTargetDiv.PROPERTY_EDITOR_KEY)) { configContext.setComponentProperty(ID_PARAMETER, property.getCurrentStringValue()); } } }
@Override public Widget widget(final PropertyEditorFieldInfo property) { final PropertyEditorColorPicker colorPicker = GWT.create(PropertyEditorColorPicker.class); String colorCode = property.getCurrentStringValue(); colorPicker.setValue(colorCode.startsWith("#") ? colorCode.substring(1) : colorCode); colorPicker.addChangeHandler(event -> { String color = colorPicker.getValue(); if (color.isEmpty() || validate(property, color)) { colorPicker.clearOldValidationErrors(); property.setCurrentStringValue(color); propertyEditorChangeEvent.fire(new PropertyEditorChangeEvent(property, "#" + color)); } else { colorPicker.setValidationError(getValidatorErrorMessage(property, color)); colorPicker.setValue(property.getCurrentStringValue()); } }); return colorPicker; } }
/** * Capture & process the modification events sent by the property editor */ protected void onPropertyEditorChange(@Observes PropertyEditorChangeEvent event) { PropertyEditorFieldInfo property = event.getProperty(); if (property.getEventId().equalsIgnoreCase(PROPERTY_EDITOR_ID)) { String attrKey = property.getKey(); String attrValue = event.getNewValue(); presenter.onAttributeChanged(attrKey, attrValue); } } }
public void observeEditComponentEventFromPropertyEditor(@Observes PropertyEditorChangeEvent event) { PropertyEditorFieldInfo property = event.getProperty(); if (property.getEventId().equalsIgnoreCase(EditScreen.PROPERTY_EDITOR_KEY)) { configContext.setComponentProperty(property.getLabel(), property.getCurrentStringValue()); } }
@Override public void onBlur(BlurEvent event) { if (validate(property, textBox.getText())) { textBox.clearOldValidationErrors(); property.setCurrentStringValue(textBox.getText()); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, textBox.getText())); } else { textBox.setValidationError(getValidatorErrorMessage(property, textBox.getText())); textBox.setText(property.getCurrentStringValue()); } } });
public void propertyChanged(@Observes PropertyEditorChangeEvent event) { if (event.getProperty().getEventId().equals(id)) { final String propertyName = event.getProperty().getKey(); final PropertyFormType propertyType = preference.getPropertyType(propertyName); Object newValue = propertyType.fromString(event.getNewValue()); Object currentValue = preference.get(propertyName); if (currentValue instanceof Enum) { newValue = getEnumValue(event, currentValue); } preference.set(propertyName, newValue); } }
public void observeEditComponentEventFromPropertyEditor(@Observes PropertyEditorChangeEvent event) { PropertyEditorFieldInfo property = event.getProperty(); if (property.getEventId().equalsIgnoreCase(EditScreen.PROPERTY_EDITOR_KEY)) { configContext.setComponentProperty(property.getLabel(), property.getCurrentStringValue()); } }
@Override public void onBlur(BlurEvent event) { if (validate(property, passwordTextBox.getText())) { passwordTextBox.clearOldValidationErrors(); property.setCurrentStringValue(passwordTextBox.getText()); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, passwordTextBox.getText())); } else { passwordTextBox.setValidationError(getValidatorErrorMessage(property, passwordTextBox.getText())); passwordTextBox.setText(property.getCurrentStringValue()); } } });
public void propertyChanged(@Observes PropertyEditorChangeEvent event) { if (event.getProperty().getEventId().equals(id)) { final String propertyName = event.getProperty().getKey(); final PropertyFormType propertyType = preference.getPropertyType(propertyName); Object newValue = propertyType.fromString(event.getNewValue()); Object currentValue = preference.get(propertyName); if (currentValue instanceof Enum) { newValue = getEnumValue(event, currentValue); } preference.set(propertyName, newValue); } }
@Override public void onChange(ChangeEvent event) { int selectedIndex = listBox.getSelectedIndex(); if (validate(property, listBox.getItemText(selectedIndex))) { listBox.clearOldValidationErrors(); property.setCurrentStringValue(listBox.getItemText(selectedIndex)); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, listBox.getItemText(selectedIndex))); } else { listBox.setValidationError(getValidatorErrorMessage(property, listBox.getItemText(selectedIndex))); listBox.setSelectItemByText(property.getCurrentStringValue()); } } }
@Override public void onKeyDown(KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { if (validate(property, passwordTextBox.getText())) { passwordTextBox.clearOldValidationErrors(); property.setCurrentStringValue(passwordTextBox.getText()); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, passwordTextBox.getText())); } else { passwordTextBox.setValidationError(getValidatorErrorMessage(property, passwordTextBox.getText())); passwordTextBox.setText(property.getCurrentStringValue()); } } } });