-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move and rename "Mass Getting bibliographic data" action
- Relocate action from Right-click menu to "Lookup" menu for consistency - Rename action from "Mass Getting" to "Get bibliographic data from DOI/ISBN/... (fully automated)" - Other modifications not finished yet
- Loading branch information
Showing
4 changed files
with
52 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 33 additions & 10 deletions
43
src/main/java/org/jabref/gui/mergeentries/MultiEntryMergeWithFetchedDataAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,74 @@ | ||
package org.jabref.gui.mergeentries; | ||
|
||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
import javax.swing.undo.UndoManager; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.LibraryTab; | ||
import org.jabref.gui.StateManager; | ||
import org.jabref.gui.actions.ActionHelper; | ||
import org.jabref.gui.actions.SimpleCommand; | ||
import org.jabref.gui.preferences.GuiPreferences; | ||
import org.jabref.logic.util.TaskExecutor; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
import org.jabref.model.entry.BibEntry; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Action for merging multiple entries with fetched data from identifiers like DOI or arXiv. | ||
*/ | ||
public class MultiEntryMergeWithFetchedDataAction extends SimpleCommand { | ||
|
||
private final LibraryTab libraryTab; | ||
private static final Logger LOGGER = LoggerFactory.getLogger(MultiEntryMergeWithFetchedDataAction.class); | ||
|
||
private final Supplier<LibraryTab> tabSupplier; | ||
private final GuiPreferences preferences; | ||
private final TaskExecutor taskExecutor; | ||
private final BibDatabaseContext bibDatabaseContext; | ||
private final DialogService dialogService; | ||
private final UndoManager undoManager; | ||
|
||
public MultiEntryMergeWithFetchedDataAction(LibraryTab libraryTab, | ||
public MultiEntryMergeWithFetchedDataAction(Supplier<LibraryTab> tabSupplier, | ||
GuiPreferences preferences, | ||
TaskExecutor taskExecutor, | ||
BibDatabaseContext bibDatabaseContext, | ||
DialogService dialogService, | ||
UndoManager undoManager) { | ||
this.libraryTab = libraryTab; | ||
UndoManager undoManager, | ||
StateManager stateManager) { | ||
this.tabSupplier = tabSupplier; | ||
this.preferences = preferences; | ||
this.taskExecutor = taskExecutor; | ||
this.bibDatabaseContext = bibDatabaseContext; | ||
this.dialogService = dialogService; | ||
this.undoManager = undoManager; | ||
|
||
// Binding to only execute if a database is open | ||
this.executable.bind(ActionHelper.needsDatabase(stateManager)); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
List<BibEntry> selectedEntries = libraryTab.getSelectedEntries(); | ||
LibraryTab libraryTab = tabSupplier.get(); | ||
|
||
// Ensure that libraryTab is present | ||
if (libraryTab == null) { | ||
LOGGER.error("Action 'Multi Entry Merge' must be disabled when no database is open."); | ||
return; | ||
} | ||
|
||
List<BibEntry> selectedEntries = libraryTab.getDatabase().getEntries(); | ||
|
||
// If no entries are selected, log and do not execute | ||
if (selectedEntries.isEmpty()) { | ||
dialogService.notify("No entries selected for merging."); | ||
return; | ||
} | ||
|
||
// Create an instance of FetchAndMergeEntry | ||
// Create an instance of FetchAndMergeEntry to perform the batch fetch and merge operation | ||
BibDatabaseContext bibDatabaseContext = libraryTab.getBibDatabaseContext(); | ||
FetchAndMergeEntry fetchAndMergeEntry = new FetchAndMergeEntry(bibDatabaseContext, taskExecutor, preferences, dialogService, undoManager); | ||
|
||
// Perform the batch fetch and merge operation | ||
fetchAndMergeEntry.fetchAndMergeBatch(selectedEntries); | ||
} | ||
} |