Skip to content

Commit

Permalink
Fix automaticalls set file links task not runinng
Browse files Browse the repository at this point in the history
Executing the created task would have been helpful...

Fixes #5023
  • Loading branch information
Siedlerchr committed Jun 15, 2019
1 parent d811c17 commit 332257a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ private MenuBar createMenu() {

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.SET_FILE_LINKS, new AutoLinkFilesAction(this, prefs, stateManager, undoManager))
factory.createMenuItem(StandardActions.SET_FILE_LINKS, new AutoLinkFilesAction(this, prefs, stateManager, undoManager, Globals.TASK_EXECUTOR))
);

// PushToApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.gui.util.BindingsHelper;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
Expand All @@ -31,12 +32,14 @@ public class AutoLinkFilesAction extends SimpleCommand {
private final JabRefPreferences preferences;
private final StateManager stateManager;
private UndoManager undoManager;
private TaskExecutor taskExecutor;

public AutoLinkFilesAction(JabRefFrame frame, JabRefPreferences preferences, StateManager stateManager, UndoManager undoManager) {
public AutoLinkFilesAction(JabRefFrame frame, JabRefPreferences preferences, StateManager stateManager, UndoManager undoManager, TaskExecutor taskExecutor) {
this.dialogService = frame.getDialogService();
this.preferences = preferences;
this.stateManager = stateManager;
this.undoManager = undoManager;
this.taskExecutor = taskExecutor;

this.executable.bind(needsDatabase(this.stateManager).and(needsEntriesSelected(stateManager)));
this.statusMessage.bind(BindingsHelper.ifThenElse(executable, "", Localization.lang("This operation requires one or more entries to be selected.")));
Expand All @@ -51,6 +54,7 @@ public void execute() {
final NamedCompound nc = new NamedCompound(Localization.lang("Automatically set file links"));
AutoSetFileLinksUtil util = new AutoSetFileLinksUtil(database, preferences.getFilePreferences(), preferences.getAutoLinkPreferences(), ExternalFileTypes.getInstance());
Task<List<BibEntry>> linkFilesTask = new Task<List<BibEntry>>() {

@Override
protected List<BibEntry> call() {
return util.linkAssociatedFiles(entries, nc);
Expand All @@ -71,9 +75,9 @@ protected void succeeded() {
};

dialogService.showProgressDialogAndWait(
Localization.lang("Automatically setting file links"),
Localization.lang("Searching for files"),
linkFilesTask
);
Localization.lang("Automatically setting file links"),
Localization.lang("Searching for files"),
linkFilesTask);
taskExecutor.execute(linkFilesTask);
}
}

0 comments on commit 332257a

Please sign in to comment.