Java Code Examples for javafx.scene.input.Clipboard#getSystemClipboard()
The following examples show how to use
javafx.scene.input.Clipboard#getSystemClipboard() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CutFileAction.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread protected void execute(@Nullable ActionEvent event) { super.execute(event); var files = getElements().stream() .map(ResourceElement::getFile) .map(Path::toFile) .collect(toList()); var content = new ClipboardContent(); content.putFiles(files); content.put(EditorUtil.JAVA_PARAM, "cut"); var clipboard = Clipboard.getSystemClipboard(); clipboard.setContent(content); }
Example 2
Source File: PasteFileAction.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread protected void execute(@Nullable ActionEvent event) { super.execute(event); var clipboard = Clipboard.getSystemClipboard(); if (clipboard == null) { return; } List<File> files = unsafeCast(clipboard.getContent(DataFormat.FILES)); if (files == null || files.isEmpty()) { return; } var currentFile = getElement().getFile(); var isCut = "cut".equals(clipboard.getContent(EditorUtil.JAVA_PARAM)); if (isCut) { files.forEach(file -> moveFile(currentFile, file.toPath())); } else { files.forEach(file -> copyFile(currentFile, file.toPath())); } clipboard.clear(); }
Example 3
Source File: TreeNode.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Fill the items actions for this node. * * @param nodeTree the node tree * @param items the items */ @FxThread public void fillContextMenu(@NotNull final NodeTree<?> nodeTree, @NotNull final ObservableList<MenuItem> items) { if (canEditName()) { items.add(new RenameNodeAction(nodeTree, this)); } if (canCopy()) { items.add(new CopyNodeAction(nodeTree, this)); } final Clipboard clipboard = Clipboard.getSystemClipboard(); final Object content = clipboard.getContent(DATA_FORMAT); if (!(content instanceof Long)) { return; } final Long objectId = (Long) content; final TreeItem<?> treeItem = UiUtils.findItem(nodeTree.getTreeView(), objectId); final TreeNode<?> treeNode = treeItem == null ? null : (TreeNode<?>) treeItem.getValue(); if (treeNode != null && canAccept(treeNode, true)) { items.add(new PasteNodeAction(nodeTree, this, treeNode)); } }
Example 4
Source File: TerminalView.java From TerminalFX with MIT License | 5 votes |
@WebkitCall(from = "hterm") public void copy(String text) { final Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent clipboardContent = new ClipboardContent(); clipboardContent.putString(text); clipboard.setContent(clipboardContent); }
Example 5
Source File: ScanCommandTree.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** Paste commands from clipboard, append after currently selected item */ void pasteFromClipboard() { final Clipboard clip = Clipboard.getSystemClipboard(); if (ScanCommandDragDrop.hasCommands(clip)) { final List<ScanCommand> commands = ScanCommandDragDrop.getCommands(clip); final TreeItem<ScanCommand> item = getSelectionModel().getSelectedItem(); final ScanCommand location = item != null ? item.getValue() : null; undo.execute(new AddCommands(model, location, commands, true)); } }
Example 6
Source File: BrowsableField.java From pdfsam with GNU Affero General Public License v3.0 | 5 votes |
@Override public void paste() { Clipboard clipboard = Clipboard.getSystemClipboard(); if (clipboard.hasString()) { String text = clipboard.getString(); if (text.length() > 2 && text.charAt(0) == '"' && text.charAt(text.length() - 1) == '"') { replaceSelection(text.substring(1, text.length() - 1)); } else { super.paste(); } } }
Example 7
Source File: SystemClipboard.java From marathonv5 with Apache License 2.0 | 5 votes |
public SystemClipboard() { clipboard = Clipboard.getSystemClipboard(); Timeline monitorTask = new Timeline(new KeyFrame(Duration.millis(200), this)); monitorTask.setCycleCount(Animation.INDEFINITE); monitorTask.play(); prevData = null; }
Example 8
Source File: SystemTools.java From MyBox with Apache License 2.0 | 5 votes |
public static Image fetchImageInClipboard(boolean clear) { Clipboard clipboard = Clipboard.getSystemClipboard(); if (!clipboard.hasImage()) { return null; } Image image = clipboard.getImage(); if (clear) { clipboard.clear(); } return image; }
Example 9
Source File: ExceptionController.java From BetonQuest-Editor with GNU General Public License v3.0 | 5 votes |
@FXML private void copy() { try { Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent content = new ClipboardContent(); String string = stackTrace.getText(); // add 4 spaces before each line so when pasted on GitHub it's formatted as code content.putString(" " + string.replace("\n", "\n ").trim()); clipboard.setContent(content); } catch (Exception e) { ExceptionController.display(e); } }
Example 10
Source File: ClickableBitcoinAddress.java From GreenBits with GNU General Public License v3.0 | 5 votes |
@FXML protected void copyAddress(ActionEvent event) { // User clicked icon or menu item. Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent content = new ClipboardContent(); content.putString(addressStr.get()); content.putHtml(String.format("<a href='%s'>%s</a>", uri(), addressStr.get())); clipboard.setContent(content); }
Example 11
Source File: UIMenuItem.java From tcMenu with Apache License 2.0 | 5 votes |
public boolean handleCopy() { TextField focused = getFocusedTextField(); if (focused == null) return false; String text = focused.getSelectedText(); if (!StringHelper.isStringEmptyOrNull(text)) { Clipboard systemClipboard = Clipboard.getSystemClipboard(); ClipboardContent content = new ClipboardContent(); content.putString(text); systemClipboard.setContent(content); } return true; }
Example 12
Source File: ContextMenuPvToClipboard.java From phoebus with Eclipse Public License 1.0 | 5 votes |
@Override public void call(final Selection selection) throws Exception { final List<ProcessVariable> pvs = selection.getSelections(); final Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent content = new ClipboardContent(); content.putString(pvs.stream().map(ProcessVariable::getName).collect(Collectors.joining(" "))); clipboard.setContent(content); }
Example 13
Source File: Screenshot.java From chart-fx with Apache License 2.0 | 5 votes |
/** * Save screenshot to clipbaord */ public void screenshotToClipboard() { Image image = getScreenshot(); Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent content = new ClipboardContent(); content.putImage(image); clipboard.setContent(content); LOGGER.atInfo().log("Copied screenshot to clipboard"); }
Example 14
Source File: TableViewUtilities.java From constellation with Apache License 2.0 | 5 votes |
/** * Copy the given text to the system clipboard. * * @param text the text to copy. */ public static void copyToClipboard(final String text) { final Clipboard clipboard = Clipboard.getSystemClipboard(); final ClipboardContent content = new ClipboardContent(); content.putString(text); clipboard.setContent(content); }
Example 15
Source File: CopyNodeAction.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@Override @FxThread protected void process() { super.process(); final TreeNode<?> node = getNode(); final ClipboardContent content = new ClipboardContent(); content.put(DATA_FORMAT, node.getObjectId()); final Clipboard clipboard = Clipboard.getSystemClipboard(); clipboard.setContent(content); }
Example 16
Source File: OpenLabelerController.java From OpenLabeler with Apache License 2.0 | 5 votes |
private ObjectModel fromClipboard() { Clipboard clipboard = Clipboard.getSystemClipboard(); if (clipboard.getContentTypes().contains(DATA_FORMAT_JAXB)) { try { String content = (String)clipboard.getContent(DATA_FORMAT_JAXB); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); return (ObjectModel) unmarshaller.unmarshal(new StringReader(content)); } catch (Exception ex) { LOG.log(Level.SEVERE, "Unable to get content from clipboard", ex); } } return null; }
Example 17
Source File: GuiTest.java From VocabHunter with Apache License 2.0 | 4 votes |
private String collectCurrentClipboardText() { Clipboard clipboard = Clipboard.getSystemClipboard(); return clipboard.getString(); }
Example 18
Source File: CircuitSim.java From CircuitSim with BSD 3-Clause "New" or "Revised" License | 4 votes |
void copySelectedComponents() { CircuitManager manager = getCurrentCircuit(); if(manager != null) { Set<GuiElement> selectedElements = manager.getSelectedElements(); if(selectedElements.isEmpty()) { return; } List<ComponentInfo> components = selectedElements .stream() .filter(element -> element instanceof ComponentPeer<?>) .map(element -> (ComponentPeer<?>)element) .map(component -> new ComponentInfo(component.getClass().getName(), component.getX(), component.getY(), component.getProperties())) .collect(Collectors.toList()); List<WireInfo> wires = selectedElements .stream() .filter(element -> element instanceof Wire) .map(element -> (Wire)element) .map(wire -> new WireInfo(wire.getX(), wire.getY(), wire.getLength(), wire.isHorizontal())) .collect(Collectors.toList()); try { String data = FileFormat.stringify( new CircuitFile(0, 0, null, Collections.singletonList( new CircuitInfo("Copy", components, wires)))); Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent content = new ClipboardContent(); content.put(copyDataFormat, data); clipboard.setContent(content); } catch(Exception exc) { setLastException(exc); getDebugUtil().logException("Error while copying", exc); } } }
Example 19
Source File: WebViewContextMenuTest.java From oim-fx with MIT License | 4 votes |
public void paste() { final Clipboard clipboard = Clipboard.getSystemClipboard(); String content = (String) clipboard.getContent(DataFormat.PLAIN_TEXT); webView.getEngine().executeScript(String.format("editor.replaceSelection(\"%s\");", content)); }
Example 20
Source File: FileUtils.java From Notebook with Apache License 2.0 | 4 votes |
public static void toClipboard(String message) { Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent clipboardContent = new ClipboardContent(); clipboardContent.putString(message); clipboard.setContent(clipboardContent); }