implementing finish-button logic for addNewVault wizard

This commit is contained in:
armin
2019-08-11 13:25:04 +02:00
parent 23c868b646
commit 2a3e2e315e
2 changed files with 4 additions and 12 deletions
@@ -1,12 +1,12 @@
package org.cryptomator.ui.addvaultwizard; package org.cryptomator.ui.addvaultwizard;
import dagger.Lazy; import dagger.Lazy;
import javafx.beans.Observable;
import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.Vault;
import org.cryptomator.common.vaults.VaultFactory; import org.cryptomator.common.vaults.VaultFactory;
@@ -30,6 +30,7 @@ public class CreateNewVaultPasswordController implements FxController {
private final VaultFactory vaultFactory; private final VaultFactory vaultFactory;
private final ResourceBundle resourceBundle; private final ResourceBundle resourceBundle;
public Button finishButton;
public SecPasswordField passwordField; public SecPasswordField passwordField;
public SecPasswordField retypeField; public SecPasswordField retypeField;
@@ -42,20 +43,11 @@ public class CreateNewVaultPasswordController implements FxController {
this.vaults = vaults; this.vaults = vaults;
this.vaultFactory = vaultFactory; this.vaultFactory = vaultFactory;
this.resourceBundle = resourceBundle; this.resourceBundle = resourceBundle;
} }
@FXML @FXML
public void initialize() { public void initialize() {
passwordField.textProperty().addListener(this::passwordsChanged); finishButton.disableProperty().bind(passwordField.textProperty().isEmpty().or(passwordField.textProperty().isEqualTo(retypeField.textProperty()).not()));
retypeField.textProperty().addListener(this::passwordsChanged);
}
private boolean passwordsChanged(@SuppressWarnings("unused") Observable observable) {
boolean passwordsEmpty = passwordField.getCharacters().length() == 0;
boolean passwordsEqual = passwordField.getCharacters().equals(retypeField.getCharacters());
//passwordStrength.set(strengthRater.computeRate(passwordField.getCharacters().toString()));
return (!passwordsEmpty) && passwordsEqual;
} }
@FXML @FXML
@@ -26,7 +26,7 @@
<ButtonBar buttonMinWidth="120" buttonOrder="B+I"> <ButtonBar buttonMinWidth="120" buttonOrder="B+I">
<buttons> <buttons>
<Button text="TODO Back" ButtonBar.buttonData="BACK_PREVIOUS" onAction="#back"/> <Button text="TODO Back" ButtonBar.buttonData="BACK_PREVIOUS" onAction="#back"/>
<Button text="TODO Next" ButtonBar.buttonData="FINISH" onAction="#finish" defaultButton="true" disable="true"/> <Button fx:id="finishButton" text="TODO Next" ButtonBar.buttonData="FINISH" onAction="#finish" defaultButton="true" />
</buttons> </buttons>
</ButtonBar> </ButtonBar>
</children> </children>