-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement mass addition of bib information (Closes #372) #12025
base: main
Are you sure you want to change the base?
Changes from 10 commits
887dd35
656facf
0409856
489b512
dc138ce
0532df4
012dd9a
f8267ac
74f2473
29759a6
37cfeae
77e0d51
e6f0ad2
c5b7b4c
5b829b1
350502e
fe46c0c
8eac6a9
5d54083
93072cf
262d25d
4667124
ae4df14
5ed3d70
74a6285
8d9bdce
95e9ae8
9fdbbb4
ce1ea3e
7305f3c
9dce81a
5f24815
d17fd88
61f5a8f
86051ac
198f2d0
ace1975
74681e1
3197ef4
c04a2fa
d2566db
4d1b88d
e8645a2
ac8c59d
5172bc2
05b3c42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ public enum StandardActions implements Action { | |
OPEN_URL(Localization.lang("Open URL or DOI"), IconTheme.JabRefIcons.WWW, KeyBinding.OPEN_URL_OR_DOI), | ||
SEARCH_SHORTSCIENCE(Localization.lang("Search ShortScience")), | ||
MERGE_WITH_FETCHED_ENTRY(Localization.lang("Get bibliographic data from %0", "DOI/ISBN/...")), | ||
MASS_GET_BIBLIOGRAPHIC_DATA(Localization.lang("Get bibliographic data from %0 (fully automated)", "DOI/ISBN/...")), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe rename |
||
ATTACH_FILE(Localization.lang("Attach file"), IconTheme.JabRefIcons.ATTACH_FILE), | ||
ATTACH_FILE_FROM_URL(Localization.lang("Attach file from URL"), IconTheme.JabRefIcons.DOWNLOAD_FILE), | ||
PRIORITY(Localization.lang("Priority"), IconTheme.JabRefIcons.PRIORITY), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ | |
import org.jabref.gui.maintable.NewLibraryFromPdfActionOffline; | ||
import org.jabref.gui.maintable.NewLibraryFromPdfActionOnline; | ||
import org.jabref.gui.mergeentries.MergeEntriesAction; | ||
import org.jabref.gui.mergeentries.MultiEntryMergeWithFetchedDataAction; | ||
import org.jabref.gui.plaincitationparser.PlainCitationParserAction; | ||
import org.jabref.gui.preferences.GuiPreferences; | ||
import org.jabref.gui.preferences.ShowPreferencesAction; | ||
|
@@ -273,7 +274,22 @@ private void createMenu() { | |
|
||
new SeparatorMenuItem(), | ||
|
||
factory.createMenuItem(StandardActions.FIND_UNLINKED_FILES, new FindUnlinkedFilesAction(dialogService, stateManager)) | ||
factory.createMenuItem(StandardActions.FIND_UNLINKED_FILES, new FindUnlinkedFilesAction(dialogService, stateManager)), | ||
|
||
new SeparatorMenuItem(), | ||
|
||
// Adding new menu item for mass bibliographic data fetching | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not useful comment. Remove it. |
||
factory.createMenuItem( | ||
StandardActions.MASS_GET_BIBLIOGRAPHIC_DATA, | ||
new MultiEntryMergeWithFetchedDataAction( | ||
frame::getCurrentLibraryTab, | ||
preferences, | ||
taskExecutor, | ||
dialogService, | ||
undoManager, | ||
stateManager | ||
) | ||
) | ||
); | ||
|
||
final MenuItem pushToApplicationMenuItem = factory.createMenuItem(pushToApplicationCommand.getAction(), pushToApplicationCommand); | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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 static final Logger LOGGER = LoggerFactory.getLogger(MultiEntryMergeWithFetchedDataAction.class); | ||
|
||
private final Supplier<LibraryTab> tabSupplier; | ||
private final GuiPreferences preferences; | ||
private final TaskExecutor taskExecutor; | ||
private final DialogService dialogService; | ||
private final UndoManager undoManager; | ||
|
||
public MultiEntryMergeWithFetchedDataAction(Supplier<LibraryTab> tabSupplier, | ||
GuiPreferences preferences, | ||
TaskExecutor taskExecutor, | ||
DialogService dialogService, | ||
UndoManager undoManager, | ||
StateManager stateManager) { | ||
this.tabSupplier = tabSupplier; | ||
this.preferences = preferences; | ||
this.taskExecutor = taskExecutor; | ||
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() { | ||
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 to perform the batch fetch and merge operation | ||
BibDatabaseContext bibDatabaseContext = libraryTab.getBibDatabaseContext(); | ||
FetchAndMergeEntry fetchAndMergeEntry = new FetchAndMergeEntry(bibDatabaseContext, taskExecutor, preferences, dialogService, undoManager); | ||
|
||
fetchAndMergeEntry.fetchAndMergeBatch(selectedEntries); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1679,6 +1679,10 @@ No\ %0\ found=No %0 found | |
Entry\ from\ %0=Entry from %0 | ||
Merge\ entry\ with\ %0\ information=Merge entry with %0 information | ||
Updated\ entry\ with\ info\ from\ %0=Updated entry with info from %0 | ||
Mass\ getting\ bibliographic\ data\ from\ %0=Mass getting bibliographic data from %0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think, this string should get obsoelete |
||
Merge\ entry\ without\ user\ interaction=Merge entry without user interaction | ||
No\ new\ information\ was\ added=No new information was added | ||
Updated\ entry\ with\ fetched\ information=Updated entry with fetched information | ||
|
||
Add\ new\ list=Add new list | ||
Open\ existing\ list=Open existing list | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add where you added it.
It really needs to be in the "Lookup" menu.
We want to keep the right click menu small.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.