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 7, 2016
1 parent f1d7c2b commit dcecbed
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 1 deletion.
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
- 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"
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 @@ -1728,3 +1728,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

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 @@ -2437,3 +2437,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=Problem_beim_Analysieren_des_von_IEEEXplore_empfangenen_Eintrags

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 @@ -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
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1628,3 +1628,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_fa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2415,3 +2415,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1667,3 +1667,5 @@ Synchronize_files=Synchroniser_les_fichiers
Unabbreviate=Dés-abréger

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_in.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1648,3 +1648,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1746,3 +1746,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2420,3 +2420,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2422,3 +2422,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_no.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2821,3 +2821,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1641,3 +1641,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2421,3 +2421,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_tr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1662,3 +1662,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_vi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2419,3 +2419,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2416,3 +2416,5 @@ Synchronize_files=
Unabbreviate=

Error_occured_parsing_Bibtex_returned_from_IEEEXplore=

Copy_preview=

0 comments on commit dcecbed

Please sign in to comment.