diff --git a/CHANGELOG.md b/CHANGELOG.md index 00233cb5d36..895b01089a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by ### Changed - OvidImporter now also imports fields: doi, issn, language and keywords +- Implemented [#647](https://github.com/JabRef/jabref/issues/647): The preview can now be copied ### Fixed - Make BibTex parser more robust against missing newlines diff --git a/src/main/java/net/sf/jabref/gui/PreviewPanel.java b/src/main/java/net/sf/jabref/gui/PreviewPanel.java index 32996c67585..660d8ccf9a6 100644 --- a/src/main/java/net/sf/jabref/gui/PreviewPanel.java +++ b/src/main/java/net/sf/jabref/gui/PreviewPanel.java @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2012 JabRef contributors. +/* Copyright (C) 2003-2016 JabRef contributors. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -89,6 +89,8 @@ public class PreviewPanel extends JPanel implements VetoableChangeListener, Sear private final CloseAction closeAction; + private final CopyPreviewAction copyPreviewAction; + 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.copyPreviewAction = new CopyPreviewAction(); 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.copyPreviewAction); 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.copyPreviewAction); + 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.copyPreviewAction); + 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 CopyPreviewAction extends AbstractAction { + + public CopyPreviewAction() { + 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 db639a92f6e..9dc70fd9c4e 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 44cb1dc98db..2d57d8d4708 100644 --- a/src/main/resources/l10n/JabRef_da.properties +++ b/src/main/resources/l10n/JabRef_da.properties @@ -1730,3 +1730,5 @@ Unabbreviate= Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_de.properties b/src/main/resources/l10n/JabRef_de.properties index 8b41ff64230..97f3a7282b1 100644 --- a/src/main/resources/l10n/JabRef_de.properties +++ b/src/main/resources/l10n/JabRef_de.properties @@ -2439,3 +2439,5 @@ Unabbreviate= Error_occured_parsing_BibTeX_returned_from_IEEEXplore=Problem_beim_Analysieren_des_von_IEEEXplore_empfangenen_Eintrags should_contain_a_protocol= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 561d6458c6c..c68309ddaa3 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2425,3 +2425,4 @@ Synchronize_files=Synchronize_files Unabbreviate=Unabbreviate Error_occured_parsing_BibTeX_returned_from_IEEEXplore=Error_occured_parsing_BibTeX_returned_from_IEEEXplore should_contain_a_protocol=should_contain_a_protocol +Copy_preview=Copy_preview diff --git a/src/main/resources/l10n/JabRef_es.properties b/src/main/resources/l10n/JabRef_es.properties index 7f0c17ce0f1..42ce9bb6b3e 100644 --- a/src/main/resources/l10n/JabRef_es.properties +++ b/src/main/resources/l10n/JabRef_es.properties @@ -1626,7 +1626,7 @@ String_dialog,_remove_string= Switch_preview_layout= Synchronize_files= Unabbreviate= - Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_fa.properties b/src/main/resources/l10n/JabRef_fa.properties index 92fcde09104..9724207f414 100644 --- a/src/main/resources/l10n/JabRef_fa.properties +++ b/src/main/resources/l10n/JabRef_fa.properties @@ -1,4 +1,4 @@ -#! +#! #! created/edited by Popeye version 0.55 (https://github.com/JabRef/popeye) #! encoding:ISO-8859-1 @@ -2413,7 +2413,7 @@ String_dialog,_remove_string= Switch_preview_layout= Synchronize_files= Unabbreviate= - Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_fr.properties b/src/main/resources/l10n/JabRef_fr.properties index c59e38283ae..23e2c77f8a9 100644 --- a/src/main/resources/l10n/JabRef_fr.properties +++ b/src/main/resources/l10n/JabRef_fr.properties @@ -1665,8 +1665,8 @@ String_dialog,_remove_string=Chaine_de_dialogue,_supprimer_une_chaine Switch_preview_layout=Basculer_la_prévisualisation Synchronize_files=Synchroniser_les_fichiers Unabbreviate=Dés-abréger - Error_occured_parsing_BibTeX_returned_from_IEEEXplore=Une_erreur_est_survenue_lors_du_traitement_du_format_BibTeX_renvoyé_par_IEEEXplore should_contain_a_protocol=doit_contenir_un_protocole +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_in.properties b/src/main/resources/l10n/JabRef_in.properties index fb4743bcbd8..d681f2ee859 100644 --- a/src/main/resources/l10n/JabRef_in.properties +++ b/src/main/resources/l10n/JabRef_in.properties @@ -1646,7 +1646,8 @@ String_dialog,_remove_string= Switch_preview_layout= Synchronize_files= Unabbreviate= - Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_it.properties b/src/main/resources/l10n/JabRef_it.properties index 86db726607f..afdc51fb1b4 100644 --- a/src/main/resources/l10n/JabRef_it.properties +++ b/src/main/resources/l10n/JabRef_it.properties @@ -1744,7 +1744,8 @@ String_dialog,_remove_string= Switch_preview_layout= Synchronize_files= Unabbreviate= - Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= + +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_ja.properties b/src/main/resources/l10n/JabRef_ja.properties index 73c00ba805c..34adc169067 100644 --- a/src/main/resources/l10n/JabRef_ja.properties +++ b/src/main/resources/l10n/JabRef_ja.properties @@ -2418,7 +2418,7 @@ String_dialog,_remove_string= Switch_preview_layout= Synchronize_files= Unabbreviate= - Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_nl.properties b/src/main/resources/l10n/JabRef_nl.properties index fc9e002c10c..2921bf29909 100644 --- a/src/main/resources/l10n/JabRef_nl.properties +++ b/src/main/resources/l10n/JabRef_nl.properties @@ -2420,7 +2420,7 @@ String_dialog,_remove_string= Switch_preview_layout= Synchronize_files= Unabbreviate= - Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_no.properties b/src/main/resources/l10n/JabRef_no.properties index 4a6843f39af..4f97f9835e3 100644 --- a/src/main/resources/l10n/JabRef_no.properties +++ b/src/main/resources/l10n/JabRef_no.properties @@ -2819,7 +2819,7 @@ String_dialog,_remove_string= Switch_preview_layout= Synchronize_files= Unabbreviate= - Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_pt_BR.properties b/src/main/resources/l10n/JabRef_pt_BR.properties index 9d28ae23c57..37ebd024e2c 100644 --- a/src/main/resources/l10n/JabRef_pt_BR.properties +++ b/src/main/resources/l10n/JabRef_pt_BR.properties @@ -1639,7 +1639,7 @@ String_dialog,_remove_string= Switch_preview_layout= Synchronize_files= Unabbreviate= - Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_ru.properties b/src/main/resources/l10n/JabRef_ru.properties index 13746f7df61..8737de614e5 100644 --- a/src/main/resources/l10n/JabRef_ru.properties +++ b/src/main/resources/l10n/JabRef_ru.properties @@ -2419,7 +2419,7 @@ String_dialog,_remove_string= Switch_preview_layout= Synchronize_files= Unabbreviate= - Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_tr.properties b/src/main/resources/l10n/JabRef_tr.properties index daa77da35a1..5b5c99d1364 100644 --- a/src/main/resources/l10n/JabRef_tr.properties +++ b/src/main/resources/l10n/JabRef_tr.properties @@ -1660,7 +1660,7 @@ String_dialog,_remove_string= Switch_preview_layout= Synchronize_files= Unabbreviate= - Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_vi.properties b/src/main/resources/l10n/JabRef_vi.properties index e6bcf37ef57..cb7035c98b6 100644 --- a/src/main/resources/l10n/JabRef_vi.properties +++ b/src/main/resources/l10n/JabRef_vi.properties @@ -2417,7 +2417,7 @@ String_dialog,_remove_string= Switch_preview_layout= Synchronize_files= Unabbreviate= - Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= +Copy_preview= diff --git a/src/main/resources/l10n/JabRef_zh.properties b/src/main/resources/l10n/JabRef_zh.properties index 485d789bba0..500ba1208ee 100644 --- a/src/main/resources/l10n/JabRef_zh.properties +++ b/src/main/resources/l10n/JabRef_zh.properties @@ -2414,7 +2414,7 @@ String_dialog,_remove_string= Switch_preview_layout= Synchronize_files= Unabbreviate= - Error_occured_parsing_BibTeX_returned_from_IEEEXplore= should_contain_a_protocol= +Copy_preview=