Skip to content

Commit

Permalink
Partly implemented JabRef#647
Browse files Browse the repository at this point in the history
  • Loading branch information
oscargus committed Jan 18, 2016
1 parent 86f5016 commit 602059f
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by
## [Unreleased]

### Changed
- All import/open database warnings are now shown in a scrolling text area
- 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
28 changes: 27 additions & 1 deletion src/main/java/net/sf/jabref/gui/PreviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public class PreviewPanel extends JPanel implements VetoableChangeListener, Sear

private final CloseAction closeAction;

private final CopyAction copyAction;

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.copyAction = new CopyAction();

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.copyAction);
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.copyAction);

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.copyAction);
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 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);
}

}

}
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 602059f

Please sign in to comment.