From ad120910bae5728809db5451fd6d1ec3a712801a Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Mon, 23 Sep 2024 21:52:32 +0200 Subject: [PATCH] Revert 2c8fc01 --- CHANGELOG.md | 1 - .../org/jabref/gui/JabRefDialogService.java | 2 +- .../java/org/jabref/gui/StateManager.java | 6 ++-- .../org/jabref/gui/frame/MainToolBar.java | 33 ++++++++++--------- .../org/jabref/gui/util/UiTaskExecutor.java | 13 +++----- 5 files changed, 24 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26b802b3240..3b3bfbb78dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,6 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - The Pubmed/Medline Plain importer now imports the PMID field as well [#11488](https://github.com/JabRef/jabref/issues/11488) - The 'Check for updates' menu bar button is now always enabled. [#11485](https://github.com/JabRef/jabref/pull/11485) - JabRef respects the [configuration for storing files relative to the .bib file](https://docs.jabref.org/finding-sorting-and-cleaning-entries/filelinks#directories-for-files) in more cases. [#11492](https://github.com/JabRef/jabref/pull/11492) -- JabRef does not show finished background tasks in the status bar popup. [#11574](https://github.com/JabRef/jabref/pull/11574) - We enhanced the indexing speed. [#11502](https://github.com/JabRef/jabref/pull/11502) - ⚠️ Renamed command line parameters `embeddBibfileInPdf` to `embedBibFileInPdf`, `writeMetadatatoPdf` to `writeMetadataToPdf`, and `writeXMPtoPdf` to `writeXmpToPdf`. [#11575](https://github.com/JabRef/jabref/pull/11575) - The browse button for a Custom theme now opens in the directory of the current used CSS file. [#11597](https://github.com/JabRef/jabref/pull/11597) diff --git a/src/main/java/org/jabref/gui/JabRefDialogService.java b/src/main/java/org/jabref/gui/JabRefDialogService.java index dccdc17898d..a1d97316a25 100644 --- a/src/main/java/org/jabref/gui/JabRefDialogService.java +++ b/src/main/java/org/jabref/gui/JabRefDialogService.java @@ -379,7 +379,7 @@ public void showProgressDialogAndWait(String title, String content, Task @Override public Optional showBackgroundProgressDialogAndWait(String title, String content, StateManager stateManager) { TaskProgressView> taskProgressView = new TaskProgressView<>(); - EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getRunningBackgroundTasks()); + EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getBackgroundTasks()); taskProgressView.setRetainTasks(false); taskProgressView.setGraphicFactory(task -> ThemeManager.getDownloadIconTitleMap.getOrDefault(task.getTitle(), null)); diff --git a/src/main/java/org/jabref/gui/StateManager.java b/src/main/java/org/jabref/gui/StateManager.java index cf73b00da94..94c4a359467 100644 --- a/src/main/java/org/jabref/gui/StateManager.java +++ b/src/main/java/org/jabref/gui/StateManager.java @@ -13,7 +13,6 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.collections.ObservableMap; -import javafx.collections.transformation.FilteredList; import javafx.concurrent.Task; import javafx.scene.Node; import javafx.util.Pair; @@ -153,9 +152,8 @@ public Optional getFocusOwner() { return focusOwner.get(); } - public ObservableList> getRunningBackgroundTasks() { - FilteredList, Task>> pairs = new FilteredList<>(backgroundTasks, task -> task.getValue().isRunning()); - return EasyBind.map(pairs, Pair::getValue); + public ObservableList> getBackgroundTasks() { + return EasyBind.map(backgroundTasks, Pair::getValue); } public void addBackgroundTask(BackgroundTask backgroundTask, Task task) { diff --git a/src/main/java/org/jabref/gui/frame/MainToolBar.java b/src/main/java/org/jabref/gui/frame/MainToolBar.java index 2f61f953c62..8a44ee1ff6e 100644 --- a/src/main/java/org/jabref/gui/frame/MainToolBar.java +++ b/src/main/java/org/jabref/gui/frame/MainToolBar.java @@ -46,7 +46,6 @@ import org.jabref.model.util.FileUpdateMonitor; import com.tobiasdiez.easybind.EasyBind; -import com.tobiasdiez.easybind.Subscription; import org.controlsfx.control.PopOver; import org.controlsfx.control.TaskProgressView; @@ -66,7 +65,6 @@ public class MainToolBar extends ToolBar { private PopOver entryFromIdPopOver; private PopOver progressViewPopOver; - private Subscription taskProgressSubscription; public MainToolBar(LibraryTabContainer tabContainer, PushToApplicationCommand pushToApplicationCommand, @@ -211,11 +209,15 @@ Group createTaskIndicator() { } }); - // The label of the indicator cannot be removed with styling. Therefore, - // hide it and clip it to a square of (width x width) each time width is updated. + /* + The label of the indicator cannot be removed with styling. Therefore, + hide it and clip it to a square of (width x width) each time width is updated. + */ indicator.widthProperty().addListener((observable, oldValue, newValue) -> { - // The indeterminate spinner is wider than the determinate spinner. - // We must make sure they are the same width for the clipping to result in a square of the same size always. + /* + The indeterminate spinner is wider than the determinate spinner. + We must make sure they are the same width for the clipping to result in a square of the same size always. + */ if (!indicator.isIndeterminate()) { indicator.setPrefWidth(newValue.doubleValue()); } @@ -226,24 +228,23 @@ Group createTaskIndicator() { }); indicator.setOnMouseClicked(event -> { - if ((progressViewPopOver != null) && (progressViewPopOver.isShowing())) { - progressViewPopOver.hide(); - taskProgressSubscription.unsubscribe(); - } - TaskProgressView> taskProgressView = new TaskProgressView<>(); - taskProgressSubscription = EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getRunningBackgroundTasks()); - taskProgressView.setRetainTasks(false); + EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getBackgroundTasks()); + taskProgressView.setRetainTasks(true); taskProgressView.setGraphicFactory(task -> ThemeManager.getDownloadIconTitleMap.getOrDefault(task.getTitle(), null)); if (progressViewPopOver == null) { progressViewPopOver = new PopOver(taskProgressView); progressViewPopOver.setTitle(Localization.lang("Background Tasks")); progressViewPopOver.setArrowLocation(PopOver.ArrowLocation.RIGHT_TOP); + progressViewPopOver.setContentNode(taskProgressView); + progressViewPopOver.show(indicator); + } else if (progressViewPopOver.isShowing()) { + progressViewPopOver.hide(); + } else { + progressViewPopOver.setContentNode(taskProgressView); + progressViewPopOver.show(indicator); } - - progressViewPopOver.setContentNode(taskProgressView); - progressViewPopOver.show(indicator); }); return new Group(indicator); diff --git a/src/main/java/org/jabref/gui/util/UiTaskExecutor.java b/src/main/java/org/jabref/gui/util/UiTaskExecutor.java index 15aeaf0105c..946200e8d49 100644 --- a/src/main/java/org/jabref/gui/util/UiTaskExecutor.java +++ b/src/main/java/org/jabref/gui/util/UiTaskExecutor.java @@ -145,7 +145,7 @@ public Future schedule(BackgroundTask task, long delay, TimeUnit unit) public void shutdown() { StateManager stateManager = Injector.instantiateModelOrService(StateManager.class); if (stateManager != null) { - stateManager.getRunningBackgroundTasks().forEach(Task::cancel); + stateManager.getBackgroundTasks().stream().filter(task -> !task.isDone()).forEach(Task::cancel); } executor.shutdownNow(); scheduledExecutor.shutdownNow(); @@ -193,14 +193,9 @@ protected V call() throws Exception { javaTask.setOnRunning(event -> onRunning.run()); } Consumer onSuccess = task.getOnSuccess(); - javaTask.setOnSucceeded(event -> { - // Set to 100% completed on completion - task.updateProgress(1, 1); - - if (onSuccess != null) { - onSuccess.accept(javaTask.getValue()); - } - }); + if (onSuccess != null) { + javaTask.setOnSucceeded(event -> onSuccess.accept(javaTask.getValue())); + } Consumer onException = task.getOnException(); if (onException != null) { javaTask.setOnFailed(event -> onException.accept(convertToException(javaTask.getException())));