mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-20 09:36:55 -04:00
#929, simplyfing add existing vault dialogue
This commit is contained in:
@@ -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,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<Path> 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user