소스 검색

refactor controller:
* fix vault options UI not showing
* rename from "get" to "is" methods in vault options controller

Armin Schrenk 3 년 전
부모
커밋
3ff3b1c63e
2개의 변경된 파일16개의 추가작업 그리고 14개의 파일을 삭제
  1. 12 10
      src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java
  2. 4 4
      src/main/resources/fxml/vault_options_mount.fxml

+ 12 - 10
src/main/java/org/cryptomator/ui/vaultoptions/MountOptionsController.java

@@ -34,8 +34,7 @@ public class MountOptionsController implements FxController {
 
 	private final Stage window;
 	private final Vault vault;
-	private final boolean webDavAndWindows;
-	private final boolean fuseAndWindows;
+	private final VolumeImpl usedVolumeImpl;
 	private final WindowsDriveLetters windowsDriveLetters;
 	private final ResourceBundle resourceBundle;
 
@@ -52,8 +51,7 @@ public class MountOptionsController implements FxController {
 	MountOptionsController(@VaultOptionsWindow Stage window, @VaultOptionsWindow Vault vault, Settings settings, WindowsDriveLetters windowsDriveLetters, ResourceBundle resourceBundle, Environment environment) {
 		this.window = window;
 		this.vault = vault;
-		this.webDavAndWindows = settings.preferredVolumeImpl().get() == VolumeImpl.WEBDAV && SystemUtils.IS_OS_WINDOWS;
-		this.fuseAndWindows = settings.preferredVolumeImpl().get() == VolumeImpl.FUSE && SystemUtils.IS_OS_WINDOWS;
+		this.usedVolumeImpl = settings.preferredVolumeImpl().get();
 		this.windowsDriveLetters = windowsDriveLetters;
 		this.resourceBundle = resourceBundle;
 	}
@@ -64,7 +62,7 @@ public class MountOptionsController implements FxController {
 		// readonly:
 		readOnlyCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().usesReadOnlyMode());
 		//TODO: support this feature on Windows
-		if (fuseAndWindows) {
+		if (usedVolumeImpl == VolumeImpl.FUSE && isOsWindows()) {
 			readOnlyCheckbox.setSelected(false); // to prevent invalid states
 			readOnlyCheckbox.setDisable(true);
 		}
@@ -176,22 +174,26 @@ public class MountOptionsController implements FxController {
 
 	// Getter & Setter
 
-	public boolean getOsIsWindows() {
+	public boolean isOsWindows() {
 		return SystemUtils.IS_OS_WINDOWS;
 	}
 
-	public boolean getCustomMountPointSupported() {
-		return webDavAndWindows;
+	public boolean isCustomMountPointSupported() {
+		return !(usedVolumeImpl == VolumeImpl.WEBDAV && isOsWindows());
 	}
 
-	public boolean getReadOnlySupported() {
-		return fuseAndWindows;
+	public boolean isReadOnlySupported() {
+		return !(usedVolumeImpl == VolumeImpl.FUSE && isOsWindows()) ;
 	}
 
 	public StringProperty customMountPathProperty() {
 		return vault.getVaultSettings().customMountPath();
 	}
 
+	public boolean isCustomMountOptionsSupported() {
+		return !(usedVolumeImpl == VolumeImpl.WEBDAV);
+	}
+
 	public String getCustomMountPath() {
 		return vault.getVaultSettings().customMountPath().get();
 	}

+ 4 - 4
src/main/resources/fxml/vault_options_mount.fxml

@@ -24,7 +24,7 @@
 	<children>
 		<CheckBox fx:id="readOnlyCheckbox" text="%vaultOptions.mount.readonly"/>
 
-		<CheckBox fx:id="customMountFlagsCheckbox" text="%vaultOptions.mount.customMountFlags" onAction="#toggleUseCustomMountFlags" visible="${!controller.webDavAndWindows}" managed="${!controller.webDavAndWindows}"/>
+		<CheckBox fx:id="customMountFlagsCheckbox" text="%vaultOptions.mount.customMountFlags" onAction="#toggleUseCustomMountFlags" visible="${controller.customMountOptionsSupported}" managed="${controller.customMountOptionsSupported}"/>
 
 		<TextField fx:id="mountFlags" HBox.hgrow="ALWAYS" maxWidth="Infinity">
 			<VBox.margin>
@@ -38,11 +38,11 @@
 			</VBox.margin>
 		</Label>
 		<RadioButton toggleGroup="${mountPoint}" fx:id="mountPointAuto" text="%vaultOptions.mount.mountPoint.auto"/>
-		<HBox spacing="6" visible="${controller.osIsWindows}" managed="${controller.osIsWindows}">
+		<HBox spacing="6" visible="${controller.osWindows}" managed="${controller.osWindows}">
 			<RadioButton toggleGroup="${mountPoint}" fx:id="mountPointWinDriveLetter" text="%vaultOptions.mount.mountPoint.driveLetter"/>
 			<ChoiceBox fx:id="driveLetterSelection" disable="${!mountPointWinDriveLetter.selected}"/>
 		</HBox>
-		<HBox spacing="6" alignment="CENTER_LEFT" visible="${!controller.customMountPointSupported}" managed="${!controller.customMountPointSupported}">
+		<HBox fx:id="customMountPointRadioBtn" spacing="6" alignment="CENTER_LEFT" visible="${controller.customMountOptionsSupported}" managed="${controller.customMountOptionsSupported}">
 			<RadioButton toggleGroup="${mountPoint}" fx:id="mountPointCustomDir" text="%vaultOptions.mount.mountPoint.custom" />
 			<Button text="%vaultOptions.mount.mountPoint.directoryPickerButton" onAction="#chooseCustomMountPoint" contentDisplay="LEFT" disable="${!mountPointCustomDir.selected}">
 				<graphic>
@@ -50,7 +50,7 @@
 				</graphic>
 			</Button>
 		</HBox>
-		<TextField text="${controller.customMountPath}" visible="${mountPointCustomDir.selected}" maxWidth="Infinity" disable="true" managed="${!controller.webDavAndWindows}">
+		<TextField text="${controller.customMountPath}" visible="${mountPointCustomDir.selected}" maxWidth="Infinity" disable="true" managed="${customMountPointRadioBtn.managed}">
 			<VBox.margin>
 				<Insets left="24"/>
 			</VBox.margin>