mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-08-21 22:56:01 +00:00
#929, simplyfing add existing vault dialogue
This commit is contained in:
+13
-37
@@ -1,7 +1,6 @@
|
|||||||
package org.cryptomator.ui.addvaultwizard;
|
package org.cryptomator.ui.addvaultwizard;
|
||||||
|
|
||||||
import dagger.Lazy;
|
import dagger.Lazy;
|
||||||
import javafx.beans.binding.BooleanBinding;
|
|
||||||
import javafx.beans.property.ObjectProperty;
|
import javafx.beans.property.ObjectProperty;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
@@ -27,7 +26,6 @@ public class ChooseExistingVaultController implements FxController {
|
|||||||
private final Lazy<Scene> welcomeScene;
|
private final Lazy<Scene> welcomeScene;
|
||||||
private final ObjectProperty<Path> vaultPath;
|
private final ObjectProperty<Path> vaultPath;
|
||||||
private final ObservableList<Vault> vaults;
|
private final ObservableList<Vault> vaults;
|
||||||
private final BooleanBinding vaultPathIsNull;
|
|
||||||
private final VaultFactory vaultFactory;
|
private final VaultFactory vaultFactory;
|
||||||
private final ResourceBundle resourceBundle;
|
private final ResourceBundle resourceBundle;
|
||||||
|
|
||||||
@@ -39,18 +37,6 @@ public class ChooseExistingVaultController implements FxController {
|
|||||||
this.vaults = vaults;
|
this.vaults = vaults;
|
||||||
this.vaultFactory = vaultFactory;
|
this.vaultFactory = vaultFactory;
|
||||||
this.resourceBundle = resourceBundle;
|
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
|
@FXML
|
||||||
@@ -59,30 +45,20 @@ public class ChooseExistingVaultController implements FxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void finish() {
|
public void chooseFileAndFinish() {
|
||||||
//TODO: error handling & cannot unlock added vault
|
//TODO: error handling & cannot unlock added vault
|
||||||
VaultSettings vaultSettings = VaultSettings.withRandomId();
|
FileChooser fileChooser = new FileChooser();
|
||||||
vaultSettings.path().setValue(vaultPath.get());
|
fileChooser.setTitle(resourceBundle.getString("addvaultwizard.existing.filePickerTitle"));
|
||||||
vaults.add(vaultFactory.get(vaultSettings));
|
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Cryptomator Masterkey", "*.cryptomator"));
|
||||||
window.close();
|
final File file = fileChooser.showOpenDialog(window);
|
||||||
}
|
if (file != null) {
|
||||||
|
vaultPath.setValue(file.toPath().toAbsolutePath().getParent());
|
||||||
/* Getter/Setter */
|
VaultSettings vaultSettings = VaultSettings.withRandomId();
|
||||||
|
vaultSettings.path().setValue(vaultPath.get());
|
||||||
public Path getVaultPath() {
|
vaults.add(vaultFactory.get(vaultSettings));
|
||||||
return vaultPath.get();
|
//TODO: error handling?
|
||||||
}
|
window.close();
|
||||||
|
}
|
||||||
public ObjectProperty<Path> vaultPathProperty() {
|
|
||||||
return vaultPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isVaultPathIsNull() {
|
|
||||||
return vaultPathIsNull.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BooleanBinding vaultPathIsNullProperty() {
|
|
||||||
return vaultPathIsNull;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.control.ButtonBar?>
|
<?import javafx.scene.control.ButtonBar?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.TextField?>
|
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
<?import javafx.scene.layout.Region?>
|
<?import javafx.scene.layout.Region?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<VBox xmlns="http://javafx.com/javafx"
|
<VBox xmlns="http://javafx.com/javafx"
|
||||||
@@ -20,15 +18,11 @@
|
|||||||
<children>
|
<children>
|
||||||
<Region VBox.vgrow="ALWAYS"/>
|
<Region VBox.vgrow="ALWAYS"/>
|
||||||
<Label text="%addvaultwizard.existing.instruction"/>
|
<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"/>
|
<Region VBox.vgrow="ALWAYS"/>
|
||||||
<ButtonBar buttonMinWidth="120" buttonOrder="B+I">
|
<ButtonBar buttonMinWidth="120" buttonOrder="B+I">
|
||||||
<buttons>
|
<buttons>
|
||||||
<Button text="%generic.button.back" ButtonBar.buttonData="BACK_PREVIOUS" onAction="#back"/>
|
<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>
|
</buttons>
|
||||||
</ButtonBar>
|
</ButtonBar>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
Reference in New Issue
Block a user