Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added markdown rendering and copy capabilities to AI chat responses. [#12234](https://github.com/JabRef/jabref/issues/12234)
- We added a new `jabkit` command `pseudonymize` to pseudonymize the library. [#13109](https://github.com/JabRef/jabref/issues/13109)
- We added functionality to focus running instance when trying to start a second instance. [#13129](https://github.com/JabRef/jabref/issues/13129)
- We added a "Copy Field Content" submenu to the entry context menu, allowing users to quickly copy specific field contents including Author, Journal, Date, Keywords, and Abstract fields from selected entries. [#13280](https://github.com/JabRef/jabref/pull/13280)
- We added a highlighted diff regarding changes to the Group Tree Structure of a bib file, made outside JabRef. [#11221](https://github.com/JabRef/jabref/issues/11221)
- We added a new setting in the 'Entry Editor' preferences to hide the 'File Annotations' tab when no annotations are available. [#13143](https://github.com/JabRef/jabref/issues/13143)
- We added support for multi-file import across different formats. [#13269](https://github.com/JabRef/jabref/issues/13269)
Expand All @@ -71,6 +72,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added a progress dialog to the "Check consistency" action and progress output to the corresponding cli command. [#12487](https://github.com/JabRef/jabref/issues/12487)
- We made the `check-consistency` command of the toolkit always return an exit code; 0 means no issues found, a non-zero exit code reflects any issues, which allows CI to fail in these cases [#13328](https://github.com/JabRef/jabref/issues/13328).
- We changed the validation error dialog for overriding the default file directories to a confirmation dialog for saving other preferences under the library properties. [#13488](https://github.com/JabRef/jabref/pull/13488)
- We made the copy sub menu on the context menu consistent with the copy sub menu at "Edit". [#13280](https://github.com/JabRef/jabref/pull/13280)
- We improved file exists warning dialog with clearer options and tooltips [#12565](https://github.com/JabRef/jabref/issues/12565)
- We introduced walkthrough functionality [#12664](https://github.com/JabRef/jabref/issues/12664)

Expand Down Expand Up @@ -101,6 +103,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where Document Viewer showed technical exceptions when opening entries with non-PDF files. [#13198](https://github.com/JabRef/jabref/issues/13198)
- When creating a library, if you drag a PDF file containing only a single column, the dialog will now automatically close. [#13262](https://github.com/JabRef/jabref/issues/13262)
- We fixed an issue where the tab showing the fulltext search results would appear blank after switching library. [#13241](https://github.com/JabRef/jabref/issues/13241)
- We fixed an issue where "Copy to" was enabled even if no other library was opened. [#13280](https://github.com/JabRef/jabref/pull/13280)
- We fixed an issue where the groups were still displayed after closing all libraries. [#13382](https://github.com/JabRef/jabref/issues/13382)
- Enhanced field selection logic in the Merge Entries dialog when fetching from DOI to prefer valid years and entry types. [#12549](https://github.com/JabRef/jabref/issues/12549)

Expand Down
16 changes: 11 additions & 5 deletions jabgui/src/main/java/org/jabref/gui/actions/StandardActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ public enum StandardActions implements Action {

COPY_TO(Localization.lang("Copy to")),
COPY_MORE(Localization.lang("Copy") + "..."),
COPY_TITLE(Localization.lang("Copy title"), KeyBinding.COPY_TITLE),
COPY_KEY(Localization.lang("Copy citation key"), KeyBinding.COPY_CITATION_KEY),
COPY_CITE_KEY(Localization.lang("Copy citation key with configured cite command"), KeyBinding.COPY_CITE_CITATION_KEY),
COPY_KEY_AND_TITLE(Localization.lang("Copy citation key and title"), KeyBinding.COPY_CITATION_KEY_AND_TITLE),
COPY_KEY_AND_LINK(Localization.lang("Copy citation key and link"), KeyBinding.COPY_CITATION_KEY_AND_LINK),
COPY_CITATION_KEY(Localization.lang("Copy citation key"), KeyBinding.COPY_CITATION_KEY),
COPY_AS_CITE_COMMAND(Localization.lang("Copy citation key with configured cite command"), KeyBinding.COPY_CITE_CITATION_KEY),
COPY_CITATION_KEY_AND_TITLE(Localization.lang("Copy citation key and title"), KeyBinding.COPY_CITATION_KEY_AND_TITLE),
COPY_CITATION_KEY_AND_LINK(Localization.lang("Copy citation key and link"), KeyBinding.COPY_CITATION_KEY_AND_LINK),
COPY_CITATION_HTML(Localization.lang("Copy citation (html)"), KeyBinding.COPY_PREVIEW),
COPY_CITATION_TEXT(Localization.lang("Copy citation (text)")),
COPY_CITATION_MARKDOWN(Localization.lang("Copy citation (markdown)")),
COPY_CITATION_PREVIEW(Localization.lang("Copy preview"), KeyBinding.COPY_PREVIEW),
COPY_FIELD_CONTENT(Localization.lang("Copy field content")),
COPY_FIELD_AUTHOR(Localization.lang("Author")),
COPY_FIELD_TITLE(Localization.lang("Title"), KeyBinding.COPY_TITLE),
COPY_FIELD_JOURNAL(Localization.lang("Journal")),
COPY_FIELD_DATE(Localization.lang("Date")),
COPY_FIELD_KEYWORDS(Localization.lang("Keywords")),
COPY_FIELD_ABSTRACT(Localization.lang("Abstract")),
EXPORT_TO_CLIPBOARD(Localization.lang("Export to clipboard"), IconTheme.JabRefIcons.EXPORT_TO_CLIPBOARD),
EXPORT_SELECTED_TO_CLIPBOARD(Localization.lang("Export selected entries to clipboard"), IconTheme.JabRefIcons.EXPORT_TO_CLIPBOARD),
COPY(Localization.lang("Copy"), IconTheme.JabRefIcons.COPY, KeyBinding.COPY),
Expand Down
83 changes: 48 additions & 35 deletions jabgui/src/main/java/org/jabref/gui/edit/CopyMoreAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.strings.LatexToUnicodeAdapter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -60,49 +61,33 @@ public void execute() {
}

switch (action) {
case COPY_TITLE ->
copyTitle();
case COPY_KEY ->
case COPY_CITATION_KEY ->
copyKey();
case COPY_CITE_KEY ->
case COPY_AS_CITE_COMMAND ->
copyCiteKey();
case COPY_KEY_AND_TITLE ->
case COPY_CITATION_KEY_AND_TITLE ->
copyKeyAndTitle();
case COPY_KEY_AND_LINK ->
case COPY_CITATION_KEY_AND_LINK ->
copyKeyAndLink();
case COPY_DOI, COPY_DOI_URL ->
copyDoi();
case COPY_FIELD_AUTHOR ->
copyField(StandardField.AUTHOR, Localization.lang("Author"));
case COPY_FIELD_TITLE ->
copyField(StandardField.TITLE, Localization.lang("Title"));
case COPY_FIELD_JOURNAL ->
copyField(StandardField.JOURNAL, Localization.lang("Journal"));
case COPY_FIELD_DATE ->
copyField(StandardField.DATE, Localization.lang("Date"));
case COPY_FIELD_KEYWORDS ->
copyField(StandardField.KEYWORDS, Localization.lang("Keywords"));
case COPY_FIELD_ABSTRACT ->
copyField(StandardField.ABSTRACT, Localization.lang("Abstract"));
default ->
LOGGER.info("Unknown copy command.");
}
}

private void copyTitle() {
List<BibEntry> selectedBibEntries = stateManager.getSelectedEntries();

List<String> titles = selectedBibEntries.stream()
.filter(bibEntry -> bibEntry.getTitle().isPresent())
.map(bibEntry -> bibEntry.getTitle().get())
.collect(Collectors.toList());

if (titles.isEmpty()) {
dialogService.notify(Localization.lang("None of the selected entries have titles."));
return;
}

final String copiedTitles = String.join("\n", titles);
clipBoardManager.setContent(copiedTitles);

if (titles.size() == selectedBibEntries.size()) {
// All entries had titles.
dialogService.notify(Localization.lang("Copied '%0' to clipboard.",
JabRefDialogService.shortenDialogMessage(copiedTitles)));
} else {
dialogService.notify(Localization.lang("Warning: %0 out of %1 entries have undefined title.",
Integer.toString(selectedBibEntries.size() - titles.size()), Integer.toString(selectedBibEntries.size())));
}
}

private void copyDoi() {
List<BibEntry> entries = stateManager.getSelectedEntries();

Expand All @@ -111,12 +96,12 @@ private void copyDoi() {
copyDoiList(entries.stream()
.filter(entry -> entry.getDOI().isPresent())
.map(entry -> entry.getDOI().get().getURIAsASCIIString())
.collect(Collectors.toList()), entries.size());
.toList(), entries.size());
} else {
copyDoiList(entries.stream()
.filter(entry -> entry.getDOI().isPresent())
.map(entry -> entry.getDOI().get().asString())
.collect(Collectors.toList()), entries.size());
.toList(), entries.size());
}
}

Expand Down Expand Up @@ -146,7 +131,7 @@ private void doCopyKey(Function<List<String>, String> mapKeyList) {
List<String> keys = entries.stream()
.filter(entry -> entry.getCitationKey().isPresent())
.map(entry -> entry.getCitationKey().get())
.collect(Collectors.toList());
.toList();

if (keys.isEmpty()) {
dialogService.notify(Localization.lang("None of the selected entries have citation keys."));
Expand Down Expand Up @@ -264,4 +249,32 @@ private void copyKeyAndLink() {
Long.toString(entries.size() - entriesWithKey.size()), Integer.toString(entries.size())));
}
}

private void copyField(StandardField field, String fieldDisplayName) {
List<BibEntry> selectedBibEntries = stateManager.getSelectedEntries();

List<String> fieldValues = selectedBibEntries.stream()
.filter(bibEntry -> bibEntry.getFieldOrAlias(field).isPresent())
.map(bibEntry -> LatexToUnicodeAdapter.format(bibEntry.getFieldOrAlias(field).orElse("")))
.filter(value -> !value.isEmpty())
.toList();

if (fieldValues.isEmpty()) {
dialogService.notify(Localization.lang("None of the selected entries have %0.", fieldDisplayName));
return;
}

final String copiedContent = fieldValues.stream().collect(Collectors.joining("\n"));
clipBoardManager.setContent(copiedContent);

if (fieldValues.size() == selectedBibEntries.size()) {
dialogService.notify(Localization.lang("Copied '%0' to clipboard.",
JabRefDialogService.shortenDialogMessage(copiedContent)));
} else {
dialogService.notify(Localization.lang("Warning: %0 out of %1 entries have undefined %2.",
Integer.toString(selectedBibEntries.size() - fieldValues.size()),
Integer.toString(selectedBibEntries.size()),
fieldDisplayName));
}
}
}
16 changes: 2 additions & 14 deletions jabgui/src/main/java/org/jabref/gui/frame/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.jabref.gui.copyfiles.CopyFilesAction;
import org.jabref.gui.documentviewer.ShowDocumentViewerAction;
import org.jabref.gui.duplicationFinder.DuplicateSearch;
import org.jabref.gui.edit.CopyMoreAction;
import org.jabref.gui.edit.EditAction;
import org.jabref.gui.edit.ManageKeywordsAction;
import org.jabref.gui.edit.OpenBrowserAction;
Expand All @@ -32,7 +31,6 @@
import org.jabref.gui.entryeditor.OpenEntryEditorAction;
import org.jabref.gui.entryeditor.PreviewSwitchAction;
import org.jabref.gui.exporter.ExportCommand;
import org.jabref.gui.exporter.ExportToClipboardAction;
import org.jabref.gui.exporter.SaveAction;
import org.jabref.gui.exporter.SaveAllAction;
import org.jabref.gui.exporter.WriteMetadataToLinkedPdfsAction;
Expand All @@ -55,13 +53,13 @@
import org.jabref.gui.linkedfile.RedownloadMissingFilesAction;
import org.jabref.gui.maintable.NewLibraryFromPdfActionOffline;
import org.jabref.gui.maintable.NewLibraryFromPdfActionOnline;
import org.jabref.gui.maintable.RightClickMenu;
import org.jabref.gui.mergeentries.BatchEntryMergeWithFetchedDataAction;
import org.jabref.gui.mergeentries.MergeWithFetchedEntryAction;
import org.jabref.gui.mergeentries.threewaymerge.MergeEntriesAction;
import org.jabref.gui.newentry.NewEntryDialogTab;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.gui.preferences.ShowPreferencesAction;
import org.jabref.gui.preview.CopyCitationAction;
import org.jabref.gui.preview.PreviewControls;
import org.jabref.gui.push.GuiPushToApplicationCommand;
import org.jabref.gui.search.RebuildFulltextSearchIndexAction;
Expand All @@ -80,7 +78,6 @@
import org.jabref.gui.util.URLs;
import org.jabref.gui.util.UiTaskExecutor;
import org.jabref.logic.ai.AiService;
import org.jabref.logic.citationstyle.CitationStyleOutputFormat;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.importer.IdFetcher;
import org.jabref.logic.importer.WebFetchers;
Expand Down Expand Up @@ -210,17 +207,8 @@ private void createMenu() {
new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.CUT, new EditAction(StandardActions.CUT, frame::getCurrentLibraryTab, stateManager, undoManager)),

factory.createMenuItem(StandardActions.COPY, new EditAction(StandardActions.COPY, frame::getCurrentLibraryTab, stateManager, undoManager)),
factory.createSubMenu(StandardActions.COPY_MORE,
factory.createMenuItem(StandardActions.COPY_TITLE, new CopyMoreAction(StandardActions.COPY_TITLE, dialogService, stateManager, clipBoardManager, preferences, abbreviationRepository)),
factory.createMenuItem(StandardActions.COPY_KEY, new CopyMoreAction(StandardActions.COPY_KEY, dialogService, stateManager, clipBoardManager, preferences, abbreviationRepository)),
factory.createMenuItem(StandardActions.COPY_CITE_KEY, new CopyMoreAction(StandardActions.COPY_CITE_KEY, dialogService, stateManager, clipBoardManager, preferences, abbreviationRepository)),
factory.createMenuItem(StandardActions.COPY_KEY_AND_TITLE, new CopyMoreAction(StandardActions.COPY_KEY_AND_TITLE, dialogService, stateManager, clipBoardManager, preferences, abbreviationRepository)),
factory.createMenuItem(StandardActions.COPY_KEY_AND_LINK, new CopyMoreAction(StandardActions.COPY_KEY_AND_LINK, dialogService, stateManager, clipBoardManager, preferences, abbreviationRepository)),
factory.createMenuItem(StandardActions.COPY_CITATION_PREVIEW, new CopyCitationAction(CitationStyleOutputFormat.HTML, dialogService, stateManager, clipBoardManager, taskExecutor, preferences, abbreviationRepository)),
factory.createMenuItem(StandardActions.EXPORT_SELECTED_TO_CLIPBOARD, new ExportToClipboardAction(dialogService, stateManager, clipBoardManager, taskExecutor, preferences))),

RightClickMenu.createCopySubMenu(factory, dialogService, stateManager, preferences, clipBoardManager, abbreviationRepository, taskExecutor),
factory.createMenuItem(StandardActions.PASTE, new EditAction(StandardActions.PASTE, frame::getCurrentLibraryTab, stateManager, undoManager)),

new SeparatorMenuItem(),
Expand Down
Loading