소스 검색

Refactored decision model

See: https://github.com/cryptomator/cryptomator/pull/2985#pullrequestreview-1514141146
JaniruTEC 2 년 전
부모
커밋
a3c953d437

+ 19 - 8
src/main/java/org/cryptomator/ui/unlock/UnlockInvalidMountPointController.java

@@ -75,23 +75,34 @@ public class UnlockInvalidMountPointController implements FxController {
 
 	private enum ExceptionType {
 
-		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);
+		NOT_SUPPORTED("unlock.error.customPath.description.notSupported", ButtonAction.SHOW_PREFERENCES),
+		NOT_EXISTING("unlock.error.customPath.description.notExists", ButtonAction.SHOW_VAULT_OPTIONS),
+		IN_USE("unlock.error.customPath.description.inUse", ButtonAction.SHOW_VAULT_OPTIONS),
+		GENERIC("unlock.error.customPath.description.generic", ButtonAction.SHOW_PREFERENCES);
 
 		private final String translationKey;
-		private final boolean showPreferences;
+		private final ButtonAction action;
 
-		ExceptionType(String translationKey, boolean showPreferences) {
+		ExceptionType(String translationKey, ButtonAction action) {
 			this.translationKey = translationKey;
-			this.showPreferences = showPreferences;
+			this.action = action;
 		}
 	}
 
+	private enum ButtonAction {
+
+		SHOW_PREFERENCES,
+		SHOW_VAULT_OPTIONS;
+
+	}
+
 	/* Getter */
 
 	public boolean isShowPreferences() {
-		return exceptionType.showPreferences;
+		return exceptionType.action == ButtonAction.SHOW_PREFERENCES;
+	}
+
+	public boolean isShowVaultOptions() {
+		return exceptionType.action == ButtonAction.SHOW_VAULT_OPTIONS;
 	}
 }

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

@@ -47,7 +47,7 @@
 				<buttons>
 					<Button text="%generic.button.cancel" ButtonBar.buttonData="CANCEL_CLOSE" cancelButton="true" onAction="#close"/>
 					<Button text="%hub.noKeychain.openBtn" ButtonBar.buttonData="FINISH" defaultButton="true" onAction="#closeAndOpenPreferences" visible="${controller.showPreferences}" managed="${controller.showPreferences}"/>
-					<Button text="%main.vaultDetail.optionsBtn" ButtonBar.buttonData="FINISH" defaultButton="true" onAction="#closeAndOpenVaultOptions" visible="${!controller.showPreferences}" managed="${!controller.showPreferences}"/>
+					<Button text="%main.vaultDetail.optionsBtn" ButtonBar.buttonData="FINISH" defaultButton="true" onAction="#closeAndOpenVaultOptions" visible="${controller.showVaultOptions}" managed="${controller.showVaultOptions}"/>
 				</buttons>
 			</ButtonBar>
 		</VBox>