From cd7acea54e9dc6b95ae02839ff96f9bf35f83d2a Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Wed, 2 Jun 2021 14:52:27 +0200 Subject: [PATCH] Use of NumericTextField --- .../AutoLockVaultOptionsController.java | 23 ++++--------------- .../fxml/vault_options_autolock.fxml | 4 ++-- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/vaultoptions/AutoLockVaultOptionsController.java b/main/ui/src/main/java/org/cryptomator/ui/vaultoptions/AutoLockVaultOptionsController.java index 906a40ba3..e8e5ca5fb 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/vaultoptions/AutoLockVaultOptionsController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/vaultoptions/AutoLockVaultOptionsController.java @@ -2,31 +2,23 @@ package org.cryptomator.ui.vaultoptions; import org.cryptomator.common.vaults.Vault; import org.cryptomator.ui.common.FxController; +import org.cryptomator.ui.controls.NumericTextField; import javax.inject.Inject; - import javafx.beans.binding.Bindings; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; import javafx.fxml.FXML; import javafx.scene.control.CheckBox; -import javafx.scene.control.TextField; -import javafx.stage.Stage; import javafx.util.converter.NumberStringConverter; -import java.util.ResourceBundle; - @VaultOptionsScoped public class AutoLockVaultOptionsController implements FxController { private final Vault vault; - private final Stage window; public CheckBox lockAfterTimeCheckbox; - public TextField lockTimeInMinutesTextField; + public NumericTextField lockTimeInMinutesTextField; @Inject - AutoLockVaultOptionsController(@VaultOptionsWindow Stage window, @VaultOptionsWindow Vault vault, ResourceBundle resourceBundle) { - this.window = window; + AutoLockVaultOptionsController(@VaultOptionsWindow Vault vault) { this.vault = vault; } @@ -34,13 +26,6 @@ public class AutoLockVaultOptionsController implements FxController { public void initialize() { lockAfterTimeCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().lockAfterTime()); Bindings.bindBidirectional(lockTimeInMinutesTextField.textProperty(), vault.getVaultSettings().lockTimeInMinutes(), new NumberStringConverter()); - lockTimeInMinutesTextField.textProperty().addListener(new ChangeListener() { - @Override - public void changed(ObservableValue observable, String oldValue, String newValue) { - if (!newValue.matches("\\d{0,9}")) { - lockTimeInMinutesTextField.setText(newValue.replaceAll("[^\\d]", "")); - } - } - }); } + } diff --git a/main/ui/src/main/resources/fxml/vault_options_autolock.fxml b/main/ui/src/main/resources/fxml/vault_options_autolock.fxml index e7c120fb9..8d63b792d 100644 --- a/main/ui/src/main/resources/fxml/vault_options_autolock.fxml +++ b/main/ui/src/main/resources/fxml/vault_options_autolock.fxml @@ -1,9 +1,9 @@ + - @@ -18,7 +18,7 @@ - +