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

Fix autocomplete thread #6455

Merged
merged 8 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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