From 96b9aa54c06e4e690fb400a7be2f6aa696c83128 Mon Sep 17 00:00:00 2001 From: Robin Lichtenthaeler Date: Mon, 9 Sep 2019 09:15:54 +0200 Subject: [PATCH] UiThreadHelper package-private and usage of UiThreadListDecorator only in View not in Model --- .../java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java | 5 ++++- .../jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java | 3 +-- .../org/jabref/gui/util/uithreadaware/UiThreadHelper.java | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java index ccbf0b75d54..bf3290ef391 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java @@ -34,6 +34,7 @@ import org.jabref.gui.keyboard.KeyBinding; import org.jabref.gui.util.TaskExecutor; import org.jabref.gui.util.ViewModelListCellFactory; +import org.jabref.gui.util.uithreadaware.UiThreadListDecorator; import org.jabref.logic.integrity.FieldCheckers; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; @@ -51,6 +52,7 @@ public class LinkedFilesEditor extends HBox implements FieldEditorFX { private final DialogService dialogService; private final BibDatabaseContext databaseContext; + private final UiThreadListDecorator decoratedModelList; public LinkedFilesEditor(Field field, DialogService dialogService, BibDatabaseContext databaseContext, TaskExecutor taskExecutor, AutoCompleteSuggestionProvider suggestionProvider, FieldCheckers fieldCheckers, @@ -74,7 +76,8 @@ public LinkedFilesEditor(Field field, DialogService dialogService, BibDatabaseCo listView.setCellFactory(cellFactory); - Bindings.bindContentBidirectional(listView.itemsProperty().get(), viewModel.filesProperty()); + decoratedModelList = new UiThreadListDecorator<>(viewModel.filesProperty()); + Bindings.bindContentBidirectional(listView.itemsProperty().get(), decoratedModelList); setUpKeyBindings(); } diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java index b59c842df9b..471af98aa2f 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java @@ -27,7 +27,6 @@ import org.jabref.gui.util.BindingsHelper; import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.gui.util.TaskExecutor; -import org.jabref.gui.util.uithreadaware.UiThreadListDecorator; import org.jabref.logic.importer.FulltextFetchers; import org.jabref.logic.integrity.FieldCheckers; import org.jabref.logic.l10n.Localization; @@ -44,7 +43,7 @@ public class LinkedFilesEditorViewModel extends AbstractEditorViewModel { - private final ListProperty files = new SimpleListProperty<>(new UiThreadListDecorator<>(FXCollections.observableArrayList(LinkedFileViewModel::getObservables))); + private final ListProperty files = new SimpleListProperty<>(FXCollections.observableArrayList(LinkedFileViewModel::getObservables)); private final BooleanProperty fulltextLookupInProgress = new SimpleBooleanProperty(false); private final DialogService dialogService; private final BibDatabaseContext databaseContext; diff --git a/src/main/java/org/jabref/gui/util/uithreadaware/UiThreadHelper.java b/src/main/java/org/jabref/gui/util/uithreadaware/UiThreadHelper.java index 1ea074c1bd3..b7590055eb9 100644 --- a/src/main/java/org/jabref/gui/util/uithreadaware/UiThreadHelper.java +++ b/src/main/java/org/jabref/gui/util/uithreadaware/UiThreadHelper.java @@ -2,7 +2,7 @@ import javafx.application.Platform; -public class UiThreadHelper { +class UiThreadHelper { static void ensureUiThreadExecution(Runnable task) { if (Platform.isFxApplicationThread()) {