|
@@ -2,13 +2,12 @@
|
|
* Copyright (c) 2014, 2017 Sebastian Stenzel
|
|
* Copyright (c) 2014, 2017 Sebastian Stenzel
|
|
* All rights reserved.
|
|
* All rights reserved.
|
|
* This program and the accompanying materials are made available under the terms of the accompanying LICENSE file.
|
|
* This program and the accompanying materials are made available under the terms of the accompanying LICENSE file.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* Contributors:
|
|
* Contributors:
|
|
* Sebastian Stenzel - initial API and implementation
|
|
* Sebastian Stenzel - initial API and implementation
|
|
******************************************************************************/
|
|
******************************************************************************/
|
|
package org.cryptomator.ui.controllers;
|
|
package org.cryptomator.ui.controllers;
|
|
|
|
|
|
-import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.nio.file.*;
|
|
import java.nio.file.*;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
@@ -18,8 +17,8 @@ import java.util.Optional;
|
|
|
|
|
|
import javax.inject.Inject;
|
|
import javax.inject.Inject;
|
|
|
|
|
|
-import javafx.beans.Observable;
|
|
|
|
import javafx.beans.binding.Bindings;
|
|
import javafx.beans.binding.Bindings;
|
|
|
|
+import javafx.scene.layout.HBox;
|
|
import org.apache.commons.lang3.CharUtils;
|
|
import org.apache.commons.lang3.CharUtils;
|
|
import org.apache.commons.lang3.SystemUtils;
|
|
import org.apache.commons.lang3.SystemUtils;
|
|
import org.cryptomator.common.settings.VaultSettings;
|
|
import org.cryptomator.common.settings.VaultSettings;
|
|
@@ -116,6 +115,9 @@ public class UnlockController implements ViewController {
|
|
@FXML
|
|
@FXML
|
|
private ChoiceBox<Character> winDriveLetter;
|
|
private ChoiceBox<Character> winDriveLetter;
|
|
|
|
|
|
|
|
+ @FXML
|
|
|
|
+ private HBox mountPathBox;
|
|
|
|
+
|
|
@FXML
|
|
@FXML
|
|
private Label mountPathLabel;
|
|
private Label mountPathLabel;
|
|
|
|
|
|
@@ -155,6 +157,7 @@ public class UnlockController implements ViewController {
|
|
unlockAfterStartup.disableProperty().bind(savePassword.disabledProperty().or(savePassword.selectedProperty().not()));
|
|
unlockAfterStartup.disableProperty().bind(savePassword.disabledProperty().or(savePassword.selectedProperty().not()));
|
|
if (SystemUtils.IS_OS_WINDOWS) {
|
|
if (SystemUtils.IS_OS_WINDOWS) {
|
|
winDriveLetter.setConverter(new WinDriveLetterLabelConverter());
|
|
winDriveLetter.setConverter(new WinDriveLetterLabelConverter());
|
|
|
|
+ mountPathBox.setMouseTransparent(true);
|
|
mountPathLabel.setVisible(false);
|
|
mountPathLabel.setVisible(false);
|
|
mountPathLabel.setManaged(false);
|
|
mountPathLabel.setManaged(false);
|
|
mountPath.setVisible(false);
|
|
mountPath.setVisible(false);
|
|
@@ -170,7 +173,7 @@ public class UnlockController implements ViewController {
|
|
changeMountPathButton.disableProperty().bind(Bindings.createBooleanBinding(this::isDirVaild, mountPath.textProperty()).not());
|
|
changeMountPathButton.disableProperty().bind(Bindings.createBooleanBinding(this::isDirVaild, mountPath.textProperty()).not());
|
|
changeMountPathButton.visibleProperty().bind(
|
|
changeMountPathButton.visibleProperty().bind(
|
|
Bindings.createBooleanBinding(
|
|
Bindings.createBooleanBinding(
|
|
- ()-> mountPathLabel.isVisible() && mountPath.textProperty().isEmpty().not().get(),
|
|
|
|
|
|
+ () -> mountPathLabel.isVisible() && mountPath.textProperty().isEmpty().not().get(),
|
|
mountPathLabel.visibleProperty(),
|
|
mountPathLabel.visibleProperty(),
|
|
mountPath.textProperty().isEmpty().not()
|
|
mountPath.textProperty().isEmpty().not()
|
|
)
|
|
)
|
|
@@ -262,31 +265,28 @@ public class UnlockController implements ViewController {
|
|
}
|
|
}
|
|
|
|
|
|
@FXML
|
|
@FXML
|
|
- private void didClickchangeMountPathButton(ActionEvent event){
|
|
|
|
|
|
+ private void didClickchangeMountPathButton(ActionEvent event) {
|
|
assert isDirVaild();
|
|
assert isDirVaild();
|
|
vault.setMountPath(mountPath.getText());
|
|
vault.setMountPath(mountPath.getText());
|
|
}
|
|
}
|
|
|
|
|
|
- private boolean isDirVaild(){
|
|
|
|
- try{
|
|
|
|
- if(!mountPath.textProperty().isEmpty().get()){
|
|
|
|
|
|
+ private boolean isDirVaild() {
|
|
|
|
+ try {
|
|
|
|
+ if (!mountPath.textProperty().isEmpty().get()) {
|
|
Path p = Paths.get(mountPath.textProperty().get());
|
|
Path p = Paths.get(mountPath.textProperty().get());
|
|
return Files.isDirectory(p) && Files.isReadable(p) && Files.isWritable(p) && Files.isExecutable(p);
|
|
return Files.isDirectory(p) && Files.isReadable(p) && Files.isWritable(p) && Files.isExecutable(p);
|
|
- }
|
|
|
|
- else{
|
|
|
|
|
|
+ } else {
|
|
//default path will be taken
|
|
//default path will be taken
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- }
|
|
|
|
- catch (InvalidPathException e){
|
|
|
|
|
|
+ } catch (InvalidPathException e) {
|
|
LOG.info("Invalid path");
|
|
LOG.info("Invalid path");
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
private void filterAlphanumericKeyEvents(KeyEvent t) {
|
|
private void filterAlphanumericKeyEvents(KeyEvent t) {
|
|
if (!Strings.isNullOrEmpty(t.getCharacter()) && !ALPHA_NUMERIC_MATCHER.matchesAllOf(t.getCharacter())) {
|
|
if (!Strings.isNullOrEmpty(t.getCharacter()) && !ALPHA_NUMERIC_MATCHER.matchesAllOf(t.getCharacter())) {
|
|
t.consume();
|
|
t.consume();
|
|
@@ -451,6 +451,7 @@ public class UnlockController implements ViewController {
|
|
|
|
|
|
@FunctionalInterface
|
|
@FunctionalInterface
|
|
interface UnlockListener {
|
|
interface UnlockListener {
|
|
|
|
+
|
|
void didUnlock(Vault vault);
|
|
void didUnlock(Vault vault);
|
|
}
|
|
}
|
|
|
|
|