Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit group separator to one single character in Prefs->Entry Keyword Separator #10543

Merged
merged 9 commits into from
Oct 22, 2023
Merged
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

### Changed

- We changed the setting of the keyword separator to accept a single character only. [#177](https://github.com/koppor/jabref/issues/177)

### Fixed

### Removed
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/jabref/gui/preferences/entry/EntryTab.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.jabref.gui.preferences.entry;

import java.util.function.UnaryOperator;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;
import javafx.scene.control.TextFormatter;

import org.jabref.gui.actions.ActionFactory;
import org.jabref.gui.actions.StandardActions;
Expand Down Expand Up @@ -48,6 +51,17 @@ public void initialize() {

keywordSeparator.textProperty().bindBidirectional(viewModel.keywordSeparatorProperty());

// Use TextFormatter to limit the length of the Input of keywordSeparator to 1 character only.
UnaryOperator<TextFormatter.Change> singleCharacterFilter = change -> {
if (change.getControlNewText().length() <= 1) {
return change;
}
return null; // null means the change is rejected
};
TextFormatter<String> formatter = new TextFormatter<>(singleCharacterFilter);

keywordSeparator.setTextFormatter(formatter);

resolveStrings.selectedProperty().bindBidirectional(viewModel.resolveStringsProperty());
resolveStringsForFields.textProperty().bindBidirectional(viewModel.resolveStringsForFieldsProperty());
nonWrappableFields.textProperty().bindBidirectional(viewModel.nonWrappableFieldsProperty());
Expand Down