diff --git a/CHANGELOG.md b/CHANGELOG.md index cb2b075e783..4f5b540a58d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We added a new type of group that shows all items referenced in a given LaTeX file (actually the generated AUX file). [#1664](https://github.com/JabRef/jabref/issues/1664) - We added the export of the `translator` field to the according MS-Office XML field. [#1750, comment](https://github.com/JabRef/jabref/issues/1750#issuecomment-357350986) - We changed the import of the MS-Office XML fields `bookauthor` and `translator`. Both are now imported to their corresponding bibtex/biblatex fields. -- We improved the export of the `address` and `location` field to the MS-Office XML fields. If the address field does not contain a comma, it is treated as single value and exported to the field `city`. [#1750, comment](https://github.com/JabRef/jabref/issues/1750#issuecomment-357539167) +- We improved the export of the `address` and `location` field to the MS-Office XML fields. If the address field does not contain a comma, it is treated as single value and exported to the field `city`. [#1750, comment](https://github.com/JabRef/jabref/issues/1750#issuecomment-357539167) For more details refer to the [field mapping help page](http://help.jabref.org/en/MsOfficeBibFieldMapping) - We added Facebook and Twitter icons in the toolbar to link to our [Facebook](https://www.facebook.com/JabRef/) and [Twitter](https://twitter.com/jabref_org) pages. - We no longer print empty lines when exporting an entry in RIS format [#3634](https://github.com/JabRef/jabref/issues/3634) @@ -27,6 +27,7 @@ For more details refer to the [field mapping help page](http://help.jabref.org/e The new default removes the linked file from the entry instead of deleting the file from disk. [#3679](https://github.com/JabRef/jabref/issues/3679) ### Fixed +- We fixed an issue where pressing space caused the cursor to jump to the start of the text field. [#3471](https://github.com/JabRef/jabref/issues/3471) - We fixed the missing dot in the name of an exported file. [#3576](https://github.com/JabRef/jabref/issues/3576) - Autocompletion in the search bar can now be disabled via the preferences. [#3598](https://github.com/JabRef/jabref/issues/3598) - We fixed and extended the RIS import functionality to cover more fields. [#3634](https://github.com/JabRef/jabref/issues/3634) [#2607](https://github.com/JabRef/jabref/issues/2607) diff --git a/src/main/java/org/jabref/gui/entryeditor/SourceTab.java b/src/main/java/org/jabref/gui/entryeditor/SourceTab.java index 517180b9ad6..b48def74d21 100644 --- a/src/main/java/org/jabref/gui/entryeditor/SourceTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/SourceTab.java @@ -103,7 +103,7 @@ protected void bindToEntry(BibEntry entry) { // Store source for every change in the source code // and update source code for every change of entry field values BindingsHelper.bindContentBidirectional(entry.getFieldsObservable(), codeArea.textProperty(), this::storeSource, fields -> { - DefaultTaskExecutor.runInJavaFXThread(() -> { + DefaultTaskExecutor.runAndWaitInJavaFXThread(() -> { codeArea.clear(); try { codeArea.appendText(getSourceString(entry, mode, fieldFormatterPreferences)); diff --git a/src/main/java/org/jabref/gui/util/DefaultTaskExecutor.java b/src/main/java/org/jabref/gui/util/DefaultTaskExecutor.java index 7697e7e34bf..acb06b8e7bd 100644 --- a/src/main/java/org/jabref/gui/util/DefaultTaskExecutor.java +++ b/src/main/java/org/jabref/gui/util/DefaultTaskExecutor.java @@ -1,6 +1,7 @@ package org.jabref.gui.util; import java.util.concurrent.Callable; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -38,6 +39,39 @@ public static V runInJavaFXThread(Callable callable) { } } + /** + * Runs the specified {@link Runnable} on the JavaFX application thread and waits for completion. + * + * @param action the {@link Runnable} to run + * @throws NullPointerException if {@code action} is {@code null} + */ + public static void runAndWaitInJavaFXThread(Runnable action) { + if (action == null) + throw new NullPointerException("action"); + + // Run synchronously on JavaFX thread + if (Platform.isFxApplicationThread()) { + action.run(); + return; + } + + // Queue on JavaFX thread and wait for completion + final CountDownLatch doneLatch = new CountDownLatch(1); + Platform.runLater(() -> { + try { + action.run(); + } finally { + doneLatch.countDown(); + } + }); + + try { + doneLatch.await(); + } catch (InterruptedException e) { + LOGGER.error("Problem running action on JavaFX thread", e); + } + } + public static void runInJavaFXThread(Runnable runnable) { Platform.runLater(runnable); }