mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-21 20:21:27 +00:00
refactor CustomDialog.Builder provisioning to use Dagger's Provider
This commit is contained in:
@@ -24,6 +24,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.transformation.FilteredList;
|
||||
@@ -56,7 +57,7 @@ public class FxApplicationWindows {
|
||||
private final VaultOptionsComponent.Factory vaultOptionsWindow;
|
||||
private final ShareVaultComponent.Factory shareVaultWindow;
|
||||
private final FilteredList<Window> visibleWindows;
|
||||
private final CustomDialog.Builder customDialog;
|
||||
private final Provider<CustomDialog.Builder> customDialogProvider;
|
||||
|
||||
@Inject
|
||||
public FxApplicationWindows(@PrimaryStage Stage primaryStage, //
|
||||
@@ -71,7 +72,7 @@ public class FxApplicationWindows {
|
||||
VaultOptionsComponent.Factory vaultOptionsWindow, //
|
||||
ShareVaultComponent.Factory shareVaultWindow, //
|
||||
ExecutorService executor, //
|
||||
CustomDialog.Builder customDialog) {
|
||||
Provider<CustomDialog.Builder> customDialogProvider) {
|
||||
this.primaryStage = primaryStage;
|
||||
this.trayIntegration = trayIntegration;
|
||||
this.mainWindow = mainWindow;
|
||||
@@ -85,7 +86,7 @@ public class FxApplicationWindows {
|
||||
this.vaultOptionsWindow = vaultOptionsWindow;
|
||||
this.shareVaultWindow = shareVaultWindow;
|
||||
this.visibleWindows = Window.getWindows().filtered(Window::isShowing);
|
||||
this.customDialog = customDialog;
|
||||
this.customDialogProvider = customDialogProvider;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
@@ -149,19 +150,19 @@ public class FxApplicationWindows {
|
||||
|
||||
public void showDokanySupportEndWindow() {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
customDialog.setOwner(mainWindow.get().window()) //
|
||||
.setTitleKey("dokanySupportEnd.title") //
|
||||
.setMessageKey("dokanySupportEnd.message") //
|
||||
.setDescriptionKey("dokanySupportEnd.description") //
|
||||
.setIcon(FontAwesome5Icon.QUESTION) //
|
||||
.setOkButtonKey("generic.button.close") //
|
||||
.setCancelButtonKey("dokanySupportEnd.preferencesBtn") //
|
||||
.setOkAction(Stage::close) //
|
||||
.setCancelAction(v -> {
|
||||
showPreferencesWindow(SelectedPreferencesTab.VOLUME);
|
||||
v.close();
|
||||
}) //
|
||||
.build().showAndWait();
|
||||
customDialogProvider.get().setOwner(mainWindow.get().window()) //
|
||||
.setTitleKey("dokanySupportEnd.title") //
|
||||
.setMessageKey("dokanySupportEnd.message") //
|
||||
.setDescriptionKey("dokanySupportEnd.description") //
|
||||
.setIcon(FontAwesome5Icon.QUESTION) //
|
||||
.setOkButtonKey("generic.button.close") //
|
||||
.setCancelButtonKey("dokanySupportEnd.preferencesBtn") //
|
||||
.setOkAction(Stage::close) //
|
||||
.setCancelAction(v -> {
|
||||
showPreferencesWindow(SelectedPreferencesTab.VOLUME);
|
||||
v.close();
|
||||
}) //
|
||||
.build().showAndWait();
|
||||
}, Platform::runLater);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
@@ -28,20 +29,19 @@ public class VaultDetailMissingVaultController implements FxController {
|
||||
private final ObservableList<Vault> vaults;
|
||||
private final ResourceBundle resourceBundle;
|
||||
private final Stage window;
|
||||
private final CustomDialog.Builder customDialog;
|
||||
|
||||
private final Provider<CustomDialog.Builder> customDialogProvider;
|
||||
|
||||
@Inject
|
||||
public VaultDetailMissingVaultController(ObjectProperty<Vault> vault, //
|
||||
ObservableList<Vault> vaults, //
|
||||
ResourceBundle resourceBundle, //
|
||||
@MainWindow Stage window, //
|
||||
CustomDialog.Builder customDialog) {
|
||||
Provider<CustomDialog.Builder> customDialogProvider) {
|
||||
this.vault = vault;
|
||||
this.vaults = vaults;
|
||||
this.resourceBundle = resourceBundle;
|
||||
this.window = window;
|
||||
this.customDialog = customDialog;
|
||||
this.customDialogProvider = customDialogProvider;
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -51,20 +51,20 @@ public class VaultDetailMissingVaultController implements FxController {
|
||||
|
||||
@FXML
|
||||
void didClickRemoveVault() {
|
||||
customDialog.setOwner(window) //
|
||||
.setTitleKey("removeVault.title", vault.get().getDisplayName()) //
|
||||
.setMessageKey("removeVault.message") //
|
||||
.setDescriptionKey("removeVault.description") //
|
||||
.setIcon(FontAwesome5Icon.QUESTION) //
|
||||
.setOkButtonKey("removeVault.confirmBtn") //
|
||||
.setCancelButtonKey("generic.button.cancel") //
|
||||
.setOkAction(v -> {
|
||||
LOG.debug("Removing vault {}.", vault.get().getDisplayName());
|
||||
vaults.remove(vault.get());
|
||||
v.close();
|
||||
}) //
|
||||
.setCancelAction(Stage::close) //
|
||||
.build().showAndWait();
|
||||
customDialogProvider.get().setOwner(window) //
|
||||
.setTitleKey("removeVault.title", vault.get().getDisplayName()) //
|
||||
.setMessageKey("removeVault.message") //
|
||||
.setDescriptionKey("removeVault.description") //
|
||||
.setIcon(FontAwesome5Icon.QUESTION) //
|
||||
.setOkButtonKey("removeVault.confirmBtn") //
|
||||
.setCancelButtonKey("generic.button.cancel") //
|
||||
.setOkAction(v -> {
|
||||
LOG.debug("Removing vault {}.", vault.get().getDisplayName());
|
||||
vaults.remove(vault.get());
|
||||
v.close();
|
||||
}) //
|
||||
.setCancelAction(Stage::close) //
|
||||
.build().showAndWait();
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Provider;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
@@ -26,7 +27,7 @@ public class VaultDetailUnknownErrorController implements FxController {
|
||||
private final Stage errorWindow;
|
||||
private final ObservableList<Vault> vaults;
|
||||
private final Stage mainWindow;
|
||||
private final CustomDialog.Builder customDialog;
|
||||
private final Provider<CustomDialog.Builder> customDialogProvider;
|
||||
|
||||
@Inject
|
||||
public VaultDetailUnknownErrorController(@MainWindow Stage mainWindow, //
|
||||
@@ -34,13 +35,13 @@ public class VaultDetailUnknownErrorController implements FxController {
|
||||
ObservableList<Vault> vaults, //
|
||||
FxApplicationWindows appWindows, //
|
||||
@Named("errorWindow") Stage errorWindow, //
|
||||
CustomDialog.Builder customDialog) {
|
||||
Provider<CustomDialog.Builder> customDialogProvider) {
|
||||
this.mainWindow = mainWindow;
|
||||
this.vault = vault;
|
||||
this.vaults = vaults;
|
||||
this.appWindows = appWindows;
|
||||
this.errorWindow = errorWindow;
|
||||
this.customDialog = customDialog;
|
||||
this.customDialogProvider = customDialogProvider;
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -55,19 +56,19 @@ public class VaultDetailUnknownErrorController implements FxController {
|
||||
|
||||
@FXML
|
||||
void didClickRemoveVault() {
|
||||
customDialog.setOwner(mainWindow) //
|
||||
.setTitleKey("removeVault.title", vault.get().getDisplayName()) //
|
||||
.setMessageKey("removeVault.message") //
|
||||
.setDescriptionKey("removeVault.description") //
|
||||
.setIcon(FontAwesome5Icon.QUESTION) //
|
||||
.setOkButtonKey("removeVault.confirmBtn") //
|
||||
.setCancelButtonKey("generic.button.cancel") //
|
||||
.setOkAction(v -> {
|
||||
LOG.debug("Removing vault {}.", vault.get().getDisplayName());
|
||||
vaults.remove(vault.get());
|
||||
v.close();
|
||||
}) //
|
||||
.setCancelAction(Stage::close) //
|
||||
.build().showAndWait();
|
||||
customDialogProvider.get().setOwner(mainWindow) //
|
||||
.setTitleKey("removeVault.title", vault.get().getDisplayName()) //
|
||||
.setMessageKey("removeVault.message") //
|
||||
.setDescriptionKey("removeVault.description") //
|
||||
.setIcon(FontAwesome5Icon.QUESTION) //
|
||||
.setOkButtonKey("removeVault.confirmBtn") //
|
||||
.setCancelButtonKey("generic.button.cancel") //
|
||||
.setOkAction(v -> {
|
||||
LOG.debug("Removing vault {}.", vault.get().getDisplayName());
|
||||
vaults.remove(vault.get());
|
||||
v.close();
|
||||
}) //
|
||||
.setCancelAction(Stage::close) //
|
||||
.build().showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
@@ -47,18 +48,18 @@ public class VaultListContextMenuController implements FxController {
|
||||
private final ObservableValue<Boolean> selectedVaultUnlockable;
|
||||
private final ObservableValue<Boolean> selectedVaultLockable;
|
||||
private final ObservableList<Vault> vaults;
|
||||
private final CustomDialog.Builder customDialog;
|
||||
private final Provider<CustomDialog.Builder> customDialogProvider;
|
||||
|
||||
|
||||
@Inject
|
||||
VaultListContextMenuController(ObjectProperty<Vault> selectedVault,
|
||||
VaultListContextMenuController(ObjectProperty<Vault> selectedVault, //
|
||||
ObservableList<Vault> vaults, //
|
||||
@MainWindow Stage mainWindow, //
|
||||
FxApplicationWindows appWindows, //
|
||||
VaultService vaultService, //
|
||||
KeychainManager keychain, //
|
||||
VaultOptionsComponent.Factory vaultOptionsWindow, //
|
||||
CustomDialog.Builder customDialog) {
|
||||
Provider<CustomDialog.Builder> customDialogProvider) {
|
||||
this.selectedVault = selectedVault;
|
||||
this.vaults = vaults;
|
||||
this.mainWindow = mainWindow;
|
||||
@@ -66,7 +67,7 @@ public class VaultListContextMenuController implements FxController {
|
||||
this.vaultService = vaultService;
|
||||
this.keychain = keychain;
|
||||
this.vaultOptionsWindow = vaultOptionsWindow;
|
||||
this.customDialog = customDialog;
|
||||
this.customDialogProvider = customDialogProvider;
|
||||
|
||||
this.selectedVaultState = selectedVault.flatMap(Vault::stateProperty).orElse(null);
|
||||
this.selectedVaultPassphraseStored = selectedVault.map(this::isPasswordStored).orElse(false);
|
||||
@@ -82,19 +83,19 @@ public class VaultListContextMenuController implements FxController {
|
||||
@FXML
|
||||
public void didClickRemoveVault() {
|
||||
var vault = Objects.requireNonNull(selectedVault.get());
|
||||
customDialog.setOwner(mainWindow) //
|
||||
.setTitleKey("removeVault.title", vault.getDisplayName()) //
|
||||
.setMessageKey("removeVault.message") //
|
||||
.setDescriptionKey("removeVault.description") //
|
||||
.setIcon(FontAwesome5Icon.QUESTION) //
|
||||
.setOkButtonKey("removeVault.confirmBtn") //
|
||||
.setCancelButtonKey("generic.button.cancel") //
|
||||
.setOkAction(v -> {
|
||||
LOG.debug("Removing vault {}.", vault.getDisplayName());
|
||||
vaults.remove(vault);
|
||||
v.close();
|
||||
}) //
|
||||
.build().showAndWait();
|
||||
customDialogProvider.get().setOwner(mainWindow) //
|
||||
.setTitleKey("removeVault.title", vault.getDisplayName()) //
|
||||
.setMessageKey("removeVault.message") //
|
||||
.setDescriptionKey("removeVault.description") //
|
||||
.setIcon(FontAwesome5Icon.QUESTION) //
|
||||
.setOkButtonKey("removeVault.confirmBtn") //
|
||||
.setCancelButtonKey("generic.button.cancel") //
|
||||
.setOkAction(v -> {
|
||||
LOG.debug("Removing vault {}.", vault.getDisplayName());
|
||||
vaults.remove(vault);
|
||||
v.close();
|
||||
}) //
|
||||
.build().showAndWait();
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -154,4 +155,6 @@ public class VaultListContextMenuController implements FxController {
|
||||
public boolean isSelectedVaultPassphraseStored() {
|
||||
return selectedVaultPassphraseStored.getValue();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.binding.BooleanBinding;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
@@ -72,7 +73,7 @@ public class VaultListController implements FxController {
|
||||
private final ResourceBundle resourceBundle;
|
||||
private final FxApplicationWindows appWindows;
|
||||
private final ObservableValue<Double> cellSize;
|
||||
private final CustomDialog.Builder customDialog;
|
||||
private final Provider<CustomDialog.Builder> customDialogProvider;
|
||||
|
||||
public ListView<Vault> vaultList;
|
||||
public StackPane root;
|
||||
@@ -92,7 +93,7 @@ public class VaultListController implements FxController {
|
||||
ResourceBundle resourceBundle, //
|
||||
FxApplicationWindows appWindows, //
|
||||
Settings settings, //
|
||||
CustomDialog.Builder customDialog) {
|
||||
Provider<CustomDialog.Builder> customDialogProvider) {
|
||||
this.mainWindow = mainWindow;
|
||||
this.vaults = vaults;
|
||||
this.selectedVault = selectedVault;
|
||||
@@ -102,7 +103,7 @@ public class VaultListController implements FxController {
|
||||
this.vaultListManager = vaultListManager;
|
||||
this.resourceBundle = resourceBundle;
|
||||
this.appWindows = appWindows;
|
||||
this.customDialog = customDialog;
|
||||
this.customDialogProvider = customDialogProvider;
|
||||
|
||||
this.emptyVaultList = Bindings.isEmpty(vaults);
|
||||
|
||||
@@ -210,20 +211,20 @@ public class VaultListController implements FxController {
|
||||
private void pressedShortcutToRemoveVault() {
|
||||
final var vault = selectedVault.get();
|
||||
if (vault != null && EnumSet.of(LOCKED, MISSING, ERROR, NEEDS_MIGRATION).contains(vault.getState())) {
|
||||
customDialog.setOwner(mainWindow) //
|
||||
.setTitleKey("removeVault.title", vault.getDisplayName()) //
|
||||
.setMessageKey("removeVault.message") //
|
||||
.setDescriptionKey("removeVault.description") //
|
||||
.setIcon(FontAwesome5Icon.QUESTION) //
|
||||
.setOkButtonKey("removeVault.confirmBtn") //
|
||||
.setCancelButtonKey("generic.button.cancel") //
|
||||
.setOkAction(v -> {
|
||||
LOG.debug("Removing vault {}.", vault.getDisplayName());
|
||||
vaults.remove(vault);
|
||||
v.close();
|
||||
}) //
|
||||
.setCancelAction(Stage::close) //
|
||||
.build().showAndWait();
|
||||
customDialogProvider.get().setOwner(mainWindow) //
|
||||
.setTitleKey("removeVault.title", vault.getDisplayName()) //
|
||||
.setMessageKey("removeVault.message") //
|
||||
.setDescriptionKey("removeVault.description") //
|
||||
.setIcon(FontAwesome5Icon.QUESTION) //
|
||||
.setOkButtonKey("removeVault.confirmBtn") //
|
||||
.setCancelButtonKey("generic.button.cancel") //
|
||||
.setOkAction(v -> {
|
||||
LOG.debug("Removing vault {}.", vault.getDisplayName());
|
||||
vaults.remove(vault);
|
||||
v.close();
|
||||
}) //
|
||||
.setCancelAction(Stage::close) //
|
||||
.build().showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.cryptomator.ui.controls.CustomDialog;
|
||||
import org.cryptomator.ui.controls.FontAwesome5Icon;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javafx.application.Application;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.fxml.FXML;
|
||||
@@ -27,7 +28,7 @@ public class SupporterCertificateController implements FxController {
|
||||
private final Stage window;
|
||||
private final LicenseHolder licenseHolder;
|
||||
private final Settings settings;
|
||||
private final CustomDialog.Builder customDialog;
|
||||
private final Provider<CustomDialog.Builder> customDialogProvider;
|
||||
|
||||
@FXML
|
||||
private TextArea supporterCertificateField;
|
||||
@@ -37,12 +38,12 @@ public class SupporterCertificateController implements FxController {
|
||||
@PreferencesWindow Stage window, //
|
||||
LicenseHolder licenseHolder, //
|
||||
Settings settings, //
|
||||
CustomDialog.Builder customDialog) {
|
||||
Provider<CustomDialog.Builder> customDialogProvider) {
|
||||
this.application = application;
|
||||
this.window = window;
|
||||
this.licenseHolder = licenseHolder;
|
||||
this.settings = settings;
|
||||
this.customDialog = customDialog;
|
||||
this.customDialogProvider = customDialogProvider;
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -89,19 +90,18 @@ public class SupporterCertificateController implements FxController {
|
||||
|
||||
@FXML
|
||||
void didClickRemoveCert() {
|
||||
customDialog.setOwner(window) //
|
||||
.setTitleKey("removeCert.title") //
|
||||
.setMessageKey("removeCert.message") //
|
||||
.setDescriptionKey("removeCert.description") //
|
||||
.setIcon(FontAwesome5Icon.QUESTION) //
|
||||
.setOkButtonKey("removeCert.confirmBtn") //
|
||||
.setCancelButtonKey("generic.button.cancel")
|
||||
.setOkAction(v -> {
|
||||
settings.licenseKey.set(null);
|
||||
v.close();
|
||||
}) //
|
||||
.setCancelAction(Stage::close) //
|
||||
.build().showAndWait();
|
||||
customDialogProvider.get().setOwner(window) //
|
||||
.setTitleKey("removeCert.title") //
|
||||
.setMessageKey("removeCert.message") //
|
||||
.setDescriptionKey("removeCert.description") //
|
||||
.setIcon(FontAwesome5Icon.QUESTION) //
|
||||
.setOkButtonKey("removeCert.confirmBtn") //
|
||||
.setCancelButtonKey("generic.button.cancel").setOkAction(v -> {
|
||||
settings.licenseKey.set(null);
|
||||
v.close();
|
||||
}) //
|
||||
.setCancelAction(Stage::close) //
|
||||
.build().showAndWait();
|
||||
}
|
||||
|
||||
public LicenseHolder getLicenseHolder() {
|
||||
|
||||
Reference in New Issue
Block a user