Search in sources :

Example 36 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project dolphin-platform by canoo.

the class FXBinderTest method testJavaFXStringBidirectionalWithConverter.

@Test
public void testJavaFXStringBidirectionalWithConverter() {
    Property<Double> doubleDolphinProperty = new MockedProperty<>();
    StringProperty stringJavaFXProperty = new SimpleStringProperty();
    Converter<String, Double> doubleStringConverter = s -> s == null ? null : Double.parseDouble(s);
    Converter<Double, String> stringDoubleConverter = d -> d == null ? null : d.toString();
    BidirectionalConverter<Double, String> doubleStringBidirectionalConverter = new DefaultBidirectionalConverter<>(stringDoubleConverter, doubleStringConverter);
    doubleDolphinProperty.set(0.1);
    assertNotEquals(stringJavaFXProperty.get(), "0.1");
    Binding binding = FXBinder.bind(stringJavaFXProperty).bidirectionalTo(doubleDolphinProperty, doubleStringBidirectionalConverter);
    assertEquals(stringJavaFXProperty.get(), "0.1");
    doubleDolphinProperty.set(0.2);
    assertEquals(stringJavaFXProperty.get(), "0.2");
    doubleDolphinProperty.set(null);
    assertEquals(stringJavaFXProperty.get(), null);
    stringJavaFXProperty.set("0.1");
    assertEquals(doubleDolphinProperty.get(), 0.1);
    stringJavaFXProperty.setValue("0.2");
    assertEquals(doubleDolphinProperty.get(), 0.2);
    binding.unbind();
    doubleDolphinProperty.set(0.3);
    assertEquals(stringJavaFXProperty.get(), "0.2");
}
Also used : Binding(com.canoo.platform.core.functional.Binding) Arrays(java.util.Arrays) WritableBooleanValue(javafx.beans.value.WritableBooleanValue) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) FXCollections(javafx.collections.FXCollections) Assert.assertEquals(org.testng.Assert.assertEquals) DoubleProperty(javafx.beans.property.DoubleProperty) Test(org.testng.annotations.Test) FXBinder(com.canoo.platform.remoting.client.javafx.FXBinder) DefaultBidirectionalConverter(com.canoo.dp.impl.client.javafx.DefaultBidirectionalConverter) Property(com.canoo.platform.remoting.Property) IntegerProperty(javafx.beans.property.IntegerProperty) ArrayList(java.util.ArrayList) WritableStringValue(javafx.beans.value.WritableStringValue) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) ObservableArrayList(com.canoo.dp.impl.remoting.collections.ObservableArrayList) Assert.assertNotEquals(org.testng.Assert.assertNotEquals) ObservableList(com.canoo.platform.remoting.ObservableList) Converter(com.canoo.platform.remoting.client.javafx.Converter) BidirectionalConverter(com.canoo.platform.remoting.client.javafx.BidirectionalConverter) BooleanProperty(javafx.beans.property.BooleanProperty) List(java.util.List) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) WritableIntegerValue(javafx.beans.value.WritableIntegerValue) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) Assert.assertTrue(org.testng.Assert.assertTrue) StringProperty(javafx.beans.property.StringProperty) WritableDoubleValue(javafx.beans.value.WritableDoubleValue) Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) DefaultBidirectionalConverter(com.canoo.dp.impl.client.javafx.DefaultBidirectionalConverter) Test(org.testng.annotations.Test)

Example 37 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project dolphin-platform by canoo.

the class FXWrapper method wrapStringProperty.

/**
 * Create a JavaFX {@link javafx.beans.property.StringProperty} as a wrapper for a dolphin platform property
 *
 * @param dolphinProperty the dolphin platform property
 * @return the JavaFX property
 */
public static StringProperty wrapStringProperty(final Property<String> dolphinProperty) {
    Assert.requireNonNull(dolphinProperty, "dolphinProperty");
    StringProperty property = new SimpleStringProperty();
    FXBinder.bind(property).bidirectionalTo(dolphinProperty);
    return property;
}
Also used : SimpleStringProperty(javafx.beans.property.SimpleStringProperty) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty)

Example 38 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project Smartcity-Smarthouse by TechnionYP5777.

the class ConfigConsumer method initPathDataAddingRegion.

private void initPathDataAddingRegion(final SystemCore model) {
    titleField.setPromptText(titlefDefaultText);
    // path fields
    table.setItems(tableData);
    nameCol.setCellValueFactory(new PropertyValueFactory<NamedPath, String>("name"));
    pathCol.setCellValueFactory(new PropertyValueFactory<NamedPath, String>("path"));
    cancelCol.setCellValueFactory(namedpath -> new SimpleStringProperty(""));
    cancelCol.setCellFactory(namedpath -> new ButtonCell());
    sysPathsComboBox.setItems(FXCollections.observableArrayList(getAvailablePaths(model.getFileSystem())));
    sysPathsComboBox.getItems().set(0, pathscbDefaultText);
    sysPathsComboBox.getSelectionModel().selectFirst();
    sysPathsComboBox.setOnMouseClicked(e -> addPathBtn.setVisible(true));
    setDefaultText(nameField, namefDefaultText);
    nameField.setOnMouseClicked(e -> addPathBtn.setVisible(true));
    addPathBtn.setOnMouseClicked(e -> {
        if (sysPathsComboBox.getSelectionModel().getSelectedIndex() != 0) {
            tableData.add(new NamedPath(nameField.getText(), sysPathsComboBox.getSelectionModel().getSelectedItem()));
            addPathBtn.setVisible(false);
        }
    });
    setDefaultText(unitField, unitfDefaultText);
}
Also used : SimpleStringProperty(javafx.beans.property.SimpleStringProperty)

Example 39 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project cryptomator by cryptomator.

the class VaultModuleTest method setup.

@BeforeEach
public void setup(@TempDir Path tmpDir) {
    Mockito.when(vaultSettings.mountName()).thenReturn(Bindings.createStringBinding(() -> "TEST"));
    Mockito.when(vaultSettings.usesReadOnlyMode()).thenReturn(new SimpleBooleanProperty(true));
    Mockito.when(vaultSettings.displayName()).thenReturn(new SimpleStringProperty("Vault"));
    System.setProperty("user.home", tmpDir.toString());
}
Also used : SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 40 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project trex-stateless-gui by cisco-system-traffic-generator.

the class InterfaceSelectDialogController method initTableView.

private void initTableView() {
    propertyNameColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getKey()));
    propertyValueColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getValue()));
}
Also used : SimpleStringProperty(javafx.beans.property.SimpleStringProperty)

Aggregations

SimpleStringProperty (javafx.beans.property.SimpleStringProperty)40 StringProperty (javafx.beans.property.StringProperty)14 TableColumn (javafx.scene.control.TableColumn)12 FXML (javafx.fxml.FXML)9 BigDecimal (java.math.BigDecimal)7 Button (javafx.scene.control.Button)7 IOException (java.io.IOException)5 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)5 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)5 ObservableValue (javafx.beans.value.ObservableValue)5 MockedProperty (com.canoo.dp.impl.remoting.MockedProperty)4 Binding (com.canoo.platform.core.functional.Binding)4 List (java.util.List)4 Map (java.util.Map)4 Label (javafx.scene.control.Label)4 CellDataFeatures (javafx.scene.control.TableColumn.CellDataFeatures)4 ImageView (javafx.scene.image.ImageView)4 Test (org.testng.annotations.Test)4 ChunkWrapper (com.kyj.fx.voeditor.visual.diff.ChunkWrapper)3 CompareResult (com.kyj.fx.voeditor.visual.diff.CompareResult)3