diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a59d8b478c..c24c3ff848e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ 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) ### Fixed diff --git a/src/main/java/org/jabref/gui/JabRefDialogService.java b/src/main/java/org/jabref/gui/JabRefDialogService.java index 5d22c87d89b..0ec2acdddd5 100644 --- a/src/main/java/org/jabref/gui/JabRefDialogService.java +++ b/src/main/java/org/jabref/gui/JabRefDialogService.java @@ -348,7 +348,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.getBackgroundTasks()); + EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getRunningBackgroundTasks()); taskProgressView.setRetainTasks(false); taskProgressView.setGraphicFactory(BackgroundTask::getIcon); diff --git a/src/main/java/org/jabref/gui/StateManager.java b/src/main/java/org/jabref/gui/StateManager.java index f2d2b955f80..792a6ba01b3 100644 --- a/src/main/java/org/jabref/gui/StateManager.java +++ b/src/main/java/org/jabref/gui/StateManager.java @@ -16,6 +16,7 @@ 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; @@ -185,8 +186,9 @@ public Optional getFocusOwner() { return focusOwner.get(); } - public ObservableList> getBackgroundTasks() { - return EasyBind.map(backgroundTasks, Pair::getValue); + public ObservableList> getRunningBackgroundTasks() { + FilteredList, Task>> pairs = new FilteredList<>(backgroundTasks, task -> task.getValue().isRunning()); + return EasyBind.map(pairs, 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 bb7589754ac..1bd99a42342 100644 --- a/src/main/java/org/jabref/gui/frame/MainToolBar.java +++ b/src/main/java/org/jabref/gui/frame/MainToolBar.java @@ -45,6 +45,7 @@ import org.jabref.preferences.PreferencesService; import com.tobiasdiez.easybind.EasyBind; +import com.tobiasdiez.easybind.Subscription; import org.controlsfx.control.PopOver; import org.controlsfx.control.TaskProgressView; @@ -63,6 +64,7 @@ public class MainToolBar extends ToolBar { private PopOver entryFromIdPopOver; private PopOver progressViewPopOver; + private Subscription taskProgressSubscription; public MainToolBar(LibraryTabContainer tabContainer, PushToApplicationCommand pushToApplicationCommand, @@ -201,15 +203,11 @@ 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()); } @@ -220,23 +218,24 @@ hide it and clip it to a square of (width x width) each time width is updated. }); indicator.setOnMouseClicked(event -> { + if ((progressViewPopOver != null) && (progressViewPopOver.isShowing())) { + progressViewPopOver.hide(); + taskProgressSubscription.unsubscribe(); + } + TaskProgressView> taskProgressView = new TaskProgressView<>(); - EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getBackgroundTasks()); - taskProgressView.setRetainTasks(true); + taskProgressSubscription = EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getRunningBackgroundTasks()); + taskProgressView.setRetainTasks(false); taskProgressView.setGraphicFactory(BackgroundTask::getIcon); 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 98ba40f2440..ae601831019 100644 --- a/src/main/java/org/jabref/gui/util/UiTaskExecutor.java +++ b/src/main/java/org/jabref/gui/util/UiTaskExecutor.java @@ -128,7 +128,7 @@ public Future schedule(BackgroundTask task, long delay, TimeUnit unit) public void shutdown() { StateManager stateManager = Injector.instantiateModelOrService(StateManager.class); if (stateManager != null) { - stateManager.getBackgroundTasks().stream().filter(task -> !task.isDone()).forEach(Task::cancel); + stateManager.getRunningBackgroundTasks().stream().forEach(Task::cancel); } executor.shutdownNow(); scheduledExecutor.shutdownNow(); @@ -175,9 +175,14 @@ public V call() throws Exception { javaTask.setOnRunning(event -> onRunning.run()); } Consumer onSuccess = task.getOnSuccess(); - if (onSuccess != null) { - javaTask.setOnSucceeded(event -> onSuccess.accept(javaTask.getValue())); - } + javaTask.setOnSucceeded(event -> { + // Set to 100% completed on completion + task.updateProgress(1, 1); + + if (onSuccess != null) { + onSuccess.accept(javaTask.getValue()); + } + }); Consumer onException = task.getOnException(); if (onException != null) { javaTask.setOnFailed(event -> onException.accept(convertToException(javaTask.getException())));