Search in sources :

Example 1 with ClipBoardManager

use of org.jabref.gui.ClipBoardManager in project jabref by JabRef.

the class CopyVersionToClipboardAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    String info = String.format("JabRef %s%n%s %s %s %nJava %s", Globals.BUILD_INFO.getVersion(), BuildInfo.OS, BuildInfo.OS_VERSION, BuildInfo.OS_ARCH, BuildInfo.JAVA_VERSION);
    new ClipBoardManager().setClipboardContents(info);
    JabRefGUI.getMainFrame().output(Localization.lang("Copied version to clipboard"));
}
Also used : ClipBoardManager(org.jabref.gui.ClipBoardManager)

Example 2 with ClipBoardManager

use of org.jabref.gui.ClipBoardManager in project jabref by JabRef.

the class FileAnnotationTab method copyToClipboard.

/**
     * Copies the meta and content information of the pdf annotation to the clipboard
     */
private void copyToClipboard() {
    StringJoiner sj = new StringJoiner(System.getProperty("line.separator"));
    sj.add(Localization.lang("Author") + ": " + authorArea.getText());
    sj.add(Localization.lang("Date") + ": " + dateArea.getText());
    sj.add(Localization.lang("Page") + ": " + pageArea.getText());
    sj.add(Localization.lang("Content") + ": " + contentTxtArea.getText());
    sj.add(Localization.lang("Marking") + ": " + markedTxtArea.getText());
    new ClipBoardManager().setClipboardContents(sj.toString());
}
Also used : ClipBoardManager(org.jabref.gui.ClipBoardManager) StringJoiner(java.util.StringJoiner)

Example 3 with ClipBoardManager

use of org.jabref.gui.ClipBoardManager in project jabref by JabRef.

the class CitationStyleToClipboardWorker method done.

@Override
public void done() {
    try {
        List<String> citations = get();
        // if it's not a citation style take care of the preview
        if (!CitationStyle.isCitationStyleFile(style)) {
            new ClipBoardManager().setTransferableClipboardContents(processPreview(citations));
        } else {
            // if it's generated by a citation style take care of each output format
            Transferable transferable;
            switch(outputFormat) {
                case HTML:
                    transferable = processHtml(citations);
                    break;
                case RTF:
                    transferable = processRtf(citations);
                    break;
                case XSL_FO:
                    transferable = processXslFo(citations);
                    break;
                case ASCII_DOC:
                case TEXT:
                    transferable = processText(citations);
                    break;
                default:
                    LOGGER.warn("unknown output format: '" + outputFormat + "', processing it via the default.");
                    transferable = processText(citations);
                    break;
            }
            new ClipBoardManager().setTransferableClipboardContents(transferable);
        }
        basePanel.frame().setStatus(Localization.lang("Copied %0 citations.", String.valueOf(selectedEntries.size())));
    } catch (InterruptedException | ExecutionException e) {
        LOGGER.error("Error while copying citations to the clipboard", e);
    }
}
Also used : ClipBoardManager(org.jabref.gui.ClipBoardManager) Transferable(java.awt.datatransfer.Transferable) XmlTransferable(org.jabref.gui.fieldeditors.XmlTransferable) HtmlTransferable(org.jabref.gui.fieldeditors.HtmlTransferable) RtfTransferable(org.jabref.gui.exporter.RtfTransferable) ExecutionException(java.util.concurrent.ExecutionException)

Example 4 with ClipBoardManager

use of org.jabref.gui.ClipBoardManager in project jabref by JabRef.

the class CopyBibTeXKeyAndLinkAction method action.

@Override
public void action() throws Exception {
    List<BibEntry> entries = mainTable.getSelectedEntries();
    if (!entries.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        List<BibEntry> entriesWithKey = entries.stream().filter(BibEntry::hasCiteKey).collect(Collectors.toList());
        if (entriesWithKey.isEmpty()) {
            JabRefGUI.getMainFrame().output(Localization.lang("None of the selected entries have BibTeX keys."));
            return;
        }
        for (BibEntry entry : entriesWithKey) {
            String key = entry.getCiteKeyOptional().get();
            String url = entry.getField(FieldName.URL).orElse("");
            sb.append(url.isEmpty() ? key : String.format("<a href=\"%s\">%s</a>", url, key));
            sb.append(OS.NEWLINE);
        }
        ClipBoardManager clipboard = new ClipBoardManager();
        clipboard.setClipboardContents(sb.toString());
        int copied = entriesWithKey.size();
        int toCopy = entries.size();
        if (copied == toCopy) {
            // All entries had keys.
            JabRefGUI.getMainFrame().output((entries.size() > 1 ? Localization.lang("Copied keys") : Localization.lang("Copied key")) + '.');
        } else {
            JabRefGUI.getMainFrame().output(Localization.lang("Warning: %0 out of %1 entries have undefined BibTeX key.", Long.toString(toCopy - copied), Integer.toString(toCopy)));
        }
    }
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) ClipBoardManager(org.jabref.gui.ClipBoardManager)

Example 5 with ClipBoardManager

use of org.jabref.gui.ClipBoardManager in project jabref by JabRef.

the class CopyDoiUrlAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    identifier = component == null ? identifier : component.getText();
    Optional<String> urlOptional = DOI.parse(identifier).map(DOI::getURIAsASCIIString);
    if (urlOptional.isPresent()) {
        ClipBoardManager clipBoard = new ClipBoardManager();
        clipBoard.setClipboardContents(urlOptional.get());
        JabRefGUI.getMainFrame().output(Localization.lang("The link has been copied to the clipboard."));
    } else {
        JabRefGUI.getMainFrame().output(Localization.lang("Invalid DOI: '%0'.", identifier));
    }
}
Also used : ClipBoardManager(org.jabref.gui.ClipBoardManager) DOI(org.jabref.model.entry.identifier.DOI)

Aggregations

ClipBoardManager (org.jabref.gui.ClipBoardManager)5 Transferable (java.awt.datatransfer.Transferable)1 StringJoiner (java.util.StringJoiner)1 ExecutionException (java.util.concurrent.ExecutionException)1 RtfTransferable (org.jabref.gui.exporter.RtfTransferable)1 HtmlTransferable (org.jabref.gui.fieldeditors.HtmlTransferable)1 XmlTransferable (org.jabref.gui.fieldeditors.XmlTransferable)1 BibEntry (org.jabref.model.entry.BibEntry)1 DOI (org.jabref.model.entry.identifier.DOI)1