Skip to content

Commit

Permalink
Revert 2c8fc01 (#11818)
Browse files Browse the repository at this point in the history
* Revert 2c8fc01

* Change setRetainTasks

---------

Co-authored-by: Subhramit Basu Bhowmick <subhramit.bb@live.in>
  • Loading branch information
calixtus and subhramit authored Sep 23, 2024
1 parent 61f7c1e commit 31af5d8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 30 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/JabRefDialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public <V> void showProgressDialogAndWait(String title, String content, Task<V>
@Override
public Optional<ButtonType> showBackgroundProgressDialogAndWait(String title, String content, StateManager stateManager) {
TaskProgressView<Task<?>> 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));

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/jabref/gui/StateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -153,9 +152,8 @@ public Optional<Node> getFocusOwner() {
return focusOwner.get();
}

public ObservableList<Task<?>> getRunningBackgroundTasks() {
FilteredList<Pair<BackgroundTask<?>, Task<?>>> pairs = new FilteredList<>(backgroundTasks, task -> task.getValue().isRunning());
return EasyBind.map(pairs, Pair::getValue);
public ObservableList<Task<?>> getBackgroundTasks() {
return EasyBind.map(backgroundTasks, Pair::getValue);
}

public void addBackgroundTask(BackgroundTask<?> backgroundTask, Task<?> task) {
Expand Down
31 changes: 16 additions & 15 deletions src/main/java/org/jabref/gui/frame/MainToolBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -66,7 +65,6 @@ public class MainToolBar extends ToolBar {

private PopOver entryFromIdPopOver;
private PopOver progressViewPopOver;
private Subscription taskProgressSubscription;

public MainToolBar(LibraryTabContainer tabContainer,
PushToApplicationCommand pushToApplicationCommand,
Expand Down Expand Up @@ -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());
}
Expand All @@ -226,24 +228,23 @@ Group createTaskIndicator() {
});

indicator.setOnMouseClicked(event -> {
if ((progressViewPopOver != null) && (progressViewPopOver.isShowing())) {
progressViewPopOver.hide();
taskProgressSubscription.unsubscribe();
}

TaskProgressView<Task<?>> taskProgressView = new TaskProgressView<>();
taskProgressSubscription = EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getRunningBackgroundTasks());
EasyBind.bindContent(taskProgressView.getTasks(), stateManager.getBackgroundTasks());
taskProgressView.setRetainTasks(false);
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);
Expand Down
13 changes: 4 additions & 9 deletions src/main/java/org/jabref/gui/util/UiTaskExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public <V> Future<?> schedule(BackgroundTask<V> 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();
Expand Down Expand Up @@ -193,14 +193,9 @@ protected V call() throws Exception {
javaTask.setOnRunning(event -> onRunning.run());
}
Consumer<V> 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<Exception> onException = task.getOnException();
if (onException != null) {
javaTask.setOnFailed(event -> onException.accept(convertToException(javaTask.getException())));
Expand Down

0 comments on commit 31af5d8

Please sign in to comment.