diff --git a/CHANGELOG.md b/CHANGELOG.md index 861108c69d76..516b27eeb7e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by ### Changed - All import/open database warnings are now shown in a scrolling text area +- Implemented #647 (partly): The preview can now be copied ### Fixed - Changes in customized entry types are now directly reflected in the table when clicking "Apply" or "OK" diff --git a/src/main/java/net/sf/jabref/gui/PreviewPanel.java b/src/main/java/net/sf/jabref/gui/PreviewPanel.java index 32996c675856..4ff19d4482fc 100644 --- a/src/main/java/net/sf/jabref/gui/PreviewPanel.java +++ b/src/main/java/net/sf/jabref/gui/PreviewPanel.java @@ -89,6 +89,8 @@ public class PreviewPanel extends JPanel implements VetoableChangeListener, Sear private final CloseAction closeAction; + private final CopyAction copyAction; + private Optional highlightPattern = Optional.empty(); /** @@ -170,6 +172,7 @@ private PreviewPanel(BasePanel panel, MetaData metaData, String layoutFile, bool this.closeAction = new CloseAction(); this.printAction = new PrintAction(); + this.copyAction = new CopyAction(); this.panel = Optional.ofNullable(panel); @@ -221,6 +224,7 @@ private PreviewPanel(BasePanel panel, MetaData metaData, String layoutFile, bool private JPopupMenu createPopupMenu() { JPopupMenu menu = new JPopupMenu(); menu.add(this.printAction); + menu.add(this.copyAction); this.panel.ifPresent(p -> menu.add(p.frame().switchPreview)); return menu; } @@ -238,6 +242,9 @@ private JToolBar createToolBar() { inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); actionMap.put("close", this.closeAction); + inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.COPY_PREVIEW), "copy"); + actionMap.put("copy", this.copyAction); + inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.PRINT_ENTRY_PREVIEW), "print"); actionMap.put("print", this.printAction); @@ -246,6 +253,8 @@ private JToolBar createToolBar() { // Add actions (and thus buttons) toolBar.add(this.closeAction); toolBar.addSeparator(); + toolBar.add(this.copyAction); + toolBar.addSeparator(); toolBar.add(this.printAction); Component[] comps = toolBar.getComponents(); @@ -282,7 +291,7 @@ public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { JabRefDesktop.openExternalViewer(PreviewPanel.this.metaData, address, "url"); } catch (IOException e) { - e.printStackTrace(); + LOGGER.warn("Could not open external viewer", e); } } } @@ -422,4 +431,21 @@ public void actionPerformed(ActionEvent e) { } + class CopyAction extends AbstractAction { + + public CopyAction() { + super(Localization.lang("Copy preview"), IconTheme.JabRefIcon.COPY.getSmallIcon()); + putValue(Action.SHORT_DESCRIPTION, Localization.lang("Copy preview")); + putValue(Action.ACCELERATOR_KEY, Globals.getKeyPrefs().getKey(KeyBinding.COPY_PREVIEW)); + } + + @Override + public void actionPerformed(ActionEvent e) { + previewPane.selectAll(); + previewPane.copy(); + previewPane.select(0, -1); + } + + } + } diff --git a/src/main/java/net/sf/jabref/gui/keyboard/KeyBinding.java b/src/main/java/net/sf/jabref/gui/keyboard/KeyBinding.java index db639a92f6e3..9dc70fd9c4e2 100644 --- a/src/main/java/net/sf/jabref/gui/keyboard/KeyBinding.java +++ b/src/main/java/net/sf/jabref/gui/keyboard/KeyBinding.java @@ -18,6 +18,7 @@ public enum KeyBinding { COPY_CITE_BIBTEX_KEY("Copy \\cite{BibTeX key}", Localization.lang("Copy \\cite{BibTeX key}"), "ctrl K"), COPY_BIBTEX_KEY("Copy BibTeX key", Localization.lang("Copy BibTeX key"), "ctrl shift K"), COPY_BIBTEX_KEY_AND_TITLE("Copy BibTeX key and title", Localization.lang("Copy BibTeX key and title"), "ctrl shift alt K"), + COPY_PREVIEW("Copy preview", Localization.lang("Copy preview"), "ctrl shift C"), CUT("Cut", Localization.lang("Cut"), "ctrl X"), DECREASE_TABLE_FONT_SIZE("Decrease table font size", Localization.lang("Decrease table font size"), "ctrl MINUS"), DELETE_ENTRY("Delete entry", Localization.lang("Delete entry"), "DELETE"), diff --git a/src/main/resources/l10n/JabRef_da.properties b/src/main/resources/l10n/JabRef_da.properties index 2e4689842a8a..e04d5f9856d8 100644 --- a/src/main/resources/l10n/JabRef_da.properties +++ b/src/main/resources/l10n/JabRef_da.properties @@ -1728,3 +1728,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_de.properties b/src/main/resources/l10n/JabRef_de.properties index db87c4f3e340..eac3686bdd00 100644 --- a/src/main/resources/l10n/JabRef_de.properties +++ b/src/main/resources/l10n/JabRef_de.properties @@ -2437,3 +2437,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore=Problem_beim_Analysieren_des_von_IEEEXplore_empfangenen_Eintrags + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index c31766fe61c5..c27455fc7e13 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2424,3 +2424,4 @@ Switch_preview_layout=Switch_preview_layout Synchronize_files=Synchronize_files Unabbreviate=Unabbreviate Error_occured_parsing_Bibtex_returned_from_IEEEXplore=Error_occured_parsing_Bibtex_returned_from_IEEEXplore +Copy_preview=Copy_preview \ No newline at end of file diff --git a/src/main/resources/l10n/JabRef_es.properties b/src/main/resources/l10n/JabRef_es.properties index ba0acea34601..e2c121a6e0fb 100644 --- a/src/main/resources/l10n/JabRef_es.properties +++ b/src/main/resources/l10n/JabRef_es.properties @@ -1628,3 +1628,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_fa.properties b/src/main/resources/l10n/JabRef_fa.properties index b45492eb15cc..3f91d54da322 100644 --- a/src/main/resources/l10n/JabRef_fa.properties +++ b/src/main/resources/l10n/JabRef_fa.properties @@ -2415,3 +2415,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_fr.properties b/src/main/resources/l10n/JabRef_fr.properties index 4fbdc22cd260..2fd8b0ff96b6 100644 --- a/src/main/resources/l10n/JabRef_fr.properties +++ b/src/main/resources/l10n/JabRef_fr.properties @@ -1667,3 +1667,5 @@ Synchronize_files=Synchroniser_les_fichiers Unabbreviate=Dés-abréger Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_in.properties b/src/main/resources/l10n/JabRef_in.properties index 5e353e9f70cc..252cfff66435 100644 --- a/src/main/resources/l10n/JabRef_in.properties +++ b/src/main/resources/l10n/JabRef_in.properties @@ -1648,3 +1648,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_it.properties b/src/main/resources/l10n/JabRef_it.properties index 22384e4a0a62..6f9aa4f3cc5d 100644 --- a/src/main/resources/l10n/JabRef_it.properties +++ b/src/main/resources/l10n/JabRef_it.properties @@ -1746,3 +1746,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_ja.properties b/src/main/resources/l10n/JabRef_ja.properties index 87328025a851..b043e81162ae 100644 --- a/src/main/resources/l10n/JabRef_ja.properties +++ b/src/main/resources/l10n/JabRef_ja.properties @@ -2420,3 +2420,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_nl.properties b/src/main/resources/l10n/JabRef_nl.properties index eb916f3958c8..11557257ed34 100644 --- a/src/main/resources/l10n/JabRef_nl.properties +++ b/src/main/resources/l10n/JabRef_nl.properties @@ -2422,3 +2422,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_no.properties b/src/main/resources/l10n/JabRef_no.properties index 2d6a281bd390..6af374d65f2e 100644 --- a/src/main/resources/l10n/JabRef_no.properties +++ b/src/main/resources/l10n/JabRef_no.properties @@ -2821,3 +2821,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_pt_BR.properties b/src/main/resources/l10n/JabRef_pt_BR.properties index 926649113faf..816830cd0251 100644 --- a/src/main/resources/l10n/JabRef_pt_BR.properties +++ b/src/main/resources/l10n/JabRef_pt_BR.properties @@ -1641,3 +1641,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_ru.properties b/src/main/resources/l10n/JabRef_ru.properties index a822ca45b4ef..bab5d9b8e5c1 100644 --- a/src/main/resources/l10n/JabRef_ru.properties +++ b/src/main/resources/l10n/JabRef_ru.properties @@ -2421,3 +2421,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_tr.properties b/src/main/resources/l10n/JabRef_tr.properties index 9c3e72cbf509..67eee066f2e2 100644 --- a/src/main/resources/l10n/JabRef_tr.properties +++ b/src/main/resources/l10n/JabRef_tr.properties @@ -1662,3 +1662,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_vi.properties b/src/main/resources/l10n/JabRef_vi.properties index 404a7635a94f..1d1eec6e8546 100644 --- a/src/main/resources/l10n/JabRef_vi.properties +++ b/src/main/resources/l10n/JabRef_vi.properties @@ -2419,3 +2419,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_zh.properties b/src/main/resources/l10n/JabRef_zh.properties index 5b65ad0f4264..e0eb035e2e03 100644 --- a/src/main/resources/l10n/JabRef_zh.properties +++ b/src/main/resources/l10n/JabRef_zh.properties @@ -2416,3 +2416,5 @@ Synchronize_files= Unabbreviate= Error_occured_parsing_Bibtex_returned_from_IEEEXplore= + +Copy_preview=