use of javafx.scene.input.Clipboard in project trex-stateless-gui by cisco-system-traffic-generator.
the class ConsoleLogView method copyToClipboard.
/**
* Copy console log to clipboard
*/
public void copyToClipboard() {
// select all text
logsContent.selectAll();
final Clipboard clipboard = Clipboard.getSystemClipboard();
final ClipboardContent content = new ClipboardContent();
content.putString(logsContent.getText());
clipboard.setContent(content);
}
use of javafx.scene.input.Clipboard in project Gargoyle by callakrsos.
the class FxTableViewUtil method installPasteClipboard.
public static <K> void installPasteClipboard(TableView<K> tb, Class<K> clazz, Field targetField) {
tb.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
if (e.isControlDown() && e.getCode() == KeyCode.V) {
Clipboard clip = Clipboard.getSystemClipboard();
ObservableList<TableColumn<K, ?>> columns = tb.getColumns();
if (columns.isEmpty())
return;
Object value = null;
if (clip.hasFiles()) {
value = clip.getFiles();
} else if (clip.hasHtml()) {
value = clip.getHtml();
} else if (clip.hasImage()) {
value = clip.getImage();
} else if (clip.hasRtf()) {
value = clip.getRtf();
} else if (clip.hasString()) {
value = clip.getString();
} else if (clip.hasUrl()) {
value = clip.getUrl();
}
if (value == null)
return;
try {
K newInstance = clazz.newInstance();
Field field = clazz.getField(targetField.getName());
if (field != null) {
if (!field.isAccessible())
field.setAccessible(true);
field.set(newInstance, value);
}
tb.getItems().add(newInstance);
} catch (Exception e1) {
e1.printStackTrace();
}
}
});
}
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)
updatePortrait(cbImage);
updateFileNameTextField(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)
updatePortrait(cbImage);
} catch (IllegalArgumentException e) {
log.info(e);
updatePortrait(originalImage);
}
} else if (clipboard.hasUrl()) {
try {
Image cbImage = new Image(clipboard.getUrl());
if (cbImage != null)
updatePortrait(cbImage);
updateFileNameTextField(FileSaveUtil.searchURL(clipboard.getUrl()));
} catch (IllegalArgumentException e) {
log.info(e);
}
} else if (clipboard.hasString()) {
try {
Image cbImage = new Image(clipboard.getString());
if (cbImage != null)
updatePortrait(cbImage);
updateFileNameTextField(FileSaveUtil.searchURL(clipboard.getString()));
} catch (IllegalArgumentException e) {
log.info(e);
}
}
}
use of javafx.scene.input.Clipboard in project uPMT by coco35700.
the class MomentExpVBox method copyMoment.
/* */
public void copyMoment() {
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
}
use of javafx.scene.input.Clipboard in project certmgr by hdecarne.
the class CertExportController method exportToClipboard.
void exportToClipboard(CertWriter format, CertObjectStore exportObjects, boolean encryptExport) throws IOException {
StringWriter text = new StringWriter();
try (IOResource<Writer> out = new IOResource<>(text, CertExportI18N.formatSTR_TEXT_CLIPBOARD())) {
if (encryptExport) {
format.writeEncryptedString(out, exportObjects, PasswordDialog.enterNewPassword(this));
} else {
format.writeString(out, exportObjects);
}
}
String textData = text.toString();
if (Platform.IS_WINDOWS) {
// JavaFX on Windows doubles Windows "\r\n" line breaks
// We replace them Unix line breaks "\n" as a workaround.
textData = textData.replace("\r\n", "\n");
}
String clipboardData = textData;
PlatformHelper.runLater(() -> {
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putString(clipboardData);
clipboard.setContent(content);
});
}
Aggregations