From ce82593fc6447b63b07edad3069b9eac63831ebd Mon Sep 17 00:00:00 2001 From: Jan-Peter Klein Date: Tue, 24 Sep 2024 15:48:15 +0200 Subject: [PATCH] simplified bindings --- .../ui/mainwindow/VaultListCellController.java | 9 +++++---- .../cryptomator/ui/mainwindow/VaultListController.java | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java index 6b9461106..6afac6a11 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java @@ -21,7 +21,7 @@ public class VaultListCellController implements FxController { private final ObjectProperty vault = new SimpleObjectProperty<>(); private final ObservableValue glyph; - private final BooleanBinding compactMode; + private final ObservableValue compactMode; private AutoAnimator spinAnimation; @@ -31,7 +31,7 @@ public class VaultListCellController implements FxController { @Inject VaultListCellController(Settings settings) { this.glyph = vault.flatMap(Vault::stateProperty).map(this::getGlyphForVaultState); - this.compactMode = Bindings.createBooleanBinding(settings.compactMode::get, settings.compactMode); + this.compactMode = settings.compactMode; } public void initialize() { @@ -73,11 +73,12 @@ public class VaultListCellController implements FxController { return vault.get(); } - public BooleanBinding compactModeProperty() { + public ObservableValue compactModeProperty() { return compactMode; } + public boolean getCompactMode() { - return compactMode.get(); + return compactMode.getValue(); } public void setVault(Vault value) { diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java index a8ffde016..53b80753c 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java @@ -71,7 +71,7 @@ public class VaultListController implements FxController { private final BooleanProperty draggingVaultOver = new SimpleBooleanProperty(); private final ResourceBundle resourceBundle; private final FxApplicationWindows appWindows; - private final BooleanBinding compactMode; + private final Settings settings; public ListView vaultList; public StackPane root; @@ -102,9 +102,9 @@ public class VaultListController implements FxController { this.vaultListManager = vaultListManager; this.resourceBundle = resourceBundle; this.appWindows = appWindows; + this.settings = settings; this.emptyVaultList = Bindings.isEmpty(vaults); - this.compactMode = Bindings.createBooleanBinding(settings.compactMode::get, settings.compactMode); selectedVault.addListener(this::selectedVaultDidChange); } @@ -114,7 +114,7 @@ public class VaultListController implements FxController { vaultList.setCellFactory(cellFactory); vaultList.fixedCellSizeProperty().bind(Bindings.createDoubleBinding(() -> - compactMode.get() ? 30.0 : 60.0, compactMode)); + settings.compactMode.get() ? 30.0 : 60.0, settings.compactMode)); selectedVault.bind(vaultList.getSelectionModel().selectedItemProperty()); vaults.addListener((ListChangeListener.Change c) -> {