From 40c3e7a417c1fc8a4cb6a508bd00a0c0bd48536c Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 16 Aug 2019 12:00:51 +0200 Subject: [PATCH] #929, simplyfing add existing vault dialogue --- .../ChooseExistingVaultController.java | 50 +++++-------------- .../resources/fxml/addvault_existing.fxml | 8 +-- 2 files changed, 14 insertions(+), 44 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/addvaultwizard/ChooseExistingVaultController.java b/main/ui/src/main/java/org/cryptomator/ui/addvaultwizard/ChooseExistingVaultController.java index 99683d211..587443d73 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/addvaultwizard/ChooseExistingVaultController.java +++ b/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 welcomeScene; private final ObjectProperty vaultPath; private final ObservableList vaults; - private final BooleanBinding vaultPathIsNull; private final VaultFactory vaultFactory; private final ResourceBundle resourceBundle; @@ -39,18 +37,6 @@ public class ChooseExistingVaultController implements FxController { this.vaults = vaults; this.vaultFactory = vaultFactory; this.resourceBundle = resourceBundle; - this.vaultPathIsNull = vaultPath.isNull(); - } - - @FXML - public void chooseFile() { - 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()); - } } @FXML @@ -59,30 +45,20 @@ public class ChooseExistingVaultController implements FxController { } @FXML - public void finish() { + public void chooseFileAndFinish() { //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 vaultPathProperty() { - return vaultPath; - } - - public boolean isVaultPathIsNull() { - return vaultPathIsNull.get(); - } - - public BooleanBinding vaultPathIsNullProperty() { - return vaultPathIsNull; + 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(); + } } } diff --git a/main/ui/src/main/resources/fxml/addvault_existing.fxml b/main/ui/src/main/resources/fxml/addvault_existing.fxml index e1c116c52..fea6a2d8b 100644 --- a/main/ui/src/main/resources/fxml/addvault_existing.fxml +++ b/main/ui/src/main/resources/fxml/addvault_existing.fxml @@ -4,8 +4,6 @@ - -