Search in sources :

Example 1 with WritableStringValue

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

the class FXBinderTest method testJavaFXStringUnidirectional.

@Test
public void testJavaFXStringUnidirectional() {
    Property<String> stringDolphinProperty = new MockedProperty<>();
    StringProperty stringJavaFXProperty = new SimpleStringProperty();
    WritableStringValue writableStringValue = new SimpleStringProperty();
    stringDolphinProperty.set("Hello");
    assertNotEquals(stringJavaFXProperty.get(), "Hello");
    Binding binding = FXBinder.bind(stringJavaFXProperty).to(stringDolphinProperty);
    assertEquals(stringJavaFXProperty.get(), "Hello");
    stringDolphinProperty.set("Hello JavaFX");
    assertEquals(stringJavaFXProperty.get(), "Hello JavaFX");
    stringDolphinProperty.set(null);
    assertEquals(stringJavaFXProperty.get(), null);
    binding.unbind();
    stringDolphinProperty.set("Hello JavaFX");
    assertEquals(stringJavaFXProperty.get(), null);
    binding = FXBinder.bind(writableStringValue).to(stringDolphinProperty);
    assertEquals(writableStringValue.get(), "Hello JavaFX");
    stringDolphinProperty.set("Dolphin Platform");
    assertEquals(writableStringValue.get(), "Dolphin Platform");
    stringDolphinProperty.set(null);
    assertEquals(writableStringValue.get(), null);
    binding.unbind();
    stringDolphinProperty.set("Dolphin Platform");
    assertEquals(writableStringValue.get(), null);
}
Also used : Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) WritableStringValue(javafx.beans.value.WritableStringValue) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Test(org.testng.annotations.Test)

Aggregations

MockedProperty (com.canoo.dp.impl.remoting.MockedProperty)1 Binding (com.canoo.platform.core.functional.Binding)1 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)1 StringProperty (javafx.beans.property.StringProperty)1 WritableStringValue (javafx.beans.value.WritableStringValue)1 Test (org.testng.annotations.Test)1