Browse Source

Redo "Added UI error messages"

This reverts commit d331c302
JaniruTEC 4 năm trước cách đây
mục cha
commit
343794c1fe

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 14 - 1
main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java


+ 7 - 1
main/ui/src/main/java/org/cryptomator/ui/recoverykey/RecoveryKeyCreationController.java

@@ -4,6 +4,7 @@ import dagger.Lazy;
 import org.cryptomator.common.vaults.Vault;
 import org.cryptomator.cryptolib.api.InvalidPassphraseException;
 import org.cryptomator.ui.common.Animations;
+import org.cryptomator.ui.common.ErrorComponent;
 import org.cryptomator.ui.common.FxController;
 import org.cryptomator.ui.common.FxmlFile;
 import org.cryptomator.ui.common.FxmlScene;
@@ -31,16 +32,20 @@ public class RecoveryKeyCreationController implements FxController {
 	private final ExecutorService executor;
 	private final RecoveryKeyFactory recoveryKeyFactory;
 	private final StringProperty recoveryKeyProperty;
+	private final Lazy<Scene> createScene;
+	private final ErrorComponent.Builder errorComponent;
 	public NiceSecurePasswordField passwordField;
 
 	@Inject
-	public RecoveryKeyCreationController(@RecoveryKeyWindow Stage window, @FxmlScene(FxmlFile.RECOVERYKEY_SUCCESS) Lazy<Scene> successScene, @RecoveryKeyWindow Vault vault, RecoveryKeyFactory recoveryKeyFactory, ExecutorService executor, @RecoveryKeyWindow StringProperty recoveryKey) {
+	public RecoveryKeyCreationController(@RecoveryKeyWindow Stage window, @FxmlScene(FxmlFile.RECOVERYKEY_SUCCESS) Lazy<Scene> successScene, @RecoveryKeyWindow Vault vault, RecoveryKeyFactory recoveryKeyFactory, ExecutorService executor, @RecoveryKeyWindow StringProperty recoveryKey, @FxmlScene(FxmlFile.RECOVERYKEY_CREATE) Lazy<Scene> createScene, ErrorComponent.Builder errorComponent) {
 		this.window = window;
 		this.successScene = successScene;
 		this.vault = vault;
 		this.executor = executor;
 		this.recoveryKeyFactory = recoveryKeyFactory;
 		this.recoveryKeyProperty = recoveryKey;
+		this.createScene = createScene;
+		this.errorComponent = errorComponent;
 	}
 
 	@FXML
@@ -59,6 +64,7 @@ public class RecoveryKeyCreationController implements FxController {
 				Animations.createShakeWindowAnimation(window).play();
 			} else {
 				LOG.error("Creation of recovery key failed.", task.getException());
+				errorComponent.cause(task.getException()).window(window).returnToScene(createScene.get()).build().showErrorScene();
 			}
 		});
 		executor.submit(task);