From 661c484fc0ea08d85fd8efd386fbc0b9443be0c3 Mon Sep 17 00:00:00 2001 From: Anders Blomqvist Date: Wed, 28 Feb 2024 12:05:45 +0100 Subject: [PATCH] add: new copy action (#1) --- src/main/java/org/jabref/gui/MainMenu.java | 1 + src/main/java/org/jabref/gui/actions/StandardActions.java | 1 + src/main/java/org/jabref/gui/edit/CopyMoreAction.java | 6 ++++++ src/main/java/org/jabref/gui/maintable/RightClickMenu.java | 1 + 4 files changed, 9 insertions(+) diff --git a/src/main/java/org/jabref/gui/MainMenu.java b/src/main/java/org/jabref/gui/MainMenu.java index db5c69c7fd2..13806b4e1d2 100644 --- a/src/main/java/org/jabref/gui/MainMenu.java +++ b/src/main/java/org/jabref/gui/MainMenu.java @@ -181,6 +181,7 @@ private void createMenu() { factory.createMenuItem(StandardActions.COPY_KEY_AND_TITLE, new CopyMoreAction(StandardActions.COPY_KEY_AND_TITLE, dialogService, stateManager, clipBoardManager, preferencesService, abbreviationRepository)), factory.createMenuItem(StandardActions.COPY_KEY_AND_LINK, new CopyMoreAction(StandardActions.COPY_KEY_AND_LINK, dialogService, stateManager, clipBoardManager, preferencesService, abbreviationRepository)), factory.createMenuItem(StandardActions.COPY_CITATION_PREVIEW, new CopyCitationAction(CitationStyleOutputFormat.HTML, dialogService, stateManager, clipBoardManager, taskExecutor, preferencesService, abbreviationRepository)), + factory.createMenuItem(StandardActions.COPY_REPLACE_CONSTANTS, new CopyMoreAction(StandardActions.COPY_REPLACE_CONSTANTS, dialogService, stateManager, clipBoardManager, preferencesService, abbreviationRepository)), factory.createMenuItem(StandardActions.EXPORT_SELECTED_TO_CLIPBOARD, new ExportToClipboardAction(dialogService, stateManager, clipBoardManager, taskExecutor, preferencesService))), factory.createMenuItem(StandardActions.PASTE, new EditAction(StandardActions.PASTE, frame::getCurrentLibraryTab, stateManager, undoManager)), diff --git a/src/main/java/org/jabref/gui/actions/StandardActions.java b/src/main/java/org/jabref/gui/actions/StandardActions.java index 6f74e2caa1f..219980760ef 100644 --- a/src/main/java/org/jabref/gui/actions/StandardActions.java +++ b/src/main/java/org/jabref/gui/actions/StandardActions.java @@ -19,6 +19,7 @@ public enum StandardActions implements Action { COPY_CITATION_HTML(Localization.lang("Copy citation (html)"), KeyBinding.COPY_PREVIEW), COPY_CITATION_TEXT(Localization.lang("Copy citation (text)")), COPY_CITATION_PREVIEW(Localization.lang("Copy preview"), KeyBinding.COPY_PREVIEW), + COPY_REPLACE_CONSTANTS(Localization.lang("Copy and replace string constants")), 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), diff --git a/src/main/java/org/jabref/gui/edit/CopyMoreAction.java b/src/main/java/org/jabref/gui/edit/CopyMoreAction.java index d8fad69c5c5..5b3619eb18b 100644 --- a/src/main/java/org/jabref/gui/edit/CopyMoreAction.java +++ b/src/main/java/org/jabref/gui/edit/CopyMoreAction.java @@ -72,6 +72,8 @@ public void execute() { copyKeyAndLink(); case COPY_DOI, COPY_DOI_URL -> copyDoi(); + case COPY_REPLACE_CONSTANTS -> + copyReplaceConstants(); default -> LOGGER.info("Unknown copy command."); } @@ -264,4 +266,8 @@ private void copyKeyAndLink() { Long.toString(entries.size() - entriesWithKey.size()), Integer.toString(entries.size()))); } } + + private void copyReplaceConstants() { + // todo: When copying a BibEntry in the clipboard, also referenced @string constants should be put into the clipboard. + } } diff --git a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java index 6e65da6ab13..65a92338743 100644 --- a/src/main/java/org/jabref/gui/maintable/RightClickMenu.java +++ b/src/main/java/org/jabref/gui/maintable/RightClickMenu.java @@ -103,6 +103,7 @@ private static Menu createCopySubMenu(ActionFactory factory, factory.createMenuItem(StandardActions.COPY_CITE_KEY, new CopyMoreAction(StandardActions.COPY_CITE_KEY, dialogService, stateManager, clipBoardManager, preferencesService, abbreviationRepository)), factory.createMenuItem(StandardActions.COPY_KEY_AND_TITLE, new CopyMoreAction(StandardActions.COPY_KEY_AND_TITLE, dialogService, stateManager, clipBoardManager, preferencesService, abbreviationRepository)), factory.createMenuItem(StandardActions.COPY_KEY_AND_LINK, new CopyMoreAction(StandardActions.COPY_KEY_AND_LINK, dialogService, stateManager, clipBoardManager, preferencesService, abbreviationRepository)), + factory.createMenuItem(StandardActions.COPY_REPLACE_CONSTANTS, new CopyMoreAction(StandardActions.COPY_REPLACE_CONSTANTS, dialogService, stateManager, clipBoardManager, preferencesService, abbreviationRepository)), factory.createMenuItem(StandardActions.COPY_DOI, new CopyMoreAction(StandardActions.COPY_DOI, dialogService, stateManager, clipBoardManager, preferencesService, abbreviationRepository)), factory.createMenuItem(StandardActions.COPY_DOI_URL, new CopyMoreAction(StandardActions.COPY_DOI_URL, dialogService, stateManager, clipBoardManager, preferencesService, abbreviationRepository)), new SeparatorMenuItem()