Skip to content

Commit

Permalink
Don't register any database changes to the indexer while dropping a f…
Browse files Browse the repository at this point in the history
…ile (#8334)

* Don't register any database changes to the indexer while dropping a file

* Changelog

* Use try-with-resources construct

* Moved blocking to ExternalFilesEntryLinker
  • Loading branch information
btut authored Dec 17, 2021
1 parent 5792f0f commit 144a37d
Show file tree
Hide file tree
Showing 15 changed files with 112 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where an exception would occur when clicking on a DOI link in the preview pane [#7706](https://github.com/JabRef/jabref/issues/7706)
- We fixed an issue where XMP and embedded BibTeX export would not work [#8278](https://github.com/JabRef/jabref/issues/8278)
- We fixed an issue where the XMP and embedded BibTeX import of a file containing multiple schemas failed [#8278](https://github.com/JabRef/jabref/issues/8278)
- We fixed an issue where pdf-paths and the pdf-indexer could get out of sync [#8182](https://github.com/JabRef/jabref/issues/8182)


### Removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.pdf.search.indexing.IndexingTaskManager;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryType;
Expand All @@ -33,11 +34,12 @@ public DeprecatedFieldsTab(BibDatabaseContext databaseContext,
DialogService dialogService,
PreferencesService preferences,
StateManager stateManager,
IndexingTaskManager indexingTaskManager,
BibEntryTypesManager entryTypesManager,
ExternalFileTypes externalFileTypes,
TaskExecutor taskExecutor,
JournalAbbreviationRepository journalAbbreviationRepository) {
super(false, databaseContext, suggestionProviders, undoManager, dialogService, preferences, stateManager, externalFileTypes, taskExecutor, journalAbbreviationRepository);
super(false, databaseContext, suggestionProviders, undoManager, dialogService, preferences, stateManager, externalFileTypes, taskExecutor, journalAbbreviationRepository, indexingTaskManager);
this.entryTypesManager = entryTypesManager;

setText(Localization.lang("Deprecated fields"));
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ public EntryEditor(LibraryTab libraryTab, ExternalFileTypes externalFileTypes) {
switch (event.getTransferMode()) {
case COPY -> {
LOGGER.debug("Mode COPY");
fileLinker.copyFilesToFileDirAndAddToEntry(entry, files);
fileLinker.copyFilesToFileDirAndAddToEntry(entry, files, libraryTab.getIndexingTaskManager());
}
case MOVE -> {
LOGGER.debug("Mode MOVE");
fileLinker.moveFilesToFileDirAndAddToEntry(entry, files);
fileLinker.moveFilesToFileDirAndAddToEntry(entry, files, libraryTab.getIndexingTaskManager());
}
case LINK -> {
LOGGER.debug("Mode LINK");
Expand Down Expand Up @@ -233,22 +233,22 @@ private void navigateToNextEntry() {

private List<EntryEditorTab> createTabs() {
// Preview tab
entryEditorTabs.add(new PreviewTab(databaseContext, dialogService, preferencesService, stateManager, ExternalFileTypes.getInstance()));
entryEditorTabs.add(new PreviewTab(databaseContext, dialogService, preferencesService, stateManager, libraryTab.getIndexingTaskManager(), ExternalFileTypes.getInstance()));

// Required fields
entryEditorTabs.add(new RequiredFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, Globals.entryTypesManager, ExternalFileTypes.getInstance(), Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository));
entryEditorTabs.add(new RequiredFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, libraryTab.getIndexingTaskManager(), Globals.entryTypesManager, ExternalFileTypes.getInstance(), Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository));

// Optional fields
entryEditorTabs.add(new OptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, Globals.entryTypesManager, ExternalFileTypes.getInstance(), Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository));
entryEditorTabs.add(new OptionalFields2Tab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, Globals.entryTypesManager, ExternalFileTypes.getInstance(), Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository));
entryEditorTabs.add(new DeprecatedFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, Globals.entryTypesManager, ExternalFileTypes.getInstance(), Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository));
entryEditorTabs.add(new OptionalFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, libraryTab.getIndexingTaskManager(), Globals.entryTypesManager, ExternalFileTypes.getInstance(), Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository));
entryEditorTabs.add(new OptionalFields2Tab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, libraryTab.getIndexingTaskManager(), Globals.entryTypesManager, ExternalFileTypes.getInstance(), Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository));
entryEditorTabs.add(new DeprecatedFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, libraryTab.getIndexingTaskManager(), Globals.entryTypesManager, ExternalFileTypes.getInstance(), Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository));

// Other fields
entryEditorTabs.add(new OtherFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, Globals.entryTypesManager, ExternalFileTypes.getInstance(), Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository));
entryEditorTabs.add(new OtherFieldsTab(databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, libraryTab.getIndexingTaskManager(), Globals.entryTypesManager, ExternalFileTypes.getInstance(), Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository));

// General fields from preferences
for (Map.Entry<String, Set<Field>> tab : entryEditorPreferences.getEntryEditorTabList().entrySet()) {
entryEditorTabs.add(new UserDefinedFieldsTab(tab.getKey(), tab.getValue(), databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, Globals.entryTypesManager, ExternalFileTypes.getInstance(), Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository));
entryEditorTabs.add(new UserDefinedFieldsTab(tab.getKey(), tab.getValue(), databaseContext, libraryTab.getSuggestionProviders(), undoManager, dialogService, preferencesService, stateManager, libraryTab.getIndexingTaskManager(), Globals.entryTypesManager, ExternalFileTypes.getInstance(), Globals.TASK_EXECUTOR, Globals.journalAbbreviationRepository));
}

// Special tabs
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.jabref.gui.preview.PreviewPanel;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.pdf.search.indexing.IndexingTaskManager;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.Field;
Expand All @@ -52,6 +53,7 @@ abstract class FieldsEditorTab extends EntryEditorTab {
private final TaskExecutor taskExecutor;
private final JournalAbbreviationRepository journalAbbreviationRepository;
private final StateManager stateManager;
private final IndexingTaskManager indexingTaskManager;
private PreviewPanel previewPanel;
private final UndoManager undoManager;
private Collection<Field> fields = new ArrayList<>();
Expand All @@ -66,7 +68,7 @@ public FieldsEditorTab(boolean compressed,
StateManager stateManager,
ExternalFileTypes externalFileTypes,
TaskExecutor taskExecutor,
JournalAbbreviationRepository journalAbbreviationRepository) {
JournalAbbreviationRepository journalAbbreviationRepository, IndexingTaskManager indexingTaskManager) {
this.isCompressed = compressed;
this.databaseContext = Objects.requireNonNull(databaseContext);
this.suggestionProviders = Objects.requireNonNull(suggestionProviders);
Expand All @@ -77,6 +79,7 @@ public FieldsEditorTab(boolean compressed,
this.taskExecutor = Objects.requireNonNull(taskExecutor);
this.journalAbbreviationRepository = Objects.requireNonNull(journalAbbreviationRepository);
this.stateManager = stateManager;
this.indexingTaskManager = indexingTaskManager;
}

private static void addColumn(GridPane gridPane, int columnIndex, List<Label> nodes) {
Expand Down Expand Up @@ -230,7 +233,7 @@ private void initPanel() {

SplitPane container = new SplitPane(scrollPane);
if (!preferences.getPreviewPreferences().showPreviewAsExtraTab()) {
previewPanel = new PreviewPanel(databaseContext, dialogService, externalFileTypes, preferences.getKeyBindingRepository(), preferences, stateManager);
previewPanel = new PreviewPanel(databaseContext, dialogService, externalFileTypes, preferences.getKeyBindingRepository(), preferences, stateManager, indexingTaskManager);
container.getItems().add(previewPanel);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.pdf.search.indexing.IndexingTaskManager;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.preferences.PreferencesService;
Expand All @@ -20,6 +21,7 @@ public OptionalFields2Tab(BibDatabaseContext databaseContext,
DialogService dialogService,
PreferencesService preferences,
StateManager stateManager,
IndexingTaskManager indexingTaskManager,
BibEntryTypesManager entryTypesManager,
ExternalFileTypes externalFileTypes,
TaskExecutor taskExecutor,
Expand All @@ -33,6 +35,7 @@ public OptionalFields2Tab(BibDatabaseContext databaseContext,
dialogService,
preferences,
stateManager,
indexingTaskManager,
entryTypesManager,
externalFileTypes,
taskExecutor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.pdf.search.indexing.IndexingTaskManager;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.preferences.PreferencesService;
Expand All @@ -20,6 +21,7 @@ public OptionalFieldsTab(BibDatabaseContext databaseContext,
DialogService dialogService,
PreferencesService preferences,
StateManager stateManager,
IndexingTaskManager indexingTaskManager,
BibEntryTypesManager entryTypesManager,
ExternalFileTypes externalFileTypes,
TaskExecutor taskExecutor,
Expand All @@ -33,6 +35,7 @@ public OptionalFieldsTab(BibDatabaseContext databaseContext,
dialogService,
preferences,
stateManager,
indexingTaskManager,
entryTypesManager,
externalFileTypes,
taskExecutor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.pdf.search.indexing.IndexingTaskManager;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryType;
Expand All @@ -35,11 +36,12 @@ public OptionalFieldsTabBase(String title,
DialogService dialogService,
PreferencesService preferences,
StateManager stateManager,
IndexingTaskManager indexingTaskManager,
BibEntryTypesManager entryTypesManager,
ExternalFileTypes externalFileTypes,
TaskExecutor taskExecutor,
JournalAbbreviationRepository journalAbbreviationRepository) {
super(true, databaseContext, suggestionProviders, undoManager, dialogService, preferences, stateManager, externalFileTypes, taskExecutor, journalAbbreviationRepository);
super(true, databaseContext, suggestionProviders, undoManager, dialogService, preferences, stateManager, externalFileTypes, taskExecutor, journalAbbreviationRepository, indexingTaskManager);
this.entryTypesManager = entryTypesManager;
this.isPrimaryOptionalFields = isPrimaryOptionalFields;
setText(title);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/gui/entryeditor/OtherFieldsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.pdf.search.indexing.IndexingTaskManager;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryType;
Expand All @@ -39,6 +40,7 @@ public OtherFieldsTab(BibDatabaseContext databaseContext,
DialogService dialogService,
PreferencesService preferences,
StateManager stateManager,
IndexingTaskManager indexingTaskManager,
BibEntryTypesManager entryTypesManager,
ExternalFileTypes externalFileTypes,
TaskExecutor taskExecutor,
Expand All @@ -52,7 +54,7 @@ public OtherFieldsTab(BibDatabaseContext databaseContext,
stateManager,
externalFileTypes,
taskExecutor,
journalAbbreviationRepository);
journalAbbreviationRepository, indexingTaskManager);

this.entryTypesManager = entryTypesManager;
this.customTabFieldNames = preferences.getAllDefaultTabFieldNames();
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/org/jabref/gui/entryeditor/PreviewTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.preview.PreviewPanel;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.pdf.search.indexing.IndexingTaskManager;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.preferences.PreferencesService;
Expand All @@ -15,18 +16,20 @@ public class PreviewTab extends EntryEditorTab {
private final BibDatabaseContext databaseContext;
private final PreferencesService preferences;
private final StateManager stateManager;
private final IndexingTaskManager indexingTaskManager;
private final ExternalFileTypes externalFileTypes;
private PreviewPanel previewPanel;

public PreviewTab(BibDatabaseContext databaseContext,
DialogService dialogService,
PreferencesService preferences,
StateManager stateManager,
ExternalFileTypes externalFileTypes) {
IndexingTaskManager indexingTaskManager, ExternalFileTypes externalFileTypes) {
this.databaseContext = databaseContext;
this.dialogService = dialogService;
this.preferences = preferences;
this.stateManager = stateManager;
this.indexingTaskManager = indexingTaskManager;
this.externalFileTypes = externalFileTypes;

setGraphic(IconTheme.JabRefIcons.TOGGLE_ENTRY_PREVIEW.getGraphicNode());
Expand Down Expand Up @@ -55,7 +58,7 @@ public boolean shouldShow(BibEntry entry) {
@Override
protected void bindToEntry(BibEntry entry) {
if (previewPanel == null) {
previewPanel = new PreviewPanel(databaseContext, dialogService, externalFileTypes, preferences.getKeyBindingRepository(), preferences, stateManager);
previewPanel = new PreviewPanel(databaseContext, dialogService, externalFileTypes, preferences.getKeyBindingRepository(), preferences, stateManager, indexingTaskManager);
setContent(previewPanel);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.pdf.search.indexing.IndexingTaskManager;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryType;
Expand All @@ -35,12 +36,13 @@ public RequiredFieldsTab(BibDatabaseContext databaseContext,
DialogService dialogService,
PreferencesService preferences,
StateManager stateManager,
IndexingTaskManager indexingTaskManager,
BibEntryTypesManager entryTypesManager,
ExternalFileTypes externalFileTypes,
TaskExecutor taskExecutor,
JournalAbbreviationRepository journalAbbreviationRepository) {
super(false, databaseContext, suggestionProviders, undoManager, dialogService,
preferences, stateManager, externalFileTypes, taskExecutor, journalAbbreviationRepository);
preferences, stateManager, externalFileTypes, taskExecutor, journalAbbreviationRepository, indexingTaskManager);
this.entryTypesManager = entryTypesManager;

setText(Localization.lang("Required fields"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.pdf.search.indexing.IndexingTaskManager;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryTypesManager;
Expand All @@ -29,11 +30,12 @@ public UserDefinedFieldsTab(String name,
DialogService dialogService,
PreferencesService preferences,
StateManager stateManager,
IndexingTaskManager indexingTaskManager,
BibEntryTypesManager entryTypesManager,
ExternalFileTypes externalFileTypes,
TaskExecutor taskExecutor,
JournalAbbreviationRepository journalAbbreviationRepository) {
super(false, databaseContext, suggestionProviders, undoManager, dialogService, preferences, stateManager, externalFileTypes, taskExecutor, journalAbbreviationRepository);
super(false, databaseContext, suggestionProviders, undoManager, dialogService, preferences, stateManager, externalFileTypes, taskExecutor, journalAbbreviationRepository, indexingTaskManager);

this.fields = new LinkedHashSet<>(fields);

Expand Down
Loading

0 comments on commit 144a37d

Please sign in to comment.