Java Code Examples for com.vaadin.data.HasValue#ValueChangeEvent

The following examples show how to use com.vaadin.data.HasValue#ValueChangeEvent . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebTimeField.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void componentValueChanged(HasValue.ValueChangeEvent<LocalTime> e) {
    if (e.isUserOriginated()) {
        V value;

        try {
            value = constructModelValue();

            setValueToPresentation(convertToPresentation(value));
        } catch (ConversionException ce) {
            LoggerFactory.getLogger(WebDateField.class)
                    .trace("Unable to convert presentation value to model", ce);

            setValidationError(ce.getLocalizedMessage());
            return;
        }

        V oldValue = internalValue;
        internalValue = value;

        if (!fieldValueEquals(value, oldValue)) {
            ValueChangeEvent<V> event = new ValueChangeEvent<>(this, oldValue, value, true);
            publish(ValueChangeEvent.class, event);
        }
    }
}
 
Example 2
Source File: WebDateField.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void componentValueChanged(HasValue.ValueChangeEvent<?> e) {
    if (e.isUserOriginated()) {
        V value;

        try {
            value = constructModelValue();

            if (!checkRange(value, true)) {
                return;
            }

            LocalDateTime presentationValue = convertToPresentation(value);
            setValueToPresentation(presentationValue);
        } catch (ConversionException ce) {
            LoggerFactory.getLogger(WebDateField.class)
                    .trace("Unable to convert presentation value to model", ce);

            setValidationError(ce.getLocalizedMessage());
            return;
        }

        V oldValue = internalValue;
        internalValue = value;

        if (!fieldValueEquals(value, oldValue)) {
            ValueChangeEvent<V> event = new ValueChangeEvent<>(this, oldValue, value, true);
            publish(ValueChangeEvent.class, event);
        }
    }
}
 
Example 3
Source File: CubaTimeFieldWrapper.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void componentValueChanged(HasValue.ValueChangeEvent<LocalTime> event) {
    if (event.isUserOriginated()) {
        LocalTime oldValue = this.internalValue;

        LocalTime newValue = event.getValue();
        this.internalValue = newValue == null ? null : constructModelValue(newValue);

        setValueToPresentation(convertToPresentation(this.internalValue));

        HasValue.ValueChangeEvent<LocalTime> valueChangeEvent =
                new ValueChangeEvent<>(this, oldValue, true);
        fireEvent(valueChangeEvent);
    }
}
 
Example 4
Source File: CubaTimeFieldWrapper.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void amPmFieldValueChanged(HasValue.ValueChangeEvent<AmPm> event) {
    if (event.isUserOriginated() && getValue() != null) {
        LocalTime oldValue = this.internalValue;
        this.internalValue = convertFrom12hFormat(
                new AmPmLocalTime(oldValue, event.getValue()));

        ValueChangeEvent<LocalTime> valueChangeEvent =
                new ValueChangeEvent<>(this, oldValue, true);
        fireEvent(valueChangeEvent);
    }
}
 
Example 5
Source File: CubaEditorImpl.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected void onFieldValueChange(HasValue.ValueChangeEvent<?> ignored) {
    isEditorFieldsValid();
}