diff --git a/src/main/java/org/jabref/gui/DefaultInjector.java b/src/main/java/org/jabref/gui/DefaultInjector.java index cf93ad54b38..678f91db32f 100644 --- a/src/main/java/org/jabref/gui/DefaultInjector.java +++ b/src/main/java/org/jabref/gui/DefaultInjector.java @@ -3,7 +3,6 @@ import java.util.function.Function; import org.jabref.gui.keyboard.KeyBindingRepository; -import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.protectedterms.ProtectedTermsLoader; import org.jabref.model.util.FileUpdateMonitor; @@ -23,9 +22,7 @@ public class DefaultInjector implements PresenterFactory { * Dependencies without default constructor are constructed by hand. */ private static Object createDependency(Class> clazz) { - if (clazz == TaskExecutor.class) { - return Globals.TASK_EXECUTOR; - } else if (clazz == KeyBindingRepository.class) { + if (clazz == KeyBindingRepository.class) { return Globals.getKeyPrefs(); } else if (clazz == JournalAbbreviationRepository.class) { return Globals.journalAbbreviationRepository; diff --git a/src/main/java/org/jabref/gui/Globals.java b/src/main/java/org/jabref/gui/Globals.java index e3c0f4ef225..b450a5fad51 100644 --- a/src/main/java/org/jabref/gui/Globals.java +++ b/src/main/java/org/jabref/gui/Globals.java @@ -4,8 +4,6 @@ import org.jabref.gui.keyboard.KeyBindingRepository; import org.jabref.gui.util.DefaultDirectoryMonitor; import org.jabref.gui.util.DefaultFileUpdateMonitor; -import org.jabref.gui.util.DefaultTaskExecutor; -import org.jabref.gui.util.TaskExecutor; import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.protectedterms.ProtectedTermsLoader; import org.jabref.logic.remote.server.RemoteListenerServerManager; @@ -30,8 +28,6 @@ public class Globals { public static final RemoteListenerServerManager REMOTE_LISTENER = new RemoteListenerServerManager(); - public static final TaskExecutor TASK_EXECUTOR = new DefaultTaskExecutor(); - /** * This field is initialized upon startup. *
@@ -84,17 +80,4 @@ public static DirectoryMonitor getDirectoryMonitor() {
}
return directoryMonitor;
}
-
- public static void shutdownThreadPools() {
- TASK_EXECUTOR.shutdown();
- if (fileUpdateMonitor != null) {
- fileUpdateMonitor.shutdown();
- }
-
- if (directoryMonitor != null) {
- directoryMonitor.shutdown();
- }
-
- JabRefExecutorService.INSTANCE.shutdownEverything();
- }
}
diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java
index d18a36a4089..2c6f185e666 100644
--- a/src/main/java/org/jabref/gui/JabRefGUI.java
+++ b/src/main/java/org/jabref/gui/JabRefGUI.java
@@ -22,6 +22,8 @@
import org.jabref.gui.telemetry.Telemetry;
import org.jabref.gui.theme.ThemeManager;
import org.jabref.gui.undo.CountingUndoManager;
+import org.jabref.gui.util.DefaultTaskExecutor;
+import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.UiCommand;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.net.ProxyRegisterer;
@@ -55,6 +57,7 @@ public class JabRefGUI extends Application {
private static StateManager stateManager;
private static CountingUndoManager countingUndoManager;
+ private static TaskExecutor taskExecutor;
private boolean correctedWindowPos = false;
private Stage mainStage;
@@ -91,6 +94,9 @@ public void start(Stage stage) {
Injector.setModelOrService(UndoManager.class, countingUndoManager);
Injector.setModelOrService(CountingUndoManager.class, countingUndoManager);
+ JabRefGUI.taskExecutor = new DefaultTaskExecutor();
+ Injector.setModelOrService(TaskExecutor.class, taskExecutor);
+
JabRefGUI.mainFrame = new JabRefFrame(
mainStage,
dialogService,
@@ -99,7 +105,7 @@ public void start(Stage stage) {
stateManager,
countingUndoManager,
Injector.instantiateModelOrService(BibEntryTypesManager.class),
- Globals.TASK_EXECUTOR);
+ taskExecutor);
openWindow();
@@ -114,7 +120,7 @@ public void start(Stage stage) {
if (enabled) {
new VersionWorker(Globals.BUILD_INFO.version,
dialogService,
- Globals.TASK_EXECUTOR,
+ taskExecutor,
preferencesService)
.checkForNewVersionDelayed();
}
@@ -123,13 +129,6 @@ public void start(Stage stage) {
setupProxy();
}
- @Override
- public void stop() {
- OOBibBaseConnect.closeOfficeConnection();
- stopBackgroundTasks();
- Globals.shutdownThreadPools();
- }
-
private void setupProxy() {
if (!preferencesService.getProxyPreferences().shouldUseProxy()
|| !preferencesService.getProxyPreferences().shouldUseAuthentication()) {
@@ -267,6 +266,7 @@ private boolean isWindowPositionOutOfBounds() {
preferencesService.getGuiPreferences().getPositionY());
}
+
// Background tasks
public void startBackgroundTasks() {
// TODO Currently deactivated due to incompatibilities in XML
@@ -284,11 +284,25 @@ public void startBackgroundTasks() {
}
}
+ @Override
+ public void stop() {
+ OOBibBaseConnect.closeOfficeConnection();
+ stopBackgroundTasks();
+ shutdownThreadPools();
+ }
+
public void stopBackgroundTasks() {
Telemetry.shutdown();
Unirest.shutDown();
}
+ public static void shutdownThreadPools() {
+ taskExecutor.shutdown();
+ Globals.getFileUpdateMonitor().shutdown();
+ Globals.getDirectoryMonitor().shutdown();
+ JabRefExecutorService.INSTANCE.shutdownEverything();
+ }
+
public static JabRefFrame getMainFrame() {
return mainFrame;
}
diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
index 759c46fc0ad..bb5bf410d57 100644
--- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
+++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
@@ -298,8 +298,15 @@ private List> citingTask;
private static BackgroundTask
> citedByTask;
- private final EntryEditorPreferences preferences;
private final DialogService dialogService;
private final BibDatabaseContext databaseContext;
- private final UndoManager undoManager;
- private final StateManager stateManager;
- private final FileUpdateMonitor fileUpdateMonitor;
private final PreferencesService preferencesService;
private final LibraryTab libraryTab;
private final TaskExecutor taskExecutor;
@@ -79,16 +73,16 @@ public class CitationRelationsTab extends EntryEditorTab {
private final CitationsRelationsTabViewModel citationsRelationsTabViewModel;
private final DuplicateCheck duplicateCheck;
- public CitationRelationsTab(EntryEditorPreferences preferences, DialogService dialogService,
- BibDatabaseContext databaseContext, UndoManager undoManager,
- StateManager stateManager, FileUpdateMonitor fileUpdateMonitor,
- PreferencesService preferencesService, LibraryTab lTab, TaskExecutor taskExecutor) {
- this.preferences = preferences;
+ public CitationRelationsTab(DialogService dialogService,
+ BibDatabaseContext databaseContext,
+ UndoManager undoManager,
+ StateManager stateManager,
+ FileUpdateMonitor fileUpdateMonitor,
+ PreferencesService preferencesService,
+ LibraryTab lTab,
+ TaskExecutor taskExecutor) {
this.dialogService = dialogService;
this.databaseContext = databaseContext;
- this.undoManager = undoManager;
- this.stateManager = stateManager;
- this.fileUpdateMonitor = fileUpdateMonitor;
this.preferencesService = preferencesService;
this.libraryTab = lTab;
this.taskExecutor = taskExecutor;
@@ -98,7 +92,7 @@ public CitationRelationsTab(EntryEditorPreferences preferences, DialogService di
this.duplicateCheck = new DuplicateCheck(new BibEntryTypesManager());
this.bibEntryRelationsRepository = new BibEntryRelationsRepository(new SemanticScholarFetcher(preferencesService.getImporterPreferences()),
new BibEntryRelationsCache());
- citationsRelationsTabViewModel = new CitationsRelationsTabViewModel(databaseContext, preferencesService, undoManager, stateManager, dialogService, fileUpdateMonitor, Globals.TASK_EXECUTOR);
+ citationsRelationsTabViewModel = new CitationsRelationsTabViewModel(databaseContext, preferencesService, undoManager, stateManager, dialogService, fileUpdateMonitor, taskExecutor);
}
/**
diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java
index c02ce45380e..405425c0f8f 100644
--- a/src/main/java/org/jabref/preferences/JabRefPreferences.java
+++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java
@@ -2159,6 +2159,7 @@ public WorkspacePreferences getWorkspacePreferences() {
Localization.setLanguage(newValue);
}
});
+
EasyBind.listen(workspacePreferences.shouldOverrideDefaultFontSizeProperty(), (obs, oldValue, newValue) -> putBoolean(OVERRIDE_DEFAULT_FONT_SIZE, newValue));
EasyBind.listen(workspacePreferences.mainFontSizeProperty(), (obs, oldValue, newValue) -> putInt(MAIN_FONT_SIZE, newValue));
EasyBind.listen(workspacePreferences.themeProperty(), (obs, oldValue, newValue) -> put(THEME, newValue.getName()));