From 813c69f6ac77d0fea25702436c7c09b5df894114 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Tue, 5 Oct 2021 10:09:33 +0200 Subject: [PATCH] fixed broken bidi binding --- .../ui/health/CheckListCellController.java | 12 ++++++++---- src/main/resources/fxml/health_check_listcell.fxml | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/cryptomator/ui/health/CheckListCellController.java b/src/main/java/org/cryptomator/ui/health/CheckListCellController.java index d3ec4b996..5ef2926ef 100644 --- a/src/main/java/org/cryptomator/ui/health/CheckListCellController.java +++ b/src/main/java/org/cryptomator/ui/health/CheckListCellController.java @@ -5,6 +5,7 @@ import org.cryptomator.ui.common.FxController; import javax.inject.Inject; import javafx.beans.binding.Binding; +import javafx.beans.binding.Bindings; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.scene.control.CheckBox; @@ -17,7 +18,7 @@ public class CheckListCellController implements FxController { private final Binding checkRunnable; /* FXML */ - public CheckBox forRunSelectedCheckBox; + public CheckBox checkbox; @Inject public CheckListCellController() { @@ -27,9 +28,12 @@ public class CheckListCellController implements FxController { } public void initialize() { - forRunSelectedCheckBox.selectedProperty().addListener((observable, wasSelected, isSelected) -> { - if (check.get() != null) { - check.get().chosenForExecutionProperty().set(isSelected); + check.addListener((observable, oldVal, newVal) -> { + if (oldVal != null) { + Bindings.unbindBidirectional(checkbox.selectedProperty(), oldVal.chosenForExecutionProperty()); + } + if (newVal != null) { + Bindings.bindBidirectional(checkbox.selectedProperty(), newVal.chosenForExecutionProperty()); } }); } diff --git a/src/main/resources/fxml/health_check_listcell.fxml b/src/main/resources/fxml/health_check_listcell.fxml index 08155afc8..df000fa44 100644 --- a/src/main/resources/fxml/health_check_listcell.fxml +++ b/src/main/resources/fxml/health_check_listcell.fxml @@ -18,7 +18,7 @@ - +