mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-19 17:16:53 -04:00
Use of NumericTextField
This commit is contained in:
@@ -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<String>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
||||
if (!newValue.matches("\\d{0,9}")) {
|
||||
lockTimeInMinutesTextField.setText(newValue.replaceAll("[^\\d]", ""));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import org.cryptomator.ui.controls.FormattedLabel?>
|
||||
<?import org.cryptomator.ui.controls.NumericTextField?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
<?import javafx.scene.text.TextFlow?>
|
||||
@@ -18,7 +18,7 @@
|
||||
<TextFlow styleClass="text-flow" prefWidth="-Infinity">
|
||||
<CheckBox text="%vaultOptions.autoLock.lockAfterTimePart1" fx:id="lockAfterTimeCheckbox"/>
|
||||
<Text text=" "/>
|
||||
<TextField fx:id="lockTimeInMinutesTextField" prefWidth="50"/>
|
||||
<NumericTextField fx:id="lockTimeInMinutesTextField" prefWidth="50"/>
|
||||
<Text text=" "/>
|
||||
<FormattedLabel format="%vaultOptions.autoLock.lockAfterTimePart2"/>
|
||||
</TextFlow>
|
||||
|
||||
Reference in New Issue
Block a user