Browse Source

#929, simplyfing add existing vault dialogue

Armin Schrenk 5 years ago
parent
commit
40c3e7a417

+ 12 - 36
main/ui/src/main/java/org/cryptomator/ui/addvaultwizard/ChooseExistingVaultController.java

@@ -1,7 +1,6 @@
 package org.cryptomator.ui.addvaultwizard;
 
 import dagger.Lazy;
-import javafx.beans.binding.BooleanBinding;
 import javafx.beans.property.ObjectProperty;
 import javafx.collections.ObservableList;
 import javafx.fxml.FXML;
@@ -27,7 +26,6 @@ public class ChooseExistingVaultController implements FxController {
 	private final Lazy<Scene> welcomeScene;
 	private final ObjectProperty<Path> vaultPath;
 	private final ObservableList<Vault> vaults;
-	private final BooleanBinding vaultPathIsNull;
 	private final VaultFactory vaultFactory;
 	private final ResourceBundle resourceBundle;
 
@@ -39,50 +37,28 @@ public class ChooseExistingVaultController implements FxController {
 		this.vaults = vaults;
 		this.vaultFactory = vaultFactory;
 		this.resourceBundle = resourceBundle;
-		this.vaultPathIsNull = vaultPath.isNull();
 	}
 
 	@FXML
-	public void chooseFile() {
+	public void back() {
+		window.setScene(welcomeScene.get());
+	}
+
+	@FXML
+	public void chooseFileAndFinish() {
+		//TODO: error handling & cannot unlock added vault
 		FileChooser fileChooser = new FileChooser();
 		fileChooser.setTitle(resourceBundle.getString("addvaultwizard.existing.filePickerTitle"));
 		fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Cryptomator Masterkey", "*.cryptomator"));
 		final File file = fileChooser.showOpenDialog(window);
 		if (file != null) {
 			vaultPath.setValue(file.toPath().toAbsolutePath().getParent());
+			VaultSettings vaultSettings = VaultSettings.withRandomId();
+			vaultSettings.path().setValue(vaultPath.get());
+			vaults.add(vaultFactory.get(vaultSettings));
+			//TODO: error handling?
+			window.close();
 		}
 	}
 
-	@FXML
-	public void back() {
-		window.setScene(welcomeScene.get());
-	}
-
-	@FXML
-	public void finish() {
-		//TODO: error handling & cannot unlock added vault
-		VaultSettings vaultSettings = VaultSettings.withRandomId();
-		vaultSettings.path().setValue(vaultPath.get());
-		vaults.add(vaultFactory.get(vaultSettings));
-		window.close();
-	}
-
-	/* Getter/Setter */
-
-	public Path getVaultPath() {
-		return vaultPath.get();
-	}
-
-	public ObjectProperty<Path> vaultPathProperty() {
-		return vaultPath;
-	}
-
-	public boolean isVaultPathIsNull() {
-		return vaultPathIsNull.get();
-	}
-
-	public BooleanBinding vaultPathIsNullProperty() {
-		return vaultPathIsNull;
-	}
-
 }

+ 1 - 7
main/ui/src/main/resources/fxml/addvault_existing.fxml

@@ -4,8 +4,6 @@
 <?import javafx.scene.control.Button?>
 <?import javafx.scene.control.ButtonBar?>
 <?import javafx.scene.control.Label?>
-<?import javafx.scene.control.TextField?>
-<?import javafx.scene.layout.HBox?>
 <?import javafx.scene.layout.Region?>
 <?import javafx.scene.layout.VBox?>
 <VBox xmlns="http://javafx.com/javafx"
@@ -20,15 +18,11 @@
 	<children>
 		<Region VBox.vgrow="ALWAYS"/>
 		<Label text="%addvaultwizard.existing.instruction"/>
-		<HBox spacing="18">
-			<TextField promptText="%addvaultwizard.existing.promptText" text="${controller.vaultPath}" disable="true" HBox.hgrow="ALWAYS"/>
-			<Button text="%addvaultwizard.existing.filePickerButton" onAction="#chooseFile" HBox.hgrow="NEVER" prefWidth="120"/>
-		</HBox>
 		<Region VBox.vgrow="ALWAYS"/>
 		<ButtonBar buttonMinWidth="120" buttonOrder="B+I">
 			<buttons>
 				<Button text="%generic.button.back" ButtonBar.buttonData="BACK_PREVIOUS" onAction="#back"/>
-				<Button text="%generic.button.open" ButtonBar.buttonData="FINISH" onAction="#finish" defaultButton="true" disable="${controller.vaultPathIsNull}"/>
+				<Button text="Choose..." ButtonBar.buttonData="FINISH" onAction="#chooseFileAndFinish" defaultButton="true"/>
 			</buttons>
 		</ButtonBar>
 	</children>