Skip to content

Commit

Permalink
Fix field formatter throwing exception on autosave
Browse files Browse the repository at this point in the history
Fixes #4958
  • Loading branch information
Siedlerchr committed May 30, 2019
1 parent ef2ebe1 commit 6f045e8
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import javafx.util.Callback;
import javafx.util.StringConverter;

import org.jabref.gui.util.DefaultTaskExecutor;

import org.controlsfx.control.textfield.AutoCompletionBinding;

/**
Expand All @@ -51,7 +53,7 @@ public class AutoCompletionTextInputBinding<T> extends AutoCompletionBinding<T>
private AutoCompletionStrategy inputAnalyzer;
private final ChangeListener<String> textChangeListener = (obs, oldText, newText) -> {
if (getCompletionTarget().isFocused()) {
setUserInputText(newText);
DefaultTaskExecutor.runInJavaFXThread(() -> setUserInputText(newText)); //we need to wrap this as it is called from a non fx thread in autosave
}
};
private boolean showOnFocus;
Expand All @@ -73,9 +75,9 @@ private AutoCompletionTextInputBinding(final TextInputControl textInputControl,
Callback<ISuggestionRequest, Collection<T>> suggestionProvider) {

this(textInputControl,
suggestionProvider,
AutoCompletionTextInputBinding.defaultStringConverter(),
new ReplaceStrategy());
suggestionProvider,
AutoCompletionTextInputBinding.defaultStringConverter(),
new ReplaceStrategy());
}

private AutoCompletionTextInputBinding(final TextInputControl textInputControl,
Expand All @@ -99,6 +101,7 @@ private AutoCompletionTextInputBinding(final TextInputControl textInputControl,

private static <T> StringConverter<T> defaultStringConverter() {
return new StringConverter<T>() {

@Override
public String toString(T t) {
return t == null ? null : t.toString();
Expand Down

0 comments on commit 6f045e8

Please sign in to comment.