Search in sources :

Example 21 with Clipboard

use of javafx.scene.input.Clipboard in project jgnash by ccavanaugh.

the class TableViewEx method handleGenericCopyToClipboard.

private void handleGenericCopyToClipboard() {
    final List<Integer> integerList = getSelectionModel().getSelectedIndices();
    if (integerList.size() > 0) {
        final Clipboard clipboard = Clipboard.getSystemClipboard();
        final ClipboardContent content = new ClipboardContent();
        final StringBuilder builder = new StringBuilder();
        for (final Integer row : integerList) {
            final List<TableColumn<S, ?>> columns = getColumns();
            for (int i = 0; i < columns.size(); i++) {
                final TableColumn<S, ?> column = columns.get(i);
                if (column.getCellObservableValue(row) != null) {
                    final Object value = column.getCellObservableValue(row).getValue();
                    if (value != null) {
                        if (value instanceof BigDecimal) {
                            builder.append(((BigDecimal) value).toPlainString());
                        } else if (value instanceof LocalDate) {
                            builder.append(DateUtils.getExcelDateFormatter().format((LocalDate) value));
                        } else {
                            builder.append(value);
                        }
                    }
                }
                if (i < columns.size() - i) {
                    builder.append('\t');
                }
            }
            builder.append('\n');
        }
        content.putString(builder.toString());
        clipboard.setContent(content);
    }
}
Also used : ClipboardContent(javafx.scene.input.ClipboardContent) TableColumn(javafx.scene.control.TableColumn) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) Clipboard(javafx.scene.input.Clipboard)

Example 22 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)

Example 23 with Clipboard

use of javafx.scene.input.Clipboard in project jvarkit by lindenb.

the class NgsStage method buildItemsForContextMenu.

/**
 * build context menu for current selected locatable
 */
protected List<MenuItem> buildItemsForContextMenu() {
    final List<MenuItem> L = new ArrayList<>();
    MenuItem menuItem;
    menuItem = new MenuItem("Copy Interval in Clipboard");
    menuItem.setOnAction(AE -> {
        Optional<ITEMTYPE> sel = getCurrentSelectedItem();
        if (!sel.isPresent() || sel.get().getContig() == null)
            return;
        final Clipboard clipboard = Clipboard.getSystemClipboard();
        final ClipboardContent content = new ClipboardContent();
        content.putString(sel.get().getContig() + ":" + sel.get().getStart() + "-" + sel.get().getEnd());
        clipboard.setContent(content);
    });
    L.add(menuItem);
    for (final String build : new String[] { "hg38", "hg19", "hg18" }) {
        menuItem = new MenuItem("Open in UCSC " + build + " ... ");
        menuItem.setOnAction(AE -> {
            final Optional<ITEMTYPE> sel = getCurrentSelectedItem();
            if (!sel.isPresent() || sel.get().getContig() == null)
                return;
            NgsStage.this.owner.getHostServices().showDocument("http://genome.ucsc.edu/cgi-bin/hgTracks?db=hg19&position=" + JfxNgs.ContigToUCSC.apply(sel.get().getContig()) + "%3A" + sel.get().getStart() + "-" + sel.get().getEnd());
        });
        L.add(menuItem);
    }
    for (final String build : new String[] { "grch37.Homo_sapiens", "www.Homo_sapiens", "www.Rattus_norvegicus" }) {
        int dot = build.indexOf('.');
        final String host = build.substring(0, dot);
        final String org = build.substring(dot + 1);
        menuItem = new MenuItem("Open in Ensembl " + org + (host.equals("www") ? "" : "[" + host + "]") + " ... ");
        menuItem.setOnAction(AE -> {
            final Optional<ITEMTYPE> sel = getCurrentSelectedItem();
            if (!sel.isPresent() || sel.get().getContig() == null)
                return;
            NgsStage.this.owner.getHostServices().showDocument("http://" + host + ".ensembl.org/" + org + "/Location/View?r=" + JfxNgs.ContigToEnseml.apply(sel.get().getContig()) + "%3A" + sel.get().getStart() + "-" + sel.get().getEnd());
        });
        L.add(menuItem);
    }
    for (final String database : new String[] { "Exac", "gnomAD" }) {
        menuItem = new MenuItem("Open Region in " + database + " ... ");
        menuItem.setOnAction(AE -> {
            final Optional<ITEMTYPE> sel = getCurrentSelectedItem();
            if (!sel.isPresent() || sel.get().getContig() == null)
                return;
            NgsStage.this.owner.getHostServices().showDocument("http://" + database.toLowerCase() + ".broadinstitute.org/region/" + JfxNgs.ContigToEnseml.apply(sel.get().getContig()) + "-" + sel.get().getStart() + "-" + sel.get().getEnd());
        });
        L.add(menuItem);
    }
    return L;
}
Also used : ClipboardContent(javafx.scene.input.ClipboardContent) ArrayList(java.util.ArrayList) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Clipboard(javafx.scene.input.Clipboard) Paint(javafx.scene.paint.Paint)

Example 24 with Clipboard

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

the class TokenTool_Controller method editPasteImageMenu_OnAction.

@FXML
void editPasteImageMenu_OnAction(ActionEvent event) {
    Clipboard clipboard = Clipboard.getSystemClipboard();
    Image originalImage = portraitImageView.getImage();
    // So lets just check for File first...
    if (clipboard.hasFiles()) {
        clipboard.getFiles().forEach(file -> {
            try {
                Image cbImage = new Image(file.toURI().toURL().toExternalForm());
                if (cbImage != null)
                    updateImage(cbImage, FilenameUtils.getBaseName(file.toURI().toURL().toExternalForm()));
            } catch (Exception e) {
                log.error("Could not load image " + file);
                e.printStackTrace();
            }
        });
    } else if (clipboard.hasImage()) {
        try {
            Image cbImage = clipboard.getImage();
            if (cbImage != null)
                updateImage(cbImage);
        } catch (IllegalArgumentException e) {
            log.info(e);
            updatePortrait(originalImage);
        }
    } else if (clipboard.hasUrl()) {
        try {
            Image cbImage = new Image(clipboard.getUrl());
            if (cbImage != null)
                updateImage(cbImage, FileSaveUtil.searchURL(clipboard.getUrl()));
        } catch (IllegalArgumentException e) {
            log.info(e);
        }
    } else if (clipboard.hasString()) {
        try {
            Image cbImage = new Image(clipboard.getString());
            if (cbImage != null)
                updateImage(cbImage, FileSaveUtil.searchURL(clipboard.getString()));
        } catch (IllegalArgumentException e) {
            log.info(e);
        }
    }
}
Also used : Clipboard(javafx.scene.input.Clipboard) Image(javafx.scene.image.Image) BufferedImage(java.awt.image.BufferedImage) IOException(java.io.IOException) FXML(javafx.fxml.FXML)

Aggregations

Clipboard (javafx.scene.input.Clipboard)24 ClipboardContent (javafx.scene.input.ClipboardContent)18 FXML (javafx.fxml.FXML)12 IOException (java.io.IOException)7 File (java.io.File)4 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