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);
}
}
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);
}
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;
}
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);
}
}
}
Aggregations