Skip to content

Commit

Permalink
Merge pull request #648 from oscargus/copypreview
Browse files Browse the repository at this point in the history
Partly implemented #647
  • Loading branch information
simonharrer committed Jan 19, 2016
2 parents 5f00b33 + dc4b343 commit 26222a5
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 28 additions & 2 deletions src/main/java/net/sf/jabref/gui/PreviewPanel.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -89,6 +89,8 @@ public class PreviewPanel extends JPanel implements VetoableChangeListener, Sear

private final CloseAction closeAction;

private final CopyPreviewAction copyPreviewAction;

private Optional<Pattern> highlightPattern = Optional.empty();

/**
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand All @@ -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);

Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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);
}

}

}
1 change: 1 addition & 0 deletions src/main/java/net/sf/jabref/gui/keyboard/KeyBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1730,3 +1730,5 @@ Unabbreviate=
Error_occured_parsing_BibTeX_returned_from_IEEEXplore=

should_contain_a_protocol=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
1 change: 1 addition & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
4 changes: 2 additions & 2 deletions src/main/resources/l10n/JabRef_fa.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!
#!
#! created/edited by Popeye version 0.55 (https://github.com/JabRef/popeye)
#! encoding:ISO-8859-1

Expand Down Expand Up @@ -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=
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_in.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 2 additions & 1 deletion src/main/resources/l10n/JabRef_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_no.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_tr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_vi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=

0 comments on commit 26222a5

Please sign in to comment.