Skip to content

Commit

Permalink
Fix autocomplete thread (#6455)
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr authored May 12, 2020
1 parent 993e8f9 commit f984442
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where the Preferences entry preview will be unexpected modified leads to Value too long exception [#6198](https://github.com/JabRef/jabref/issues/6198)
- We fixed an issue where custom jstyles for Open/LibreOffice would only be valid if a layout line for the entry type `default` was at the end of the layout section [#6303](https://github.com/JabRef/jabref/issues/6303)
- We fixed an issue where sort on numeric cases was broken. [#6349](https://github.com/JabRef/jabref/issues/6349)

- We fixed an issue where an "Not on FX thread" exception occured when saving on linux [#6453](https://github.com/JabRef/jabref/issues/6453)

### Removed

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ task deleteInstallerTemp(type: Delete) {

jpackage.dependsOn deleteInstallerTemp
jlink {
options = ['--strip-debug','--compress', '2', '--no-header-files', '--no-man-pages']
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'JabRef'
}
Expand Down
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 Down Expand Up @@ -98,7 +100,7 @@ private AutoCompletionTextInputBinding(final TextInputControl textInputControl,
}

private static <T> StringConverter<T> defaultStringConverter() {
return new StringConverter<T>() {
return new StringConverter<>() {
@Override
public String toString(T t) {
return t == null ? null : t.toString();
Expand Down Expand Up @@ -133,7 +135,7 @@ private void setUserInputText(String newText) {
newText = "";
}
AutoCompletionInput input = inputAnalyzer.analyze(newText);
setUserInput(input.getUnfinishedPart());
DefaultTaskExecutor.runInJavaFXThread(() -> setUserInput(input.getUnfinishedPart()));
}

@Override
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/jabref/gui/fieldeditors/SimpleEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ public SimpleEditor(final Field field,
((ContextMenuAddable) textInput).addToContextMenu(EditorMenus.getDefaultMenu(textInput));
this.getChildren().add(textInput);

AutoCompletionTextInputBinding<?> autoCompleter = AutoCompletionTextInputBinding.autoComplete(textInput, viewModel::complete, viewModel.getAutoCompletionStrategy());
if (suggestionProvider instanceof ContentSelectorSuggestionProvider) {
// If content selector values are present, then we want to show the auto complete suggestions immediately on focus
autoCompleter.setShowOnFocus(true);
if (!isMultiLine) {
AutoCompletionTextInputBinding<?> autoCompleter = AutoCompletionTextInputBinding.autoComplete(textInput, viewModel::complete, viewModel.getAutoCompletionStrategy());
if (suggestionProvider instanceof ContentSelectorSuggestionProvider) {
// If content selector values are present, then we want to show the auto complete suggestions immediately on focus
autoCompleter.setShowOnFocus(true);
}
}

new EditorValidator(preferences).configureValidation(viewModel.getFieldValidator().getValidationStatus(), textInput);
Expand Down

0 comments on commit f984442

Please sign in to comment.