Search in sources :

Example 6 with BidirectionalConverter

use of com.canoo.platform.remoting.client.javafx.BidirectionalConverter in project dolphin-platform by canoo.

the class AbstractNumericJavaFXBidirectionalBinder method bidirectionalTo.

@Override
public <T> Binding bidirectionalTo(final Property<T> property, BidirectionalConverter<T, Number> converter) {
    final Binding unidirectionalBinding = to(property, converter);
    final ChangeListener<Number> listener = (obs, oldVal, newVal) -> property.set(converter.convertBack(newVal));
    javaFxProperty.addListener(listener);
    return () -> {
        javaFxProperty.removeListener(listener);
        unidirectionalBinding.unbind();
    };
}
Also used : Binding(com.canoo.platform.core.functional.Binding) BidirectionalConverter(com.canoo.platform.remoting.client.javafx.BidirectionalConverter) Binding(com.canoo.platform.core.functional.Binding) Property(com.canoo.platform.remoting.Property) API(org.apiguardian.api.API) NumericJavaFXBidirectionaBinder(com.canoo.platform.remoting.client.javafx.binding.NumericJavaFXBidirectionaBinder) ChangeListener(javafx.beans.value.ChangeListener) INTERNAL(org.apiguardian.api.API.Status.INTERNAL)

Aggregations

Binding (com.canoo.platform.core.functional.Binding)6 Property (com.canoo.platform.remoting.Property)6 BidirectionalConverter (com.canoo.platform.remoting.client.javafx.BidirectionalConverter)6 DefaultBidirectionalConverter (com.canoo.dp.impl.client.javafx.DefaultBidirectionalConverter)3 MockedProperty (com.canoo.dp.impl.remoting.MockedProperty)3 ObservableArrayList (com.canoo.dp.impl.remoting.collections.ObservableArrayList)3 ObservableList (com.canoo.platform.remoting.ObservableList)3 Converter (com.canoo.platform.remoting.client.javafx.Converter)3 FXBinder (com.canoo.platform.remoting.client.javafx.FXBinder)3 ArrayList (java.util.ArrayList)3 Arrays (java.util.Arrays)3 List (java.util.List)3 BooleanProperty (javafx.beans.property.BooleanProperty)3 DoubleProperty (javafx.beans.property.DoubleProperty)3 IntegerProperty (javafx.beans.property.IntegerProperty)3 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)3 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)3 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)3 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)3 StringProperty (javafx.beans.property.StringProperty)3