Refactored decision model

See: https://github.com/cryptomator/cryptomator/pull/2985#pullrequestreview-1514141146
This commit is contained in:
JaniruTEC
2023-07-05 15:35:05 +02:00
parent 743da019f9
commit a3c953d437
2 changed files with 20 additions and 9 deletions

View File

@@ -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;
}
}