diff --git a/src/main/java/org/cryptomator/ui/health/CheckStateIconView.java b/src/main/java/org/cryptomator/ui/health/CheckStateIconView.java index cd4408fb5..4544bf00c 100644 --- a/src/main/java/org/cryptomator/ui/health/CheckStateIconView.java +++ b/src/main/java/org/cryptomator/ui/health/CheckStateIconView.java @@ -1,6 +1,7 @@ package org.cryptomator.ui.health; import com.tobiasdiez.easybind.EasyBind; +import com.tobiasdiez.easybind.Subscription; import com.tobiasdiez.easybind.optional.OptionalBinding; import org.cryptomator.cryptofs.health.api.DiagnosticResult; import org.cryptomator.ui.controls.FontAwesome5Icon; @@ -8,6 +9,7 @@ import org.cryptomator.ui.controls.FontAwesome5IconView; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; +import java.util.List; import java.util.Optional; public class CheckStateIconView extends FontAwesome5IconView { @@ -15,17 +17,20 @@ public class CheckStateIconView extends FontAwesome5IconView { private final ObjectProperty check = new SimpleObjectProperty<>(); private final OptionalBinding state; private final OptionalBinding severity; + private List subscriptions; public CheckStateIconView() { super(); this.getStyleClass().remove("glyph-icon"); this.state = EasyBind.wrapNullable(check).mapObservable(Check::stateProperty); this.severity = EasyBind.wrapNullable(check).mapObservable(Check::highestResultSeverityProperty); - glyphProperty().bind(EasyBind.combine(state, severity, this::glyphForState)); - EasyBind.includeWhen(getStyleClass(), "glyph-icon-muted", glyphProperty().isEqualTo(FontAwesome5Icon.INFO_CIRCLE)); - EasyBind.includeWhen(getStyleClass(), "glyph-icon-primary", glyphProperty().isEqualTo(FontAwesome5Icon.CHECK)); - EasyBind.includeWhen(getStyleClass(), "glyph-icon-orange", glyphProperty().isEqualTo(FontAwesome5Icon.EXCLAMATION_TRIANGLE)); - EasyBind.includeWhen(getStyleClass(), "glyph-icon-red", glyphProperty().isEqualTo(FontAwesome5Icon.TIMES)); + glyphProperty().bind(EasyBind.combine(state, severity, this::glyphForState)); //TODO: does the binding need to be stored? + this.subscriptions = List.of( + EasyBind.includeWhen(getStyleClass(), "glyph-icon-muted", glyphProperty().isEqualTo(FontAwesome5Icon.INFO_CIRCLE)), + EasyBind.includeWhen(getStyleClass(), "glyph-icon-primary", glyphProperty().isEqualTo(FontAwesome5Icon.CHECK)), + EasyBind.includeWhen(getStyleClass(), "glyph-icon-orange", glyphProperty().isEqualTo(FontAwesome5Icon.EXCLAMATION_TRIANGLE)), + EasyBind.includeWhen(getStyleClass(), "glyph-icon-red", glyphProperty().isEqualTo(FontAwesome5Icon.TIMES)) + ); } private FontAwesome5Icon glyphForState(Optional state, Optional severity) { diff --git a/src/main/java/org/cryptomator/ui/health/ResultListCellController.java b/src/main/java/org/cryptomator/ui/health/ResultListCellController.java index b74a92f7b..1dd30c766 100644 --- a/src/main/java/org/cryptomator/ui/health/ResultListCellController.java +++ b/src/main/java/org/cryptomator/ui/health/ResultListCellController.java @@ -1,6 +1,7 @@ package org.cryptomator.ui.health; import com.tobiasdiez.easybind.EasyBind; +import com.tobiasdiez.easybind.Subscription; import com.tobiasdiez.easybind.optional.OptionalBinding; import org.cryptomator.ui.common.FxController; import org.cryptomator.ui.controls.FontAwesome5Icon; @@ -18,6 +19,8 @@ import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.fxml.FXML; import javafx.scene.control.Button; +import java.util.ArrayList; +import java.util.List; // unscoped because each cell needs its own controller public class ResultListCellController implements FxController { @@ -38,6 +41,7 @@ public class ResultListCellController implements FxController { private final BooleanBinding fixable; private final BooleanBinding fixing; private final BooleanBinding fixed; + private final List subscriptions; public FontAwesome5IconView iconView; public Button fixButton; @@ -52,16 +56,19 @@ public class ResultListCellController implements FxController { this.fixable = Bindings.createBooleanBinding(this::isFixable, fixState); this.fixing = Bindings.createBooleanBinding(this::isFixing, fixState); this.fixed = Bindings.createBooleanBinding(this::isFixed, fixState); + this.subscriptions = new ArrayList<>(); } @FXML public void initialize() { // see getGlyph() for relevant glyphs: iconView.getStyleClass().remove("glyph-icon"); - EasyBind.includeWhen(iconView.getStyleClass(), "glyph-icon-muted", iconView.glyphProperty().isEqualTo(INFO_ICON)); - EasyBind.includeWhen(iconView.getStyleClass(), "glyph-icon-primary", iconView.glyphProperty().isEqualTo(GOOD_ICON)); - EasyBind.includeWhen(iconView.getStyleClass(), "glyph-icon-orange", iconView.glyphProperty().isEqualTo(WARN_ICON)); - EasyBind.includeWhen(iconView.getStyleClass(), "glyph-icon-red", iconView.glyphProperty().isEqualTo(CRIT_ICON)); + subscriptions.addAll(List.of( + EasyBind.includeWhen(iconView.getStyleClass(), "glyph-icon-muted", iconView.glyphProperty().isEqualTo(INFO_ICON)), // + EasyBind.includeWhen(iconView.getStyleClass(), "glyph-icon-primary", iconView.glyphProperty().isEqualTo(GOOD_ICON)), // + EasyBind.includeWhen(iconView.getStyleClass(), "glyph-icon-orange", iconView.glyphProperty().isEqualTo(WARN_ICON)), // + EasyBind.includeWhen(iconView.getStyleClass(), "glyph-icon-red", iconView.glyphProperty().isEqualTo(CRIT_ICON))) // + ); } @FXML diff --git a/src/main/java/org/cryptomator/ui/health/StartFailController.java b/src/main/java/org/cryptomator/ui/health/StartFailController.java index edf406213..7142bd2f5 100644 --- a/src/main/java/org/cryptomator/ui/health/StartFailController.java +++ b/src/main/java/org/cryptomator/ui/health/StartFailController.java @@ -14,6 +14,7 @@ import javafx.beans.property.StringProperty; import javafx.fxml.FXML; import javafx.stage.Stage; +@HealthCheckScoped public class StartFailController implements FxController { @Inject