rename supporterCert WhiteSpace and VaultNameLength methods

This commit is contained in:
Martin Beyer
2021-11-18 12:06:50 +01:00
parent 0c47af2f15
commit 63b40091ea
2 changed files with 4 additions and 4 deletions

View File

@@ -34,10 +34,10 @@ public class SupporterCertificateController implements FxController {
public void initialize() {
supporterCertificateField.setText(licenseHolder.getLicenseKey().orElse(null));
supporterCertificateField.textProperty().addListener(this::registrationKeyChanged);
supporterCertificateField.setTextFormatter(new TextFormatter<>(this::checkVaultNameLength));
supporterCertificateField.setTextFormatter(new TextFormatter<>(this::removeWhitespaces));
}
private TextFormatter.Change checkVaultNameLength(TextFormatter.Change change) {
private TextFormatter.Change removeWhitespaces(TextFormatter.Change change) {
if (change.isContentChange()) {
var strippedText = CharMatcher.whitespace().removeFrom(change.getText());
change.setText(strippedText);

View File

@@ -47,7 +47,7 @@ public class GeneralVaultOptionsController implements FxController {
public void initialize() {
vaultName.textProperty().set(vault.getVaultSettings().displayName().get());
vaultName.focusedProperty().addListener(this::trimVaultNameOnFocusLoss);
vaultName.setTextFormatter(new TextFormatter<>(this::removeWhitespaces));
vaultName.setTextFormatter(new TextFormatter<>(this::checkVaultNameLength));
unlockOnStartupCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().unlockAfterStartup());
actionAfterUnlockChoiceBox.getItems().addAll(WhenUnlocked.values());
actionAfterUnlockChoiceBox.valueProperty().bindBidirectional(vault.getVaultSettings().actionAfterUnlock());
@@ -63,7 +63,7 @@ public class GeneralVaultOptionsController implements FxController {
}
}
private TextFormatter.Change removeWhitespaces(TextFormatter.Change change) {
private TextFormatter.Change checkVaultNameLength(TextFormatter.Change change) {
if (change.isContentChange() && change.getControlNewText().length() > VAULTNAME_TRUNCATE_THRESHOLD) {
return null; // reject any change that would lead to a text exceeding threshold
} else {