mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-20 19:51:27 +00:00
bump OpenJFX to version 19
replaced EasyBind with `ObservableValue.map()` where possible
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package org.cryptomator.ui.common;
|
||||
|
||||
import com.tobiasdiez.easybind.EasyBind;
|
||||
import org.cryptomator.ui.controls.FontAwesome5IconView;
|
||||
import org.cryptomator.ui.controls.NiceSecurePasswordField;
|
||||
|
||||
@@ -42,7 +41,7 @@ public class NewPasswordController implements FxController {
|
||||
passwordStrength.bind(Bindings.createIntegerBinding(() -> strengthRater.computeRate(passwordField.getCharacters()), passwordField.textProperty()));
|
||||
|
||||
passwordStrengthLabel.graphicProperty().bind(Bindings.createObjectBinding(this::getIconViewForPasswordStrengthLabel, passwordField.textProperty(), passwordStrength));
|
||||
passwordStrengthLabel.textProperty().bind(EasyBind.map(passwordStrength, strengthRater::getStrengthDescription));
|
||||
passwordStrengthLabel.textProperty().bind(passwordStrength.map(strengthRater::getStrengthDescription));
|
||||
|
||||
BooleanBinding passwordsMatch = Bindings.createBooleanBinding(this::passwordFieldsMatch, passwordField.textProperty(), reenterField.textProperty());
|
||||
BooleanBinding reenterFieldNotEmpty = reenterField.textProperty().isNotEmpty();
|
||||
|
||||
@@ -3,12 +3,12 @@ package org.cryptomator.ui.health;
|
||||
import com.tobiasdiez.easybind.EasyBind;
|
||||
import com.tobiasdiez.easybind.EasyObservableList;
|
||||
import com.tobiasdiez.easybind.Subscription;
|
||||
import com.tobiasdiez.easybind.optional.OptionalBinding;
|
||||
import org.cryptomator.cryptofs.health.api.DiagnosticResult;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.beans.binding.Binding;
|
||||
import javafx.beans.binding.BooleanExpression;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
@@ -22,15 +22,15 @@ public class CheckDetailController implements FxController {
|
||||
|
||||
private final EasyObservableList<Result> results;
|
||||
private final ObjectProperty<Check> check;
|
||||
private final OptionalBinding<Check.CheckState> checkState;
|
||||
private final Binding<String> checkName;
|
||||
private final Binding<Boolean> checkRunning;
|
||||
private final Binding<Boolean> checkScheduled;
|
||||
private final Binding<Boolean> checkFinished;
|
||||
private final Binding<Boolean> checkSkipped;
|
||||
private final Binding<Boolean> checkSucceeded;
|
||||
private final Binding<Boolean> checkFailed;
|
||||
private final Binding<Boolean> checkCancelled;
|
||||
private final ObservableValue<Check.CheckState> checkState;
|
||||
private final ObservableValue<String> checkName;
|
||||
private final BooleanExpression checkRunning;
|
||||
private final BooleanExpression checkScheduled;
|
||||
private final BooleanExpression checkFinished;
|
||||
private final BooleanExpression checkSkipped;
|
||||
private final BooleanExpression checkSucceeded;
|
||||
private final BooleanExpression checkFailed;
|
||||
private final BooleanExpression checkCancelled;
|
||||
private final Binding<Number> countOfWarnSeverity;
|
||||
private final Binding<Number> countOfCritSeverity;
|
||||
private final Binding<Boolean> warnOrCritsExist;
|
||||
@@ -44,15 +44,15 @@ public class CheckDetailController implements FxController {
|
||||
this.resultListCellFactory = resultListCellFactory;
|
||||
this.results = EasyBind.wrapList(FXCollections.observableArrayList());
|
||||
this.check = selectedTask;
|
||||
this.checkState = EasyBind.wrapNullable(selectedTask).mapObservable(Check::stateProperty);
|
||||
this.checkName = EasyBind.wrapNullable(selectedTask).map(Check::getName).orElse("");
|
||||
this.checkRunning = checkState.map(Check.CheckState.RUNNING::equals).orElse(false);
|
||||
this.checkScheduled = checkState.map(Check.CheckState.SCHEDULED::equals).orElse(false);
|
||||
this.checkSkipped = checkState.map(Check.CheckState.SKIPPED::equals).orElse(false);
|
||||
this.checkSucceeded = checkState.map(Check.CheckState.SUCCEEDED::equals).orElse(false);
|
||||
this.checkFailed = checkState.map(Check.CheckState.ERROR::equals).orElse(false);
|
||||
this.checkCancelled = checkState.map(Check.CheckState.CANCELLED::equals).orElse(false);
|
||||
this.checkFinished = EasyBind.combine(checkSucceeded, checkFailed, checkCancelled, (a, b, c) -> a || b || c);
|
||||
this.checkState = selectedTask.flatMap(Check::stateProperty);
|
||||
this.checkName = selectedTask.map(Check::getName).orElse("");
|
||||
this.checkRunning = BooleanExpression.booleanExpression(checkState.map(Check.CheckState.RUNNING::equals).orElse(false));
|
||||
this.checkScheduled = BooleanExpression.booleanExpression(checkState.map(Check.CheckState.SCHEDULED::equals).orElse(false));
|
||||
this.checkSkipped =BooleanExpression.booleanExpression(checkState.map(Check.CheckState.SKIPPED::equals).orElse(false));
|
||||
this.checkSucceeded = BooleanExpression.booleanExpression(checkState.map(Check.CheckState.SUCCEEDED::equals).orElse(false));
|
||||
this.checkFailed = BooleanExpression.booleanExpression(checkState.map(Check.CheckState.ERROR::equals).orElse(false));
|
||||
this.checkCancelled = BooleanExpression.booleanExpression(checkState.map(Check.CheckState.CANCELLED::equals).orElse(false));
|
||||
this.checkFinished = checkSucceeded.or(checkFailed).or(checkCancelled);
|
||||
this.countOfWarnSeverity = results.reduce(countSeverity(DiagnosticResult.Severity.WARN));
|
||||
this.countOfCritSeverity = results.reduce(countSeverity(DiagnosticResult.Severity.CRITICAL));
|
||||
this.warnOrCritsExist = EasyBind.combine(checkSucceeded, countOfWarnSeverity, countOfCritSeverity, (suceeded, warns, crits) -> suceeded && (warns.longValue() > 0 || crits.longValue() > 0) );
|
||||
@@ -84,7 +84,7 @@ public class CheckDetailController implements FxController {
|
||||
return checkName.getValue();
|
||||
}
|
||||
|
||||
public Binding<String> checkNameProperty() {
|
||||
public ObservableValue<String> checkNameProperty() {
|
||||
return checkName;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class CheckDetailController implements FxController {
|
||||
return checkRunning.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> checkRunningProperty() {
|
||||
public BooleanExpression checkRunningProperty() {
|
||||
return checkRunning;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class CheckDetailController implements FxController {
|
||||
return checkFinished.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> checkFinishedProperty() {
|
||||
public BooleanExpression checkFinishedProperty() {
|
||||
return checkFinished;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class CheckDetailController implements FxController {
|
||||
return checkScheduled.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> checkScheduledProperty() {
|
||||
public BooleanExpression checkScheduledProperty() {
|
||||
return checkScheduled;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class CheckDetailController implements FxController {
|
||||
return checkSkipped.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> checkSkippedProperty() {
|
||||
public BooleanExpression checkSkippedProperty() {
|
||||
return checkSkipped;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class CheckDetailController implements FxController {
|
||||
return checkSucceeded.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> checkSucceededProperty() {
|
||||
public BooleanExpression checkSucceededProperty() {
|
||||
return checkSucceeded;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class CheckDetailController implements FxController {
|
||||
return checkFailed.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> checkFailedProperty() {
|
||||
public BooleanExpression checkFailedProperty() {
|
||||
return checkFailed;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class CheckDetailController implements FxController {
|
||||
return warnOrCritsExist.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> checkCancelledProperty() {
|
||||
public BooleanExpression checkCancelledProperty() {
|
||||
return checkCancelled;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
package org.cryptomator.ui.health;
|
||||
|
||||
import com.tobiasdiez.easybind.EasyBind;
|
||||
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.beans.value.ObservableValue;
|
||||
import javafx.scene.control.CheckBox;
|
||||
|
||||
public class CheckListCellController implements FxController {
|
||||
|
||||
|
||||
private final ObjectProperty<Check> check;
|
||||
private final Binding<String> checkName;
|
||||
private final Binding<Boolean> checkRunnable;
|
||||
private final ObservableValue<Boolean> checkRunnable;
|
||||
private final ObservableValue<String> checkName;
|
||||
|
||||
/* FXML */
|
||||
public CheckBox checkbox;
|
||||
@@ -23,8 +22,8 @@ public class CheckListCellController implements FxController {
|
||||
@Inject
|
||||
public CheckListCellController() {
|
||||
check = new SimpleObjectProperty<>();
|
||||
checkRunnable = EasyBind.wrapNullable(check).mapObservable(Check::stateProperty).map(Check.CheckState.RUNNABLE::equals).orElse(false);
|
||||
checkName = EasyBind.wrapNullable(check).map(Check::getName).orElse("");
|
||||
checkRunnable = check.flatMap(Check::stateProperty).map(Check.CheckState.RUNNABLE::equals).orElse(false);
|
||||
checkName = check.map(Check::getName).orElse("");
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
@@ -50,7 +49,7 @@ public class CheckListCellController implements FxController {
|
||||
check.set(c);
|
||||
}
|
||||
|
||||
public Binding<String> checkNameProperty() {
|
||||
public ObservableValue<String> checkNameProperty() {
|
||||
return checkName;
|
||||
}
|
||||
|
||||
@@ -58,7 +57,7 @@ public class CheckListCellController implements FxController {
|
||||
return checkName.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> checkRunnableProperty() {
|
||||
public ObservableValue<Boolean> checkRunnableProperty() {
|
||||
return checkRunnable;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import javafx.beans.binding.ObjectBinding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.value.ObservableObjectValue;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.util.Duration;
|
||||
@@ -38,7 +39,7 @@ public class ResultListCellController implements FxController {
|
||||
private final Logger LOG = LoggerFactory.getLogger(ResultListCellController.class);
|
||||
|
||||
private final ObjectProperty<Result> result;
|
||||
private final ObservableObjectValue<DiagnosticResult.Severity> severity;
|
||||
private final ObservableValue<DiagnosticResult.Severity> severity;
|
||||
private final Binding<String> description;
|
||||
private final ResultFixApplier fixApplier;
|
||||
private final ObservableObjectValue<Result.FixState> fixState;
|
||||
@@ -62,7 +63,7 @@ public class ResultListCellController implements FxController {
|
||||
@Inject
|
||||
public ResultListCellController(ResultFixApplier fixApplier, ResourceBundle resourceBundle) {
|
||||
this.result = new SimpleObjectProperty<>(null);
|
||||
this.severity = EasyBind.wrapNullable(result).map(r -> r.diagnosis().getSeverity()).asOrdinary();
|
||||
this.severity = result.map(Result::diagnosis).map(DiagnosticResult::getSeverity);
|
||||
this.description = EasyBind.wrapNullable(result).map(Result::getDescription).orElse("");
|
||||
this.fixApplier = fixApplier;
|
||||
this.fixState = EasyBind.wrapNullable(result).mapObservable(Result::fixState).asOrdinary();
|
||||
@@ -83,10 +84,10 @@ public class ResultListCellController implements FxController {
|
||||
@FXML
|
||||
public void initialize() {
|
||||
// see getGlyph() for relevant glyphs:
|
||||
subscriptions.addAll(List.of(EasyBind.includeWhen(severityView.getStyleClass(), "glyph-icon-muted", Bindings.equal(severity, DiagnosticResult.Severity.INFO)), //
|
||||
EasyBind.includeWhen(severityView.getStyleClass(), "glyph-icon-primary", Bindings.equal(severity, DiagnosticResult.Severity.GOOD)), //
|
||||
EasyBind.includeWhen(severityView.getStyleClass(), "glyph-icon-orange", Bindings.equal(severity, DiagnosticResult.Severity.WARN)), //
|
||||
EasyBind.includeWhen(severityView.getStyleClass(), "glyph-icon-red", Bindings.equal(severity, DiagnosticResult.Severity.CRITICAL)) //
|
||||
subscriptions.addAll(List.of(EasyBind.includeWhen(severityView.getStyleClass(), "glyph-icon-muted", severity.map(DiagnosticResult.Severity.INFO::equals).orElse(false)), //
|
||||
EasyBind.includeWhen(severityView.getStyleClass(), "glyph-icon-primary", severity.map(DiagnosticResult.Severity.GOOD::equals).orElse(false)), //
|
||||
EasyBind.includeWhen(severityView.getStyleClass(), "glyph-icon-orange", severity.map(DiagnosticResult.Severity.WARN::equals).orElse(false)), //
|
||||
EasyBind.includeWhen(severityView.getStyleClass(), "glyph-icon-red", severity.map(DiagnosticResult.Severity.CRITICAL::equals).orElse(false)) //
|
||||
));
|
||||
var animation = Animations.createDiscrete360Rotation(fixView);
|
||||
this.fixRunningRotator = AutoAnimator.animate(animation) //
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.cryptomator.ui.mainwindow;
|
||||
|
||||
import com.tobiasdiez.easybind.EasyBind;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.common.vaults.VaultState;
|
||||
import org.cryptomator.ui.common.Animations;
|
||||
@@ -11,10 +10,10 @@ import org.cryptomator.ui.controls.FontAwesome5IconView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.application.Application;
|
||||
import javafx.beans.binding.Binding;
|
||||
import javafx.beans.binding.BooleanBinding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.fxml.FXML;
|
||||
|
||||
@MainWindowScoped
|
||||
@@ -22,7 +21,7 @@ public class VaultDetailController implements FxController {
|
||||
|
||||
private final ReadOnlyObjectProperty<Vault> vault;
|
||||
private final Application application;
|
||||
private final Binding<FontAwesome5Icon> glyph;
|
||||
private final ObservableValue<FontAwesome5Icon> glyph;
|
||||
private final BooleanBinding anyVaultSelected;
|
||||
|
||||
private AutoAnimator spinAnimation;
|
||||
@@ -35,15 +34,13 @@ public class VaultDetailController implements FxController {
|
||||
VaultDetailController(ObjectProperty<Vault> vault, Application application) {
|
||||
this.vault = vault;
|
||||
this.application = application;
|
||||
this.glyph = EasyBind.select(vault) //
|
||||
.selectObject(Vault::stateProperty) //
|
||||
.map(this::getGlyphForVaultState);
|
||||
this.glyph = vault.flatMap(Vault::stateProperty).map(this::getGlyphForVaultState);
|
||||
this.anyVaultSelected = vault.isNotNull();
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
this.spinAnimation = AutoAnimator.animate(Animations.createDiscrete360Rotation(vaultStateView)) //
|
||||
.onCondition(EasyBind.select(vault).selectObject(Vault::stateProperty).map(VaultState.Value.PROCESSING::equals)) //
|
||||
.onCondition(vault.flatMap(Vault::stateProperty).map(VaultState.Value.PROCESSING::equals).orElse(false)) //
|
||||
.afterStop(() -> vaultStateView.setRotate(0)) //
|
||||
.build();
|
||||
}
|
||||
@@ -77,7 +74,7 @@ public class VaultDetailController implements FxController {
|
||||
return vault.get();
|
||||
}
|
||||
|
||||
public Binding<FontAwesome5Icon> glyphProperty() {
|
||||
public ObservableValue<FontAwesome5Icon> glyphProperty() {
|
||||
return glyph;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.cryptomator.ui.mainwindow;
|
||||
|
||||
import com.tobiasdiez.easybind.EasyBind;
|
||||
import org.cryptomator.common.keychain.KeychainManager;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
@@ -34,7 +33,8 @@ public class VaultDetailLockedController implements FxController {
|
||||
this.keychain = keychain;
|
||||
this.mainWindow = mainWindow;
|
||||
if (keychain.isSupported() && !keychain.isLocked()) {
|
||||
this.passwordSaved = BooleanExpression.booleanExpression(EasyBind.select(vault).selectObject(v -> keychain.getPassphraseStoredProperty(v.getId())));
|
||||
var stored = vault.flatMap(v -> keychain.getPassphraseStoredProperty(v.getId())).orElse(false);
|
||||
this.passwordSaved = BooleanExpression.booleanExpression(stored);
|
||||
} else {
|
||||
this.passwordSaved = new SimpleBooleanProperty(false);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.cryptomator.ui.mainwindow;
|
||||
|
||||
import com.tobiasdiez.easybind.EasyBind;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.common.vaults.VaultState;
|
||||
import org.cryptomator.ui.common.Animations;
|
||||
@@ -10,15 +9,15 @@ import org.cryptomator.ui.controls.FontAwesome5Icon;
|
||||
import org.cryptomator.ui.controls.FontAwesome5IconView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.beans.binding.Binding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
|
||||
// unscoped because each cell needs its own controller
|
||||
public class VaultListCellController implements FxController {
|
||||
|
||||
private final ObjectProperty<Vault> vault = new SimpleObjectProperty<>();
|
||||
private final Binding<FontAwesome5Icon> glyph;
|
||||
private final ObservableValue<FontAwesome5Icon> glyph;
|
||||
|
||||
private AutoAnimator spinAnimation;
|
||||
|
||||
@@ -27,14 +26,12 @@ public class VaultListCellController implements FxController {
|
||||
|
||||
@Inject
|
||||
VaultListCellController() {
|
||||
this.glyph = EasyBind.select(vault) //
|
||||
.selectObject(Vault::stateProperty) //
|
||||
.map(this::getGlyphForVaultState);
|
||||
this.glyph = vault.flatMap(Vault::stateProperty).map(this::getGlyphForVaultState);
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
this.spinAnimation = AutoAnimator.animate(Animations.createDiscrete360Rotation(vaultStateView)) //
|
||||
.onCondition(EasyBind.select(vault).selectObject(Vault::stateProperty).map(VaultState.Value.PROCESSING::equals)) //
|
||||
.onCondition(vault.flatMap(Vault::stateProperty).map(VaultState.Value.PROCESSING::equals).orElse(false)) //
|
||||
.afterStop(() -> vaultStateView.setRotate(0)) //
|
||||
.build();
|
||||
}
|
||||
@@ -55,7 +52,7 @@ public class VaultListCellController implements FxController {
|
||||
|
||||
/* Getter/Setter */
|
||||
|
||||
public Binding<FontAwesome5Icon> glyphProperty() {
|
||||
public ObservableValue<FontAwesome5Icon> glyphProperty() {
|
||||
return glyph;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.cryptomator.ui.mainwindow;
|
||||
|
||||
import com.tobiasdiez.easybind.EasyBind;
|
||||
import com.tobiasdiez.easybind.optional.ObservableOptionalValue;
|
||||
import com.tobiasdiez.easybind.optional.OptionalBinding;
|
||||
import org.cryptomator.common.keychain.KeychainManager;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.common.vaults.VaultState;
|
||||
@@ -14,33 +11,39 @@ import org.cryptomator.ui.vaultoptions.SelectedVaultOptionsTab;
|
||||
import org.cryptomator.ui.vaultoptions.VaultOptionsComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.beans.binding.Binding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.stage.Stage;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.cryptomator.common.vaults.VaultState.Value.*;
|
||||
import static org.cryptomator.common.vaults.VaultState.Value.ERROR;
|
||||
import static org.cryptomator.common.vaults.VaultState.Value.LOCKED;
|
||||
import static org.cryptomator.common.vaults.VaultState.Value.MISSING;
|
||||
import static org.cryptomator.common.vaults.VaultState.Value.NEEDS_MIGRATION;
|
||||
import static org.cryptomator.common.vaults.VaultState.Value.UNLOCKED;
|
||||
|
||||
@MainWindowScoped
|
||||
public class VaultListContextMenuController implements FxController {
|
||||
|
||||
private final ObservableOptionalValue<Vault> selectedVault;
|
||||
private final ReadOnlyObjectProperty<Vault> selectedVault;
|
||||
private final Stage mainWindow;
|
||||
private final FxApplicationWindows appWindows;
|
||||
private final VaultService vaultService;
|
||||
private final KeychainManager keychain;
|
||||
private final RemoveVaultComponent.Builder removeVault;
|
||||
private final VaultOptionsComponent.Factory vaultOptionsWindow;
|
||||
private final OptionalBinding<VaultState.Value> selectedVaultState;
|
||||
private final Binding<Boolean> selectedVaultPassphraseStored;
|
||||
private final Binding<Boolean> selectedVaultRemovable;
|
||||
private final Binding<Boolean> selectedVaultUnlockable;
|
||||
private final Binding<Boolean> selectedVaultLockable;
|
||||
private final ObservableValue<VaultState.Value> selectedVaultState;
|
||||
private final ObservableValue<Boolean> selectedVaultPassphraseStored;
|
||||
private final ObservableValue<Boolean> selectedVaultRemovable;
|
||||
private final ObservableValue<Boolean> selectedVaultUnlockable;
|
||||
private final ObservableValue<Boolean> selectedVaultLockable;
|
||||
|
||||
@Inject
|
||||
VaultListContextMenuController(ObjectProperty<Vault> selectedVault, @MainWindow Stage mainWindow, FxApplicationWindows appWindows, VaultService vaultService, KeychainManager keychain, RemoveVaultComponent.Builder removeVault, VaultOptionsComponent.Factory vaultOptionsWindow) {
|
||||
this.selectedVault = EasyBind.wrapNullable(selectedVault);
|
||||
this.selectedVault = selectedVault;
|
||||
this.mainWindow = mainWindow;
|
||||
this.appWindows = appWindows;
|
||||
this.vaultService = vaultService;
|
||||
@@ -48,8 +51,8 @@ public class VaultListContextMenuController implements FxController {
|
||||
this.removeVault = removeVault;
|
||||
this.vaultOptionsWindow = vaultOptionsWindow;
|
||||
|
||||
this.selectedVaultState = this.selectedVault.mapObservable(Vault::stateProperty);
|
||||
this.selectedVaultPassphraseStored = this.selectedVault.map(this::isPasswordStored).orElse(false);
|
||||
this.selectedVaultState = selectedVault.flatMap(Vault::stateProperty).orElse(null);
|
||||
this.selectedVaultPassphraseStored = selectedVault.map(this::isPasswordStored).orElse(false);
|
||||
this.selectedVaultRemovable = selectedVaultState.map(EnumSet.of(LOCKED, MISSING, ERROR, NEEDS_MIGRATION)::contains).orElse(false);
|
||||
this.selectedVaultUnlockable = selectedVaultState.map(LOCKED::equals).orElse(false);
|
||||
this.selectedVaultLockable = selectedVaultState.map(UNLOCKED::equals).orElse(false);
|
||||
@@ -61,40 +64,37 @@ public class VaultListContextMenuController implements FxController {
|
||||
|
||||
@FXML
|
||||
public void didClickRemoveVault() {
|
||||
selectedVault.ifValuePresent(v -> {
|
||||
removeVault.vault(v).build().showRemoveVault();
|
||||
});
|
||||
var vault = Objects.requireNonNull(selectedVault.get());
|
||||
removeVault.vault(vault).build().showRemoveVault();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void didClickShowVaultOptions() {
|
||||
selectedVault.ifValuePresent(v -> {
|
||||
vaultOptionsWindow.create(v).showVaultOptionsWindow(SelectedVaultOptionsTab.ANY);
|
||||
});
|
||||
var vault = Objects.requireNonNull(selectedVault.get());
|
||||
vaultOptionsWindow.create(vault).showVaultOptionsWindow(SelectedVaultOptionsTab.ANY);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void didClickUnlockVault() {
|
||||
selectedVault.ifValuePresent(v -> {
|
||||
appWindows.startUnlockWorkflow(v, mainWindow);
|
||||
});
|
||||
var vault = Objects.requireNonNull(selectedVault.get());
|
||||
appWindows.startUnlockWorkflow(vault, mainWindow);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void didClickLockVault() {
|
||||
selectedVault.ifValuePresent(v -> {
|
||||
appWindows.startLockWorkflow(v, mainWindow);
|
||||
});
|
||||
var vault = Objects.requireNonNull(selectedVault.get());
|
||||
appWindows.startLockWorkflow(vault, mainWindow);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void didClickRevealVault() {
|
||||
selectedVault.ifValuePresent(vaultService::reveal);
|
||||
var vault = Objects.requireNonNull(selectedVault.get());
|
||||
vaultService.reveal(vault);
|
||||
}
|
||||
|
||||
// Getter and Setter
|
||||
|
||||
public Binding<Boolean> selectedVaultUnlockableProperty() {
|
||||
public ObservableValue<Boolean> selectedVaultUnlockableProperty() {
|
||||
return selectedVaultUnlockable;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class VaultListContextMenuController implements FxController {
|
||||
return selectedVaultUnlockable.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> selectedVaultLockableProperty() {
|
||||
public ObservableValue<Boolean> selectedVaultLockableProperty() {
|
||||
return selectedVaultLockable;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class VaultListContextMenuController implements FxController {
|
||||
return selectedVaultLockable.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> selectedVaultRemovableProperty() {
|
||||
public ObservableValue<Boolean> selectedVaultRemovableProperty() {
|
||||
return selectedVaultRemovable;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class VaultListContextMenuController implements FxController {
|
||||
return selectedVaultRemovable.getValue();
|
||||
}
|
||||
|
||||
public Binding<Boolean> selectedVaultPassphraseStoredProperty() {
|
||||
public ObservableValue<Boolean> selectedVaultPassphraseStoredProperty() {
|
||||
return selectedVaultPassphraseStored;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user