diff --git a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java index 5fdaa6a8a..b80804f2e 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java @@ -16,7 +16,6 @@ import org.cryptomator.ui.common.StageInitializer; import org.cryptomator.ui.error.ErrorComponent; import org.cryptomator.ui.fxapp.PrimaryStage; import org.cryptomator.ui.migration.MigrationComponent; -import org.cryptomator.ui.removevault.RemoveVaultComponent; import org.cryptomator.ui.stats.VaultStatisticsComponent; import org.cryptomator.ui.wrongfilealert.WrongFileAlertComponent; @@ -30,7 +29,7 @@ import javafx.stage.Stage; import java.util.Map; import java.util.ResourceBundle; -@Module(subcomponents = {AddVaultWizardComponent.class, MigrationComponent.class, RemoveVaultComponent.class, VaultStatisticsComponent.class, WrongFileAlertComponent.class, ErrorComponent.class}) +@Module(subcomponents = {AddVaultWizardComponent.class, MigrationComponent.class, VaultStatisticsComponent.class, WrongFileAlertComponent.class, ErrorComponent.class}) abstract class MainWindowModule { @Provides diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailMissingVaultController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailMissingVaultController.java index 372d29040..537600616 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailMissingVaultController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailMissingVaultController.java @@ -3,10 +3,14 @@ package org.cryptomator.ui.mainwindow; import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.VaultListManager; import org.cryptomator.ui.common.FxController; -import org.cryptomator.ui.removevault.RemoveVaultComponent; +import org.cryptomator.ui.controls.CustomDialogBuilder; +import org.cryptomator.ui.controls.FontAwesome5Icon; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.inject.Inject; import javafx.beans.property.ObjectProperty; +import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.stage.FileChooser; import javafx.stage.Stage; @@ -18,16 +22,21 @@ import static org.cryptomator.common.Constants.CRYPTOMATOR_FILENAME_GLOB; @MainWindowScoped public class VaultDetailMissingVaultController implements FxController { + private static final Logger LOG = LoggerFactory.getLogger(VaultDetailMissingVaultController.class); + private final ObjectProperty vault; - private final RemoveVaultComponent.Builder removeVault; + private final ObservableList vaults; private final ResourceBundle resourceBundle; private final Stage window; @Inject - public VaultDetailMissingVaultController(ObjectProperty vault, RemoveVaultComponent.Builder removeVault, ResourceBundle resourceBundle, @MainWindow Stage window) { + public VaultDetailMissingVaultController(ObjectProperty vault, // + ObservableList vaults, // + ResourceBundle resourceBundle, // + @MainWindow Stage window) { this.vault = vault; - this.removeVault = removeVault; + this.vaults = vaults; this.resourceBundle = resourceBundle; this.window = window; } @@ -39,7 +48,20 @@ public class VaultDetailMissingVaultController implements FxController { @FXML void didClickRemoveVault() { - removeVault.vault(vault.get()).build().showRemoveVault(); + new CustomDialogBuilder() // + .setTitle(String.format(resourceBundle.getString("removeVault.title"), vault.get().getDisplayName())) // + .setMessage(resourceBundle.getString("removeVault.message")) // + .setDescription(resourceBundle.getString("removeVault.description")) // + .setIcon(FontAwesome5Icon.QUESTION) // + .setOkButtonText(resourceBundle.getString("removeVault.confirmBtn")) // + .setCancelButtonText(resourceBundle.getString("generic.button.cancel")) // + .setOkAction(v -> { + LOG.debug("Removing vault {}.", vault.get().getDisplayName()); + vaults.remove(vault.get()); + v.close(); + }) // + .setCancelAction(Stage::close) // + .buildAndShow(window); } @FXML diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailUnknownErrorController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailUnknownErrorController.java index 6e40d54b3..df2947f6b 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailUnknownErrorController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailUnknownErrorController.java @@ -3,29 +3,43 @@ package org.cryptomator.ui.mainwindow; import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.VaultListManager; import org.cryptomator.ui.common.FxController; +import org.cryptomator.ui.controls.CustomDialogBuilder; +import org.cryptomator.ui.controls.FontAwesome5Icon; import org.cryptomator.ui.fxapp.FxApplicationWindows; -import org.cryptomator.ui.removevault.RemoveVaultComponent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.inject.Inject; import javax.inject.Named; import javafx.beans.property.ObjectProperty; +import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.stage.Stage; +import java.util.ResourceBundle; @MainWindowScoped public class VaultDetailUnknownErrorController implements FxController { + private static final Logger LOG = LoggerFactory.getLogger(VaultDetailUnknownErrorController.class); + private final ObjectProperty vault; private final FxApplicationWindows appWindows; private final Stage errorWindow; - private final RemoveVaultComponent.Builder removeVault; + private final ObservableList vaults; + private final ResourceBundle resourceBundle; + private final Stage mainWindow; @Inject - public VaultDetailUnknownErrorController(ObjectProperty vault, FxApplicationWindows appWindows, @Named("errorWindow") Stage errorWindow, RemoveVaultComponent.Builder removeVault) { + public VaultDetailUnknownErrorController(@MainWindow Stage mainWindow, + ObjectProperty vault, ObservableList vaults, // + ResourceBundle resourceBundle, // + FxApplicationWindows appWindows, @Named("errorWindow") Stage errorWindow) { + this.mainWindow = mainWindow; this.vault = vault; + this.vaults = vaults; + this.resourceBundle = resourceBundle; this.appWindows = appWindows; this.errorWindow = errorWindow; - this.removeVault = removeVault; } @FXML @@ -40,6 +54,19 @@ public class VaultDetailUnknownErrorController implements FxController { @FXML void didClickRemoveVault() { - removeVault.vault(vault.get()).build().showRemoveVault(); + new CustomDialogBuilder() // + .setTitle(String.format(resourceBundle.getString("removeVault.title"), vault.get().getDisplayName())) // + .setMessage(resourceBundle.getString("removeVault.message")) // + .setDescription(resourceBundle.getString("removeVault.description")) // + .setIcon(FontAwesome5Icon.QUESTION) // + .setOkButtonText(resourceBundle.getString("removeVault.confirmBtn")) // + .setCancelButtonText(resourceBundle.getString("generic.button.cancel")) // + .setOkAction(v -> { + LOG.debug("Removing vault {}.", vault.get().getDisplayName()); + vaults.remove(vault.get()); + v.close(); + }) // + .setCancelAction(Stage::close) // + .buildAndShow(mainWindow); } } diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultListContextMenuController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultListContextMenuController.java index a6baa0baf..80d731c80 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultListContextMenuController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultListContextMenuController.java @@ -5,19 +5,24 @@ import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.VaultState; import org.cryptomator.ui.common.FxController; import org.cryptomator.ui.common.VaultService; +import org.cryptomator.ui.controls.CustomDialogBuilder; +import org.cryptomator.ui.controls.FontAwesome5Icon; import org.cryptomator.ui.fxapp.FxApplicationWindows; -import org.cryptomator.ui.removevault.RemoveVaultComponent; import org.cryptomator.ui.vaultoptions.SelectedVaultOptionsTab; import org.cryptomator.ui.vaultoptions.VaultOptionsComponent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.inject.Inject; import javafx.beans.property.ObjectProperty; import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.value.ObservableValue; +import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.stage.Stage; import java.util.EnumSet; import java.util.Objects; +import java.util.ResourceBundle; import static org.cryptomator.common.vaults.VaultState.Value.ERROR; import static org.cryptomator.common.vaults.VaultState.Value.LOCKED; @@ -28,27 +33,36 @@ import static org.cryptomator.common.vaults.VaultState.Value.UNLOCKED; @MainWindowScoped public class VaultListContextMenuController implements FxController { + private static final Logger LOG = LoggerFactory.getLogger(VaultListContextMenuController.class); + + private final ReadOnlyObjectProperty 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 ObservableValue selectedVaultState; private final ObservableValue selectedVaultPassphraseStored; private final ObservableValue selectedVaultRemovable; private final ObservableValue selectedVaultUnlockable; private final ObservableValue selectedVaultLockable; + private final ObservableList vaults; + private final ResourceBundle resourceBundle; + @Inject - VaultListContextMenuController(ObjectProperty selectedVault, @MainWindow Stage mainWindow, FxApplicationWindows appWindows, VaultService vaultService, KeychainManager keychain, RemoveVaultComponent.Builder removeVault, VaultOptionsComponent.Factory vaultOptionsWindow) { + VaultListContextMenuController(ObjectProperty selectedVault, + ObservableList vaults, // + ResourceBundle resourceBundle, // + @MainWindow Stage mainWindow, FxApplicationWindows appWindows, VaultService vaultService, KeychainManager keychain, VaultOptionsComponent.Factory vaultOptionsWindow) { this.selectedVault = selectedVault; + this.vaults = vaults; + this.resourceBundle = resourceBundle; this.mainWindow = mainWindow; this.appWindows = appWindows; this.vaultService = vaultService; this.keychain = keychain; - this.removeVault = removeVault; this.vaultOptionsWindow = vaultOptionsWindow; this.selectedVaultState = selectedVault.flatMap(Vault::stateProperty).orElse(null); @@ -65,7 +79,21 @@ public class VaultListContextMenuController implements FxController { @FXML public void didClickRemoveVault() { var vault = Objects.requireNonNull(selectedVault.get()); - removeVault.vault(vault).build().showRemoveVault(); + + new CustomDialogBuilder() // + .setTitle(String.format(resourceBundle.getString("removeVault.title"), vault.getDisplayName())) // + .setMessage(resourceBundle.getString("removeVault.message")) // + .setDescription(resourceBundle.getString("removeVault.description")) // + .setIcon(FontAwesome5Icon.QUESTION) // + .setOkButtonText(resourceBundle.getString("removeVault.confirmBtn")) // + .setCancelButtonText(resourceBundle.getString("generic.button.cancel")) // + .setOkAction(v -> { + LOG.debug("Removing vault {}.", vault.getDisplayName()); + vaults.remove(vault); + v.close(); + }) // + .setCancelAction(Stage::close) // + .buildAndShow(mainWindow); } @FXML diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java index 7a75186ce..e7318792a 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java @@ -214,8 +214,8 @@ public class VaultListController implements FxController { .setOkButtonText(resourceBundle.getString("removeVault.confirmBtn")) // .setCancelButtonText(resourceBundle.getString("generic.button.cancel")) // .setOkAction(v -> { - vaults.remove(vault); LOG.debug("Removing vault {}.", vault.getDisplayName()); + vaults.remove(vault); v.close(); }) // .setCancelAction(Stage::close) // diff --git a/src/main/resources/fxml/custom_dialog.fxml b/src/main/resources/fxml/custom_dialog.fxml index 4660872bc..3c4521c00 100644 --- a/src/main/resources/fxml/custom_dialog.fxml +++ b/src/main/resources/fxml/custom_dialog.fxml @@ -11,6 +11,7 @@ + -