Browse Source

Merge branch 'develop' into release/1.6.0

Armin Schrenk 3 years ago
parent
commit
2f868304e4

+ 8 - 4
src/main/java/org/cryptomator/ui/health/CheckListCellController.java

@@ -5,6 +5,7 @@ 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.scene.control.CheckBox;
@@ -17,7 +18,7 @@ public class CheckListCellController implements FxController {
 	private final Binding<Boolean> checkRunnable;
 
 	/* FXML */
-	public CheckBox forRunSelectedCheckBox;
+	public CheckBox checkbox;
 
 	@Inject
 	public CheckListCellController() {
@@ -27,9 +28,12 @@ public class CheckListCellController implements FxController {
 	}
 
 	public void initialize() {
-		forRunSelectedCheckBox.selectedProperty().addListener((observable, wasSelected, isSelected) -> {
-			if (check.get() != null) {
-				check.get().chosenForExecutionProperty().set(isSelected);
+		check.addListener((observable, oldVal, newVal) -> {
+			if (oldVal != null) {
+				Bindings.unbindBidirectional(checkbox.selectedProperty(), oldVal.chosenForExecutionProperty());
+			}
+			if (newVal != null) {
+				Bindings.bindBidirectional(checkbox.selectedProperty(), newVal.chosenForExecutionProperty());
 			}
 		});
 	}

+ 16 - 8
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<? extends Toggle> observable, @SuppressWarnings("unused") Toggle oldValue, Toggle newValue) {
+	private void toggleMountPoint(@SuppressWarnings("unused") ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
 		if (mountPointCustomDir.equals(newValue) && Strings.isNullOrEmpty(vault.getVaultSettings().customMountPath().get())) {
-			chooseCustomMountPoint();
+			chooseCustomMountPointOrReset(oldValue);
 		}
 	}
 

+ 1 - 4
src/main/resources/fxml/health_check_list.fxml

@@ -3,14 +3,12 @@
 <?import javafx.geometry.Insets?>
 <?import javafx.scene.control.Button?>
 <?import javafx.scene.control.ButtonBar?>
-<?import javafx.scene.control.CheckBox?>
 <?import javafx.scene.control.Label?>
 <?import javafx.scene.control.ListView?>
 <?import javafx.scene.layout.HBox?>
 <?import javafx.scene.layout.StackPane?>
 <?import javafx.scene.layout.VBox?>
 <?import java.lang.Integer?>
-<?import javafx.scene.layout.Region?>
 <VBox xmlns:fx="http://javafx.com/fxml"
 	  xmlns="http://javafx.com/javafx"
 	  fx:controller="org.cryptomator.ui.health.CheckListController"
@@ -28,9 +26,8 @@
 			<ListView fx:id="checksListView" VBox.vgrow="ALWAYS" minWidth="175" maxWidth="175"/>
 			<VBox alignment="CENTER" visible="${!controller.mainRunStarted}"  managed="${!controller.mainRunStarted}" HBox.hgrow="ALWAYS" spacing="12">
 				<Label text="%health.checkList.description" wrapText="true"/>
-				<HBox alignment="CENTER">
+				<HBox alignment="CENTER" spacing="6">
 					<Button onAction="#selectAllChecks" text="%health.checkList.selectAllButton" />
-					<Region prefWidth="6"/>
 					<Button onAction="#deselectAllChecks" text="%health.checkList.deselectAllButton" />
 				</HBox>
 			</VBox>

+ 1 - 1
src/main/resources/fxml/health_check_listcell.fxml

@@ -18,7 +18,7 @@
 	</padding>
 
 	<StackPane minWidth="20" minHeight="20" alignment="CENTER">
-		<CheckBox fx:id="forRunSelectedCheckBox" visible="${controller.checkRunnable}" />
+		<CheckBox fx:id="checkbox" visible="${controller.checkRunnable}"/>
 		<CheckStateIconView check="${controller.check}" glyphSize="20" visible="${!controller.checkRunnable}"/>
 	</StackPane>
 	<Label text="${controller.checkName}"/>