From f58ab67665849d2045dd99f0fe1b74734a60848f Mon Sep 17 00:00:00 2001 From: Christoph Date: Sat, 19 Feb 2022 20:37:38 +0100 Subject: [PATCH] Revert "Fix for Indexing stopping while having library modification (#8469)" (#8511) This reverts commit d6fec0b54ad37f55c95e7438bd3604dedb133abc. --- CHANGELOG.md | 1 - src/main/java/org/jabref/gui/LibraryTab.java | 6 +++- .../search/indexing/IndexingTaskManager.java | 29 +------------------ 3 files changed, 6 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38e1f5c6923..b5acae7ecbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,6 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where an exception could occur when saving the preferences [#7614](https://github.com/JabRef/jabref/issues/7614) - We fixed an issue where "Copy DOI url" in the right-click menu of the Entry List would just copy the DOI and not the DOI url. [#8389](https://github.com/JabRef/jabref/issues/8389) - We fixed an issue where opening the console from the drop-down menu would cause an exception. [#8466](https://github.com/JabRef/jabref/issues/8466) -- We fixed an issue where modifying a library would trigger reindexing of all PDFs [#8420](https://github.com/JabRef/jabref/issues/8420) ### Removed diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java index b5603efe228..2a50b1fa373 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -108,7 +108,7 @@ public class LibraryTab extends Tab { // initializing it so we prevent NullPointerException private BackgroundTask dataLoadingTask = BackgroundTask.wrap(() -> null); - private final IndexingTaskManager indexingTaskManager = new IndexingTaskManager(Globals.TASK_EXECUTOR, bibDatabaseContext); + private final IndexingTaskManager indexingTaskManager = new IndexingTaskManager(Globals.TASK_EXECUTOR); public LibraryTab(JabRefFrame frame, PreferencesService preferencesService, @@ -337,6 +337,10 @@ public void updateTabTitle(boolean isChanged) { textProperty().setValue(tabTitle.toString()); setTooltip(new Tooltip(toolTipText.toString())); }); + + if (preferencesService.getFilePreferences().shouldFulltextIndexLinkedFiles()) { + indexingTaskManager.updateDatabaseName(tabTitle.toString()); + } } private List collectAllDatabasePaths() { diff --git a/src/main/java/org/jabref/logic/pdf/search/indexing/IndexingTaskManager.java b/src/main/java/org/jabref/logic/pdf/search/indexing/IndexingTaskManager.java index 8cad27add76..3144cd07384 100644 --- a/src/main/java/org/jabref/logic/pdf/search/indexing/IndexingTaskManager.java +++ b/src/main/java/org/jabref/logic/pdf/search/indexing/IndexingTaskManager.java @@ -1,8 +1,6 @@ package org.jabref.logic.pdf.search.indexing; -import java.nio.file.Path; import java.util.List; -import java.util.Optional; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; @@ -13,7 +11,6 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; -import org.jabref.model.entry.event.EntryChangedEvent; /** * Wrapper around {@link PdfIndexer} to execute all operations in the background. @@ -22,16 +19,14 @@ public class IndexingTaskManager extends BackgroundTask { private final Queue taskQueue = new ConcurrentLinkedQueue<>(); private TaskExecutor taskExecutor; - private final BibDatabaseContext bibDatabaseContext; private int numOfIndexedFiles = 0; private final Object lock = new Object(); private boolean isRunning = false; private boolean isBlockingNewTasks = false; - public IndexingTaskManager(TaskExecutor taskExecutor, BibDatabaseContext bibDatabaseContext) { + public IndexingTaskManager(TaskExecutor taskExecutor) { this.taskExecutor = taskExecutor; - this.bibDatabaseContext = bibDatabaseContext; showToUser(true); DefaultTaskExecutor.runInJavaFXThread(() -> { this.updateProgress(1, 1); @@ -120,29 +115,7 @@ public void removeFromIndex(PdfIndexer indexer, BibEntry entry) { enqueueTask(() -> removeFromIndex(indexer, entry, entry.getFiles())); } - public void updateDatabaseName() { - Optional file = bibDatabaseContext.getDatabasePath(); - - String name = ""; - - try { - name = bibDatabaseContext.getDatabasePath().toString(); - } finally { - if (file.isPresent()) { - Path databasePath = file.get(); - name = databasePath.getFileName().toString(); - } - - String fileName = name; - DefaultTaskExecutor.runInJavaFXThread(() -> this.titleProperty().set(Localization.lang("Indexing for %0", fileName))); - } - } - public void updateDatabaseName(String name) { DefaultTaskExecutor.runInJavaFXThread(() -> this.titleProperty().set(Localization.lang("Indexing for %0", name))); } - - public void listen(EntryChangedEvent event) { - updateDatabaseName(); - } }