浏览代码

Replace lock failed dialogue stub and integrate it into workflow

Armin Schrenk 4 年之前
父节点
当前提交
afa0cfeafb

+ 17 - 1
main/ui/src/main/java/org/cryptomator/ui/lock/LockFailedController.java

@@ -1,15 +1,31 @@
 package org.cryptomator.ui.lock;
 
+import org.cryptomator.common.vaults.Vault;
 import org.cryptomator.ui.common.FxController;
 
 import javax.inject.Inject;
+import javafx.fxml.FXML;
+import javafx.stage.Stage;
 
 @LockScoped
 public class LockFailedController implements FxController {
 
+	private final Stage window;
+	private final Vault vault;
+
 	@Inject
-	public LockFailedController() {
+	public LockFailedController(@LockWindow Stage window, @LockWindow Vault vault) {
+		this.window = window;
+		this.vault = vault;
+	}
 
+	@FXML
+	public void close() {
+		window.close();
 	}
 
+	// ----- Getter & Setter -----
+	public String getVaultName() {
+		return vault.getDisplayName();
+	}
 }

+ 2 - 0
main/ui/src/main/java/org/cryptomator/ui/lock/LockWorkflow.java

@@ -94,6 +94,8 @@ public class LockWorkflow extends Task<Void> {
 	protected void failed() {
 		LOG.warn("Failed to lock {}.", vault.getDisplayName());
 		vault.setState(VaultState.UNLOCKED);
+		lockWindow.setScene(lockFailedScene.get());
+		lockWindow.show();
 	}
 
 	@Override

+ 18 - 1
main/ui/src/main/resources/fxml/lock_failed.fxml

@@ -1,9 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
+<?import org.cryptomator.ui.controls.FontAwesome5IconView?>
+<?import org.cryptomator.ui.controls.FormattedLabel?>
 <?import javafx.geometry.Insets?>
+<?import javafx.scene.control.Button?>
 <?import javafx.scene.control.Label?>
 <?import javafx.scene.layout.HBox?>
+<?import javafx.scene.layout.StackPane?>
 <?import javafx.scene.layout.VBox?>
+<?import javafx.scene.shape.Circle?>
 <VBox xmlns:fx="http://javafx.com/fxml"
 	  xmlns="http://javafx.com/javafx"
 	  fx:controller="org.cryptomator.ui.lock.LockFailedController"
@@ -15,6 +20,18 @@
 		<Insets topRightBottomLeft="12"/>
 	</padding>
 	<children>
-		<Label text="This is a stub." wrapText="true" textAlignment="LEFT" HBox.hgrow="ALWAYS"/>
+		<HBox spacing="12" alignment="CENTER_LEFT" VBox.vgrow="ALWAYS">
+			<StackPane alignment="CENTER" HBox.hgrow="NEVER">
+				<Circle styleClass="glyph-icon-red" radius="24"/>
+				<FontAwesome5IconView styleClass="glyph-icon-white" glyph="TIMES" glyphSize="24"/>
+			</StackPane>
+			<VBox spacing="6">
+				<Label styleClass="label-medium" text="%lock.fail.heading"/>
+				<FormattedLabel format="%lock.fail.message" arg1="${controller.vaultName}" wrapText="true"/>
+			</VBox>
+		</HBox>
+		<VBox alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS">
+			<Button text="OK" defaultButton="false" VBox.vgrow="ALWAYS" cancelButton="true" onAction="#close"/>
+		</VBox>
 	</children>
 </VBox>

+ 2 - 1
main/ui/src/main/resources/i18n/strings.properties

@@ -114,7 +114,8 @@ lock.forced.heading=Forcefully Lock Vault?
 lock.forced.message=The vault "%s" cannot be locked due to open files or pending operations. Close those files and wait until I/O operations are finished and try again.\n Alternatively, you can enforce locking risking to loose unsaved data.
 lock.forced.confirmBtn=Force Locking
 ## Failure
-lock.fail.message=TODO
+lock.fail.heading=Locking Vault failed
+lock.fail.message=Vault "%s" could not be locked. Ensure unsaved work is saved elsewhere and important Read/Write operations are finished. In order to close the vault, kill the Cryptomator process.
 
 # Migration
 migration.title=Upgrade Vault