simplified bindings

This commit is contained in:
Jan-Peter Klein 2024-09-24 15:48:15 +02:00
parent 7771181e15
commit ce82593fc6
No known key found for this signature in database
GPG Key ID: 90EDA3A7C822FD0E
2 changed files with 8 additions and 7 deletions

View File

@ -21,7 +21,7 @@ public class VaultListCellController implements FxController {
private final ObjectProperty<Vault> vault = new SimpleObjectProperty<>();
private final ObservableValue<FontAwesome5Icon> glyph;
private final BooleanBinding compactMode;
private final ObservableValue<Boolean> 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<Boolean> compactModeProperty() {
return compactMode;
}
public boolean getCompactMode() {
return compactMode.get();
return compactMode.getValue();
}
public void setVault(Vault value) {

View File

@ -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<Vault> 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<? extends Vault> c) -> {