From 88c6246ceb1174b68767f828921f5947a66cb199 Mon Sep 17 00:00:00 2001 From: JaniruTEC <52893617+JaniruTEC@users.noreply.github.com> Date: Mon, 3 Jul 2023 21:08:30 +0200 Subject: [PATCH 1/8] Prepared UnlockInvalidMountPointController for new feature --- .../UnlockInvalidMountPointController.java | 42 ++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java b/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java index b07e3ffde..a45960a8b 100644 --- a/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java +++ b/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java @@ -21,32 +21,30 @@ public class UnlockInvalidMountPointController implements FxController { private final Stage window; private final Vault vault; - private final AtomicReference unlockException; private final FxApplicationWindows appWindows; private final ResourceBundle resourceBundle; + private final ExceptionType exceptionType; + private final String exceptionMessage; + public FormattedLabel dialogDescription; @Inject UnlockInvalidMountPointController(@UnlockWindow Stage window, @UnlockWindow Vault vault, @UnlockWindow AtomicReference unlockException, FxApplicationWindows appWindows, ResourceBundle resourceBundle) { this.window = window; this.vault = vault; - this.unlockException = unlockException; this.appWindows = appWindows; this.resourceBundle = resourceBundle; + + var exc = unlockException.get(); + this.exceptionType = getExceptionType(exc); + this.exceptionMessage = exc.getMessage(); } @FXML public void initialize() { - var e = unlockException.get(); - var translationKey = switch (e) { - case MountPointNotSupportedException x -> "unlock.error.customPath.description.notSupported"; - case MountPointNotExistsException x -> "unlock.error.customPath.description.notExists"; - case MountPointInUseException x -> "unlock.error.customPath.description.inUse"; - default -> "unlock.error.customPath.description.generic"; - }; - dialogDescription.setFormat(resourceBundle.getString(translationKey)); - dialogDescription.setArg1(e.getMessage()); + dialogDescription.setFormat(resourceBundle.getString(exceptionType.translationKey)); + dialogDescription.setArg1(exceptionMessage); } @FXML @@ -60,4 +58,26 @@ public class UnlockInvalidMountPointController implements FxController { window.close(); } + private ExceptionType getExceptionType(Throwable unlockException) { + return switch (unlockException) { + case MountPointNotSupportedException x -> ExceptionType.NOT_SUPPORTED; + case MountPointNotExistsException x -> ExceptionType.NOT_EXISTING; + case MountPointInUseException x -> ExceptionType.IN_USE; + default -> ExceptionType.GENERIC; + }; + } + + private enum ExceptionType { + + NOT_SUPPORTED("unlock.error.customPath.description.notSupported"), + NOT_EXISTING("unlock.error.customPath.description.notExists"), + IN_USE("unlock.error.customPath.description.inUse"), + GENERIC("unlock.error.customPath.description.generic"); + + private final String translationKey; + + ExceptionType(String translationKey) { + this.translationKey = translationKey; + } + } } \ No newline at end of file From cca6d475b3602b2d081a2993520d6aebacd24645 Mon Sep 17 00:00:00 2001 From: JaniruTEC <52893617+JaniruTEC@users.noreply.github.com> Date: Mon, 3 Jul 2023 21:14:12 +0200 Subject: [PATCH 2/8] Updated UI --- .../UnlockInvalidMountPointController.java | 22 ++++++++++++++----- .../fxml/unlock_invalid_mount_point.fxml | 3 ++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java b/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java index a45960a8b..2665f5f0e 100644 --- a/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java +++ b/src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java @@ -52,12 +52,22 @@ public class UnlockInvalidMountPointController implements FxController { window.close(); } + public boolean isShowPreferences() { + return exceptionType.showPreferences; + } + @FXML public void closeAndOpenPreferences() { appWindows.showPreferencesWindow(SelectedPreferencesTab.VOLUME); window.close(); } + @FXML + public void closeAndOpenVaultOptions() { + //TODO + window.close(); + } + private ExceptionType getExceptionType(Throwable unlockException) { return switch (unlockException) { case MountPointNotSupportedException x -> ExceptionType.NOT_SUPPORTED; @@ -69,15 +79,17 @@ public class UnlockInvalidMountPointController implements FxController { private enum ExceptionType { - NOT_SUPPORTED("unlock.error.customPath.description.notSupported"), - NOT_EXISTING("unlock.error.customPath.description.notExists"), - IN_USE("unlock.error.customPath.description.inUse"), - GENERIC("unlock.error.customPath.description.generic"); + NOT_SUPPORTED("unlock.error.customPath.description.notSupported", true), + NOT_EXISTING("unlock.error.customPath.description.notExists", false), + IN_USE("unlock.error.customPath.description.inUse", false), + GENERIC("unlock.error.customPath.description.generic", true); private final String translationKey; + private final boolean showPreferences; - ExceptionType(String translationKey) { + ExceptionType(String translationKey, boolean showPreferences) { this.translationKey = translationKey; + this.showPreferences = showPreferences; } } } \ No newline at end of file diff --git a/src/main/resources/fxml/unlock_invalid_mount_point.fxml b/src/main/resources/fxml/unlock_invalid_mount_point.fxml index 1b52f568c..1646ef47a 100644 --- a/src/main/resources/fxml/unlock_invalid_mount_point.fxml +++ b/src/main/resources/fxml/unlock_invalid_mount_point.fxml @@ -46,7 +46,8 @@