Search in sources :

Example 1 with WritableIntegerValue

use of javafx.beans.value.WritableIntegerValue in project dolphin-platform by canoo.

the class FXBinderTest method testJavaFXIntegerUnidirectional.

@Test
public void testJavaFXIntegerUnidirectional() {
    Property<Integer> integerDolphinProperty = new MockedProperty<>();
    Property<Number> numberDolphinProperty = new MockedProperty<>();
    IntegerProperty integerJavaFXProperty = new SimpleIntegerProperty();
    WritableIntegerValue writableIntegerValue = new SimpleIntegerProperty();
    integerDolphinProperty.set(47);
    assertNotEquals(integerJavaFXProperty.doubleValue(), 47);
    Binding binding = FXBinder.bind(integerJavaFXProperty).to(integerDolphinProperty);
    assertEquals(integerJavaFXProperty.get(), 47);
    integerDolphinProperty.set(100);
    assertEquals(integerJavaFXProperty.get(), 100);
    integerDolphinProperty.set(null);
    assertEquals(integerJavaFXProperty.get(), 0);
    binding.unbind();
    integerDolphinProperty.set(100);
    assertEquals(integerJavaFXProperty.get(), 0);
    numberDolphinProperty.set(12);
    binding = FXBinder.bind(integerJavaFXProperty).to(numberDolphinProperty);
    assertEquals(integerJavaFXProperty.get(), 12);
    numberDolphinProperty.set(null);
    assertEquals(integerJavaFXProperty.get(), 0);
    binding.unbind();
    numberDolphinProperty.set(100);
    assertEquals(integerJavaFXProperty.get(), 0);
    integerDolphinProperty.set(47);
    binding = FXBinder.bind(writableIntegerValue).to(integerDolphinProperty);
    assertEquals(writableIntegerValue.get(), 47);
    integerDolphinProperty.set(100);
    assertEquals(writableIntegerValue.get(), 100);
    integerDolphinProperty.set(null);
    assertEquals(writableIntegerValue.get(), 0);
    binding.unbind();
    integerDolphinProperty.set(100);
    assertEquals(writableIntegerValue.get(), 0);
}
Also used : Binding(com.canoo.platform.core.functional.Binding) IntegerProperty(javafx.beans.property.IntegerProperty) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) WritableIntegerValue(javafx.beans.value.WritableIntegerValue) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) Test(org.testng.annotations.Test)

Aggregations

MockedProperty (com.canoo.dp.impl.remoting.MockedProperty)1 Binding (com.canoo.platform.core.functional.Binding)1 IntegerProperty (javafx.beans.property.IntegerProperty)1 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)1 WritableIntegerValue (javafx.beans.value.WritableIntegerValue)1 Test (org.testng.annotations.Test)1