Skip to content

Commit

Permalink
Limit group separator to one single character in Prefs->Entry Keyword…
Browse files Browse the repository at this point in the history
… Separator (#10543)
  • Loading branch information
colinldbd authored Oct 22, 2023
1 parent 2807229 commit 6c1b7a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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

0 comments on commit 6c1b7a3

Please sign in to comment.