Search in sources :

Example 16 with Clipboard

use of javafx.scene.input.Clipboard in project certmgr by hdecarne.

the class StoreController method onCmdCopyEntryAttribute.

@SuppressWarnings("unused")
@FXML
void onCmdCopyEntryAttribute(ActionEvent evt) {
    TreeItem<AttributeModel> selectedItem = this.ctlDetailsView.getSelectionModel().getSelectedItem();
    if (selectedItem != null) {
        Clipboard clipboard = Clipboard.getSystemClipboard();
        ClipboardContent content = new ClipboardContent();
        content.putString(selectedItem.getValue().toString());
        clipboard.setContent(content);
    }
}
Also used : ClipboardContent(javafx.scene.input.ClipboardContent) Clipboard(javafx.scene.input.Clipboard) FXML(javafx.fxml.FXML)

Example 17 with Clipboard

use of javafx.scene.input.Clipboard in project tokentool by RPTools.

the class TokenTool_Controller method editCopyImageMenu_onAction.

@FXML
void editCopyImageMenu_onAction(ActionEvent event) {
    Clipboard clipboard = Clipboard.getSystemClipboard();
    ClipboardContent content = new ClipboardContent();
    // for paste as file, e.g. in Windows Explorer
    try {
        File tempTokenFile = fileSaveUtil.getTempFileName(false, useFileNumberingCheckbox.isSelected(), fileNameTextField.getText(), fileNameSuffixTextField);
        writeTokenImage(tempTokenFile);
        content.putFiles(java.util.Collections.singletonList(tempTokenFile));
        tempTokenFile.deleteOnExit();
    } catch (Exception e) {
        log.error(e);
    }
    // for paste as image, e.g. in GIMP
    content.putImage(tokenImageView.getImage());
    // Finally, put contents on clip board
    clipboard.setContent(content);
}
Also used : ClipboardContent(javafx.scene.input.ClipboardContent) Clipboard(javafx.scene.input.Clipboard) File(java.io.File) IOException(java.io.IOException) FXML(javafx.fxml.FXML)

Example 18 with Clipboard

use of javafx.scene.input.Clipboard in project RichTextFX by FXMisc.

the class ClipboardHelper method paste.

/**
 * Inserts the content from the clipboard into this text-editing area,
 * replacing the current selection. If there is no selection, the content
 * from the clipboard is inserted at the current caret position.
 */
default void paste() {
    Clipboard clipboard = Clipboard.getSystemClipboard();
    if (getStyleCodecs().isPresent()) {
        Tuple2<Codec<PS>, Codec<StyledSegment<SEG, S>>> codecs = getStyleCodecs().get();
        Codec<StyledDocument<PS, SEG, S>> codec = ReadOnlyStyledDocument.codec(codecs._1, codecs._2, getSegOps());
        DataFormat format = dataFormat(codec.getName());
        if (clipboard.hasContent(format)) {
            byte[] bytes = (byte[]) clipboard.getContent(format);
            ByteArrayInputStream is = new ByteArrayInputStream(bytes);
            DataInputStream dis = new DataInputStream(is);
            StyledDocument<PS, SEG, S> doc = null;
            try {
                doc = codec.decode(dis);
            } catch (IOException e) {
                System.err.println("Codec error: Failed to decode '" + codec.getName() + "':");
                e.printStackTrace();
            }
            if (doc != null) {
                replaceSelection(doc);
                return;
            }
        }
    }
    if (clipboard.hasString()) {
        String text = clipboard.getString();
        if (text != null) {
            replaceSelection(text);
        }
    }
}
Also used : ReadOnlyStyledDocument(org.fxmisc.richtext.model.ReadOnlyStyledDocument) StyledDocument(org.fxmisc.richtext.model.StyledDocument) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) Codec(org.fxmisc.richtext.model.Codec) ByteArrayInputStream(java.io.ByteArrayInputStream) DataFormat(javafx.scene.input.DataFormat) Clipboard(javafx.scene.input.Clipboard)

Example 19 with Clipboard

use of javafx.scene.input.Clipboard in project Krothium-Launcher by DarkLBP.

the class OutputFX method copySelected.

@FXML
public final void copySelected() {
    if (!outputList.getSelectionModel().getSelectedItems().isEmpty()) {
        Clipboard clipboard = Clipboard.getSystemClipboard();
        ClipboardContent content = new ClipboardContent();
        StringBuilder b = new StringBuilder();
        for (String s : outputList.getSelectionModel().getSelectedItems()) {
            b.append(s).append('\n');
        }
        content.putString(b.toString());
        clipboard.setContent(content);
    }
}
Also used : ClipboardContent(javafx.scene.input.ClipboardContent) Clipboard(javafx.scene.input.Clipboard) FXML(javafx.fxml.FXML)

Example 20 with Clipboard

use of javafx.scene.input.Clipboard in project trex-stateless-gui by cisco-system-traffic-generator.

the class LogsView method copyToClipboard.

/**
 * Copy logs to clipboard
 */
public void copyToClipboard() {
    final Clipboard clipboard = Clipboard.getSystemClipboard();
    final ClipboardContent content = new ClipboardContent();
    content.putString(sb.toString());
    clipboard.setContent(content);
}
Also used : ClipboardContent(javafx.scene.input.ClipboardContent) Clipboard(javafx.scene.input.Clipboard)

Aggregations

Clipboard (javafx.scene.input.Clipboard)22 ClipboardContent (javafx.scene.input.ClipboardContent)17 FXML (javafx.fxml.FXML)10 IOException (java.io.IOException)5 File (java.io.File)3 StringWriter (java.io.StringWriter)3 UserCertStore (de.carne.certmgr.certs.UserCertStore)2 UserCertStoreEntry (de.carne.certmgr.certs.UserCertStoreEntry)2 Images (de.carne.certmgr.jfx.resources.Images)2 UserCertStoreTreeTableViewHelper (de.carne.certmgr.jfx.util.UserCertStoreTreeTableViewHelper)2 PathPreference (de.carne.certmgr.util.PathPreference)2 Nullable (de.carne.check.Nullable)2 PlatformHelper (de.carne.jfx.application.PlatformHelper)2 Alerts (de.carne.jfx.scene.control.Alerts)2 StageController (de.carne.jfx.stage.StageController)2 Lazy (de.carne.util.Lazy)2 Path (java.nio.file.Path)2 List (java.util.List)2 Preferences (java.util.prefs.Preferences)2 Collectors (java.util.stream.Collectors)2