From 1ef3e948be9e639e9659ba51f1d52e7632099924 Mon Sep 17 00:00:00 2001 From: JaniruTEC <52893617+JaniruTEC@users.noreply.github.com> Date: Mon, 4 Oct 2021 14:31:48 +0200 Subject: [PATCH 1/3] Fixes #1547: "Custom path" retains invalid value/state (#1548) Co-authored-by: Sebastian Stenzel --- .../vaultoptions/MountOptionsController.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java b/src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java index b638ad889..8739be791 100644 --- a/src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java +++ b/src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java @@ -27,6 +27,7 @@ import javafx.stage.DirectoryChooser; import javafx.stage.Stage; import javafx.util.StringConverter; import java.io.File; +import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.util.ResourceBundle; import java.util.Set; @@ -94,7 +95,9 @@ public class MountOptionsController implements FxController { driveLetterSelection.setConverter(new WinDriveLetterLabelConverter(windowsDriveLetters, resourceBundle)); driveLetterSelection.setValue(vault.getVaultSettings().winDriveLetter().get()); - if (vault.getVaultSettings().useCustomMountPath().get() && !getRestrictToStableFuseOnWindows() /* to prevent invalid states */) { + if (vault.getVaultSettings().useCustomMountPath().get() + && vault.getVaultSettings().getCustomMountPath().isPresent() + && !getRestrictToStableFuseOnWindows() /* to prevent invalid states */) { mountPoint.selectToggle(mountPointCustomDir); } else if (!Strings.isNullOrEmpty(vault.getVaultSettings().winDriveLetter().get())) { mountPoint.selectToggle(mountPointWinDriveLetter); @@ -125,25 +128,30 @@ public class MountOptionsController implements FxController { } @FXML - private void chooseCustomMountPoint() { + public void chooseCustomMountPoint() { + chooseCustomMountPointOrReset(mountPointCustomDir); + } + + private void chooseCustomMountPointOrReset(Toggle previousMountToggle) { DirectoryChooser directoryChooser = new DirectoryChooser(); directoryChooser.setTitle(resourceBundle.getString("vaultOptions.mount.mountPoint.directoryPickerTitle")); try { - directoryChooser.setInitialDirectory(Path.of(System.getProperty("user.home")).toFile()); - } catch (Exception e) { - //NO-OP + var initialDir = vault.getVaultSettings().getCustomMountPath().orElse(System.getProperty("user.home")); + directoryChooser.setInitialDirectory(Path.of(initialDir).toFile()); + } catch (InvalidPathException e) { + // no-op } File file = directoryChooser.showDialog(window); if (file != null) { vault.getVaultSettings().customMountPath().set(file.getAbsolutePath()); } else { - vault.getVaultSettings().customMountPath().set(null); + mountPoint.selectToggle(previousMountToggle); } } - private void toggleMountPoint(@SuppressWarnings("unused") ObservableValue observable, @SuppressWarnings("unused") Toggle oldValue, Toggle newValue) { + private void toggleMountPoint(@SuppressWarnings("unused") ObservableValue observable, Toggle oldValue, Toggle newValue) { if (mountPointCustomDir.equals(newValue) && Strings.isNullOrEmpty(vault.getVaultSettings().customMountPath().get())) { - chooseCustomMountPoint(); + chooseCustomMountPointOrReset(oldValue); } } From 0d240cdb2de3e8c238cae9d9acaa167ce9e4bd87 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Tue, 5 Oct 2021 10:09:09 +0200 Subject: [PATCH 2/3] simpler spacing --- src/main/resources/fxml/health_check_list.fxml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/resources/fxml/health_check_list.fxml b/src/main/resources/fxml/health_check_list.fxml index d87062e59..1edb004df 100644 --- a/src/main/resources/fxml/health_check_list.fxml +++ b/src/main/resources/fxml/health_check_list.fxml @@ -3,14 +3,12 @@ - -