Java 类javafx.scene.input.Clipboard 实例源码

项目:PhotoScript    文件:Controller.java   
@Override
protected String call() throws Exception {
    final String url = PictureUploadUtil.getUrl(file.getAbsolutePath());

    Platform.runLater(() -> {
        labelHint.setText("");
        Alert alert = new Alert(
                Alert.AlertType.INFORMATION,
                url,
                new ButtonType("复制到剪切板", ButtonBar.ButtonData.YES)
        );
        alert.setTitle("上传成功");
        alert.setHeaderText(null);
        Optional<ButtonType> buttonType = alert.showAndWait();
        if (buttonType.get().getButtonData().equals(ButtonBar.ButtonData.YES)) {
            Clipboard clipboard = Clipboard.getSystemClipboard();
            ClipboardContent cc = new ClipboardContent();
            cc.putString(url);
            clipboard.setContent(cc);
        }
    });
    return url;
}
项目:ServerBrowser    文件:SampServerTable.java   
private void setMenuItemDefaultActions() {
    connectMenuItem.setOnAction(__ -> {
        getFirstIfAnythingSelected().ifPresent(server -> GTAController.tryToConnect(server.getAddress(), server.getPort()));
    });

    visitWebsiteMenuItem.setOnAction(__ -> getFirstIfAnythingSelected().ifPresent(server -> OSUtility.browse(server.getWebsite())));

    addToFavouritesMenuItem.setOnAction(__ -> {
        final List<SampServer> serverList = getSelectionModel().getSelectedItems();
        serverList.forEach(FavouritesController::addServerToFavourites);
    });

    removeFromFavouritesMenuItem.setOnAction(__ -> deleteSelectedFavourites());

    copyIpAddressAndPortMenuItem.setOnAction(__ -> {
        final Optional<SampServer> serverOptional = getFirstIfAnythingSelected();

        serverOptional.ifPresent(server -> {
            final ClipboardContent content = new ClipboardContent();
            content.putString(server.getAddress() + ":" + server.getPort());
            Clipboard.getSystemClipboard().setContent(content);
        });
    });
}
项目:jmonkeybuilder    文件:TreeNode.java   
/**
 * 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));
    }
}
项目:jmonkeybuilder    文件:CopyFileAction.java   
@FXThread
@Override
protected void execute(@Nullable final ActionEvent event) {
    super.execute(event);

    final Array<ResourceElement> elements = getElements();
    final Array<Path> files = ArrayFactory.newArray(Path.class, elements.size());
    elements.forEach(files, (resource, toStore) -> toStore.add(resource.getFile()));

    final ClipboardContent content = new ClipboardContent();

    EditorUtil.addCopiedFile(files, content);

    final Clipboard clipboard = Clipboard.getSystemClipboard();
    clipboard.setContent(content);
}
项目:jmonkeybuilder    文件:PasteFileAction.java   
@FXThread
@Override
protected void execute(@Nullable final ActionEvent event) {
    super.execute(event);

    final Clipboard clipboard = Clipboard.getSystemClipboard();
    if (clipboard == null) return;

    final List<File> files = unsafeCast(clipboard.getContent(DataFormat.FILES));
    if (files == null || files.isEmpty()) return;

    final Path currentFile = getElement().getFile();
    final boolean 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();
}
项目:jmonkeybuilder    文件:CutFileAction.java   
@FXThread
@Override
protected void execute(@Nullable final ActionEvent event) {
    super.execute(event);

    final List<File> files = getElements().stream()
            .map(ResourceElement::getFile)
            .map(Path::toFile)
            .collect(toList());

    final ClipboardContent content = new ClipboardContent();
    content.putFiles(files);
    content.put(EditorUtil.JAVA_PARAM, "cut");

    final Clipboard clipboard = Clipboard.getSystemClipboard();
    clipboard.setContent(content);
}
项目:Gargoyle    文件:XMLTreeView.java   
private void keyOnPressd(KeyEvent e) {

        if (e.isControlDown() && e.getCode() == KeyCode.C) {

            if (e.isConsumed())
                return;

            ObservableList<TreeItem<XMLMeta>> items = this.getSelectionModel().getSelectedItems();
            Clipboard c = Clipboard.getSystemClipboard();
            ClipboardContent cc = new ClipboardContent();

            StringBuffer sb = new StringBuffer();
            for (TreeItem<XMLMeta> item : items) {
                sb.append(item.getValue().getText()).append("\n");
            }
            cc.putString(sb.toString());
            c.setContent(cc);

            e.consume();
        }

    }
项目:Gargoyle    文件:TinymceDeligator.java   
/**
 * 붙여넣기 핸들링 <br/>
 * 
 * 10.26 이미지 붙여넣기
 * 
 * @작성자 : KYJ
 * @작성일 : 2017. 10. 26.
 * @param ev
 */
protected void pasteHandler(KeyEvent ev) {
    Clipboard systemClipboard = Clipboard.getSystemClipboard();
    Set<DataFormat> contentTypes = systemClipboard.getContentTypes();
    LOGGER.debug("{}", contentTypes);

    List<File> files = systemClipboard.getFiles();

    if (systemClipboard.getImage() != null) {
        pasteImage(systemClipboard.getImage());
    } else if (files != null) {

        for (File f : files) {
            try {
                String contentType = Files.probeContentType(f.toPath());
                LOGGER.debug(contentType);
                if (contentType.startsWith("image/")) {
                    pasteImage(contentType, FileUtil.getBytes(f));
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
项目:CSVboard    文件:TableKeyEventHandler.java   
/**
 * Get table selection and copy it to the clipboard.
 * @param table
 * @return    
 */
private ObservableList<CsvData> cutSelectionToClipboard(TableView<CsvData> table) {
        StringBuilder clipboardString = new StringBuilder(); 
        ObservableList<CsvData> tmpData = table.getSelectionModel().getSelectedItems(); 
        int colNum = CSVmanager.getColNums()-1;                
        String text;
        if (tmpData != null) {
        for (int i=0;i<tmpData.size();i++) { 
            for(int k=0;k<colNum;k++) {
                text = tmpData.get(i).getDataValue(k, i);
                clipboardString.append(text);
                clipboardString.append(",");
            }           
            clipboardString.append("\n");
        } 
        // create clipboard content
        final ClipboardContent clipboardContent = new ClipboardContent();
        clipboardContent.putString(clipboardString.toString()); 
        // set clipboard content
        Clipboard.getSystemClipboard().setContent(clipboardContent);
}
        return tmpData;
}
项目:opc-ua-client    文件:DataTreeViewPresenter.java   
@FXML
void copyValue() {
  if (!tableTree.isFocused()) {
    return;
  }
  TreeItem<ReferenceDescription> item = tableTree.getSelectionModel().getSelectedItem();
  if (item != null && item.getValue() != null) {
    try {
      StringWriter writer = new StringWriter();
      XmlEncoder encoder = new XmlEncoder();
      encoder.setOutput(writer);
      writer.write("<ReferenceDescription>");
      ReferenceDescription.encode(item.getValue(), encoder);
      writer.write("</ReferenceDescription>");
      writer.flush();

      Clipboard clipboard = Clipboard.getSystemClipboard();
      ClipboardContent content = new ClipboardContent();
      content.putString(writer.toString());
      clipboard.setContent(content);
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
    }
  }
}
项目:openjfx-8u-dev-tests    文件:DragDropWithControls.java   
private Parent createRightPane() {
    HBox hbox = new HBox(10);

    VBox lbox = new VBox(10);
    lbox.getChildren().addAll(targetControlPane, new Separator(), new Text("Target control type:"),
            createControlCombo(targetControlPane, false), new Text("Target transfer modes:"), createTMSelect(targetModes));

    VBox rbox = new VBox(10);
    rbox.getChildren().addAll(new Text("Data formats:"), createFormatSelect(targetFormats),
            ButtonBuilder.create().text("paste from clipboard").id(ID_FROM_CLIPBOARD_BUTTON).onAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent t) {
            getDataFromClipboard(Clipboard.getSystemClipboard());
        }
    }).build());

    VBox content = new VBox(10);
    content.getChildren().addAll(new Text("Transfered content:"), transferedContentPane);

    hbox.getChildren().addAll(lbox, new Separator(Orientation.VERTICAL), rbox,
            new Separator(Orientation.VERTICAL), content);
    if (parameters.size() > 0) {
        hbox.setStyle("-fx-background-color: " + parameters.get(0) + ";");
    }
    return hbox;
}
项目:questfiller    文件:MainWindow.java   
@FXML
public void initialize() {
    copyBtn.setOnAction(e -> {
        final ClipboardContent content = new ClipboardContent();
        content.putString(textArea.getText());
        Clipboard.getSystemClipboard().setContent(content);
    });

    // Select the entire URL on focus gain
    wowheadUrl.focusedProperty().addListener((ChangeListener<Boolean>) (value, oldValue, newValue) -> {
        if (newValue) {
            Platform.runLater(wowheadUrl::selectAll);
        }
    });

    supportedArticleTypes.setText("Supported article types: "
            + Stream.of(ParserType.values()).map(Object::toString).collect(Collectors.joining(", ")));
}
项目:amazon.de-Orders    文件:KeyEventHandlerTableview.java   
private void copy2clipboard(TableView source) {
    StringBuilder out = new StringBuilder();

    ObservableList<Integer> selectedCells = source.getSelectionModel().getSelectedIndices();

    int columns = source.getColumns().size();

    for (Integer row : selectedCells) {
        for (int idx = 0; idx < columns; idx++) {
            TableColumn tc = (TableColumn) source.getColumns().get(idx);
            Object item = tc.getCellData((int) row);
            out.append(item.toString());
            if (idx != columns - 1) {
                out.append('\t');
            }
        }
        out.append("\n");
    }

    ClipboardContent clipboardContent = new ClipboardContent();
    clipboardContent.putString(out.toString());
    Clipboard.getSystemClipboard().setContent(clipboardContent);

}
项目:certmgr    文件:StoreController.java   
@SuppressWarnings("unused")
@FXML
void onCmdCopyEntry(ActionEvent evt) {
    UserCertStoreEntry entry = getSelectedStoreEntry();

    if (entry != null) {
        List<Path> entryFilePaths = entry.getFilePaths();

        if (!entryFilePaths.isEmpty()) {
            List<File> entryFiles = entryFilePaths.stream().map((p) -> p.toFile()).collect(Collectors.toList());
            Clipboard clipboard = Clipboard.getSystemClipboard();
            ClipboardContent content = new ClipboardContent();

            content.putFiles(entryFiles);
            clipboard.setContent(content);
        }
    }
}
项目:certmgr    文件:StoreController.java   
@SuppressWarnings("unused")
@FXML
void onCmdCopyEntryAttributes(ActionEvent evt) {
    TreeItem<AttributeModel> rootItem = this.ctlDetailsView.getRoot();

    if (rootItem != null) {
        StringWriter buffer = new StringWriter();
        PrintWriter writer = new PrintWriter(buffer);

        for (TreeItem<AttributeModel> attributeItem : rootItem.getChildren()) {
            copyEntryAttributesHelper(writer, attributeItem, "");
        }

        writer.flush();

        Clipboard clipboard = Clipboard.getSystemClipboard();
        ClipboardContent content = new ClipboardContent();

        content.putString(buffer.toString());
        clipboard.setContent(content);
    }
}
项目:qupath    文件:ProjectMetadataEditorCommand.java   
private static void pasteClipboardContentsToTable(TableView<?> table) {
    String s = Clipboard.getSystemClipboard().getString();
    if (s == null) {
        logger.warn("No text on clipboard");
        return;
    }

    List<TablePosition> positions = table.getSelectionModel().getSelectedCells();
    if (positions.isEmpty()) {
        logger.warn("No table cells selected");
        return;
    }

    if (s.contains("\n") || s.contains("\t")) {
        DisplayHelpers.showWarningNotification("Paste contents", "Cannot paste clipboard contents - only simple, single-cell text supported");
        return;
    }

    setTextForSelectedCells(positions, s);
    table.refresh();
}
项目:qupath    文件:ImageTableCell.java   
private void createPopOver(final TMAEntry entry, final boolean isOverlay) {
    // Request full resolution image
    Image image = isOverlay ? cache.getOverlay(entry, -1) : cache.getImage(entry, -1);
    if (image == null)
        return;
    // Create PopOver to show larger image
    ImageView imageView = new ImageView(image);
    imageView.setPreserveRatio(true);
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    // TODO: Consider setting max width/height elsewhere, so user can adjust?
    imageView.setFitWidth(Math.min(primaryScreenBounds.getWidth()*0.5, image.getWidth()));
    imageView.setFitHeight(Math.min(primaryScreenBounds.getHeight()*0.75, image.getHeight()));
    // Enable copying to clipboard
    miCopy.setOnAction(e -> {
        ClipboardContent content = new ClipboardContent();
        content.putImage(image);
        Clipboard.getSystemClipboard().setContent(content);
    });
    imageView.setOnContextMenuRequested(e -> menu.show(this, e.getScreenX(), e.getScreenY()));

    popOver = new PopOver(imageView);
    String name = this.getTreeTableRow().getItem() == null ? null : this.getTreeTableRow().getItem().getName();
    if (name != null)
        popOver.setTitle(name);
}
项目:WhoWhatWhere    文件:VisualTraceController.java   
private void setMapContextMenu()
{
    imgView.setOnContextMenuRequested(event ->
    {
        MenuItem copyMap = new MenuItem("  Copy map image");
        copyMap.setOnAction(mapEvent ->
        {
            Clipboard clipboard = Clipboard.getSystemClipboard();
            ClipboardContent content = new ClipboardContent();

            content.putImage(imgView.getImage());
            clipboard.setContent(content);
        });

        ContextMenu menu = new ContextMenu(copyMap);
        menu.show(imgView.getScene().getWindow(), event.getScreenX(), event.getScreenY());
    });
}
项目:mzmine3    文件:MsSpectrumPlotWindowController.java   
public void handleCopySpectra(Event event) {
  StringBuilder sb = new StringBuilder();
  for (MsSpectrumDataSet dataset : datasets) {
    MsSpectrum spectrum = dataset.getSpectrum();
    String spectrumString = TxtExportAlgorithm.spectrumToString(spectrum);
    String splash = SplashCalculationAlgorithm.calculateSplash(spectrum);
    sb.append("# ");
    sb.append(dataset.getName());
    sb.append("\n");
    sb.append("# SPLASH ID: ");
    sb.append(splash);
    sb.append("\n");
    sb.append(spectrumString);
    sb.append("\n");
  }
  final Clipboard clipboard = Clipboard.getSystemClipboard();
  final ClipboardContent content = new ClipboardContent();
  content.putString(sb.toString());
  clipboard.setContent(content);
}
项目:org.csstudio.display.builder    文件:DisplayEditor.java   
/** Copy currently selected widgets to clipboard
 *  @return Widgets that were copied or <code>null</code>
 */
public List<Widget> copyToClipboard()
{
    if (selection_tracker.isInlineEditorActive())
        return null;

    final List<Widget> widgets = selection.getSelection();
    if (widgets.isEmpty())
        return null;

    final String xml;
    try
    {
        xml = ModelWriter.getXML(widgets);
    }
    catch (Exception ex)
    {
        logger.log(Level.WARNING, "Cannot create content for clipboard", ex);
        return null;
    }

    final ClipboardContent content = new ClipboardContent();
    content.putString(xml);
    Clipboard.getSystemClipboard().setContent(content);
    return widgets;
}
项目:org.csstudio.display.builder    文件:RegionBaseRepresentation.java   
/** Copy PV name to clipboard when middle button clicked
 *  @param event Mouse pressed event
 */
private void hookMiddleButtonCopy(final MouseEvent event)
{
    if (event.getButton() != MouseButton.MIDDLE)
        return;

    final String pv_name = ((PVWidget)model_widget).propPVName().getValue();

    // Copy to copy/paste clipboard
    final ClipboardContent content = new ClipboardContent();
    content.putString(pv_name);
    Clipboard.getSystemClipboard().setContent(content);

    // Copy to the 'selection' buffer used by X11
    // for middle-button copy/paste
    // Note: This is AWT API!
    // JavaFX has no API, https://bugs.openjdk.java.net/browse/JDK-8088117
    Toolkit.getDefaultToolkit().getSystemSelection().setContents(new StringSelection(pv_name), null);
}
项目:tokentool    文件:TokenTool_Controller.java   
@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);
}
项目:RichTextFX    文件:ClipboardActions.java   
/**
 * Transfers the currently selected text to the clipboard,
 * leaving the current selection.
 */
default void copy() {
    IndexRange selection = getSelection();
    if(selection.getLength() > 0) {
        ClipboardContent content = new ClipboardContent();

        content.putString(getSelectedText());

        getStyleCodecs().ifPresent(codecs -> {
            Codec<StyledDocument<PS, SEG, S>> codec = ReadOnlyStyledDocument.codec(codecs._1, codecs._2, getSegOps());
            DataFormat format = dataFormat(codec.getName());
            StyledDocument<PS, SEG, S> doc = subDocument(selection.getStart(), selection.getEnd());
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            DataOutputStream dos = new DataOutputStream(os);
            try {
                codec.encode(dos, doc);
                content.put(format, os.toByteArray());
            } catch (IOException e) {
                System.err.println("Codec error: Exception in encoding '" + codec.getName() + "':");
                e.printStackTrace();
            }
        });

        Clipboard.getSystemClipboard().setContent(content);
    }
}
项目:vidada-desktop    文件:MediaViewModel.java   
/**
 * Returns all actions which can be invoked for this media item.
 *
 * They are usually visualized by a toolbar or a context menu
 * for each media.
 *
 */
public List<Runnable> getActions(){
    List<Runnable> actions = new ArrayList<Runnable>();
    for(IMediaHandler handler : mediaPresenter.getAllMediaHandlers()){
        actions.add(new MediaHandlerAction(this, handler));
    }

    // Add some hardcoded actions...

    actions.add(new NamedAction("Copy Link", new Runnable() {
        @Override
        public void run() {
            ResourceLocation mediaResource = getMediaResource();
            final Clipboard clipboard = Clipboard.getSystemClipboard();
            final ClipboardContent content = new ClipboardContent();
            content.putString(mediaResource.getPath());
            clipboard.setContent(content);
        }
    }));

    return actions;
}
项目:fwm    文件:JettyController.java   
@FXML
public void copyAddress(ActionEvent event) {
       try {
        ClipboardContent content = new ClipboardContent();
        content.putString(getAddress());
        Clipboard.getSystemClipboard().setContent(content);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:Squid    文件:ExpressionBuilderController.java   
@FXML
private void copyButtonAction(ActionEvent event) {
    String fullText = makeStringFromTextFlow();
    final Clipboard clipboard = Clipboard.getSystemClipboard();
    final ClipboardContent content = new ClipboardContent();
    content.putString(fullText);
    clipboard.setContent(content);
}
项目:marathonv5    文件:GroupResource.java   
public void paste(int index, Clipboard clipboard, Operation operation) {
    if (!clipboard.hasFiles() || !type.droppable(clipboard.getFiles(), getFilePath())) {
        return;
    }
    List<File> files = clipboard.getFiles();
    ObservableList<TreeItem<Resource>> cs = getChildren();
    for (File file : files) {
        GroupEntry ge = null;
        try {
            if (Constants.isSuiteFile(file)) {
                ge = new GroupGroupEntry(GroupEntryType.SUITE, file.toPath().toString());
            } else if (Constants.isFeatureFile(file)) {
                ge = new GroupGroupEntry(GroupEntryType.FEATURE, file.toPath().toString());
            } else if (Constants.isStoryFile(file)) {
                ge = new GroupGroupEntry(GroupEntryType.STORY, file.toPath().toString());
            } else if (Constants.isIssueFile(file)) {
                ge = new GroupGroupEntry(GroupEntryType.ISSUE, file.toPath().toString());
            } else if (Constants.isTestFile(file)) {
                ge = getTestEntry(file);
            }
        } catch (IOException e) {
            e.printStackTrace();
            continue;
        }
        cs.add(index, new GroupEntryResource(ge));
        group.getEntries().add(index, ge);
        index++;
    }
    try {
        Group.updateFile(group);
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    Event.fireEvent(this, new ResourceModificationEvent(ResourceModificationEvent.UPDATE, this));
    return;
}
项目:marathonv5    文件:ResourceView.java   
private void copy(ObservableList<TreeItem<Resource>> selectedItems) {
    Clipboard clipboard = Clipboard.getSystemClipboard();
    Map<DataFormat, Object> content = new HashMap<>();
    for (TreeItem<Resource> treeItem : selectedItems) {
        Resource resource = treeItem.getValue();
        if (resource != null) {
            if (!resource.copy(content)) {
                FXUIUtils.showMessageDialog(null, "Clipboard operation failed", "Unhandled resource selection",
                        AlertType.ERROR);
            }
        }
    }
    clipboard.setContent(content);
    clipboardOperation = Operation.COPY;
}
项目:marathonv5    文件:FolderResource.java   
@Override public void pasteInto(Clipboard clipboard, Operation operation) {
    if (clipboard.hasFiles()) {
        List<File> files = clipboard.getFiles();
        List<Path> paths = new ArrayList<>();
        for (File file : files) {
            paths.add(file.toPath().toAbsolutePath());
        }
        Collections.sort(paths);
        Path lastCopiedPath = null;
        for (Path path : paths) {
            try {
                if (lastCopiedPath == null || !path.startsWith(lastCopiedPath)) {
                    Path newPath = Copy.copy(path, this.path, operation);
                    if (newPath == null) {
                        continue;
                    }
                    Resource to;
                    if (Files.isDirectory(newPath)) {
                        to = new FolderResource(newPath.toFile(), watcher);
                    } else {
                        to = new FileResource(newPath.toFile());
                    }
                    lastCopiedPath = path;
                    Resource from;
                    if (path.toFile().isDirectory()) {
                        from = new FolderResource(path.toFile(), watcher);
                    } else {
                        from = new FileResource(path.toFile());
                    }
                    Event.fireEvent(this, new ResourceView.ResourceModificationEvent(
                            operation == Operation.CUT ? ResourceModificationEvent.MOVED : ResourceModificationEvent.COPIED,
                            from, to));
                }
            } catch (IOException e) {
                FXUIUtils.showMessageDialog(null, "Error in copying files.", e.getMessage(), AlertType.ERROR);
            }
        }
    }
    Platform.runLater(() -> refresh());
}
项目:marathonv5    文件:SystemClipboard.java   
public SystemClipboard() {
    clipboard = Clipboard.getSystemClipboard();
    Timeline monitorTask = new Timeline(new KeyFrame(Duration.millis(200), this));
    monitorTask.setCycleCount(Animation.INDEFINITE);
    monitorTask.play();
    prevData = null;
}
项目:creacoinj    文件:ClickableBitcoinAddress.java   
@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);
}
项目:shuffleboard    文件:DragUtils.java   
/**
 * Checks if a node is a widget tile being dragged.
 *
 * @param node the node to check
 */
public static boolean isDraggedWidget(Node node) {
  return node != null
      && Clipboard.getSystemClipboard().hasContent(DataFormats.widgetTile)
      && Objects.equals(node.getId(),
      ((DataFormats.WidgetData) Clipboard.getSystemClipboard().getContent(DataFormats.widgetTile)).getId());
}
项目:WebPLP    文件:CodeEditor.java   
public void copySelectionToClipboard()
{
    //http://stackoverflow.com/questions/13929371/copy-and-paste-in-codemirror-js-embeded-in-javafx-application
    final Clipboard clipboard = Clipboard.getSystemClipboard();
    final ClipboardContent content = new ClipboardContent();
    content.putString(getSelectedText());
    clipboard.setContent(content);
}
项目:WebPLP    文件:CodeEditor.java   
private void initializeEngineEvents()
{
    webView.addEventFilter(KeyEvent.KEY_PRESSED, e -> {
        if( e.isShortcutDown() && e.getCode() == KeyCode.V) 
        {
            String content = (String) Clipboard.getSystemClipboard().getContent(DataFormat.PLAIN_TEXT);
            if (content != null) 
            {
                webView.getEngine().executeScript("editor.onPaste('" + sanitizeForAce(content) + "');");
            }
           }
    });
}
项目:altaeet    文件:Controller.java   
@FXML
public void copyCliboard() {
    final Clipboard clipboard = Clipboard.getSystemClipboard();
    final ClipboardContent content = new ClipboardContent();
    content.putString(posledniUctenka);
    clipboard.setContent(content);
}
项目:fxexperience2    文件:DoubleTextField.java   
@Override
public void paste() {
    String strToPaste = Clipboard.getSystemClipboard().getString();
    try {
        Double.parseDouble(strToPaste);
    } catch (NumberFormatException e) {
        return;
    }
    super.paste();
}
项目:legendary-guide    文件:ClickableBitcoinAddress.java   
@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);
}
项目:symmetrical-memory    文件:PasswordRevealModal.java   
@FXML
public void copyPassword() {
    ClipboardContent clipboardContent = new ClipboardContent();
    clipboardContent.putString(new String(password));

    Clipboard.getSystemClipboard()
            .setContent(clipboardContent);
}
项目:cassandra-client    文件:TableCellCopyHandler.java   
@Override
public void run() {
    Clipboard clipboard = Clipboard.getSystemClipboard();
    ClipboardContent content = new ClipboardContent();

    int row = tableView.getSelectionModel().getSelectedIndex();
    ObservableList<TablePosition> selectedCells = tableView.getSelectionModel().getSelectedCells();
    if (!selectedCells.isEmpty()) {
        TablePosition tablePosition = selectedCells.get(0);
        Object cellData = tablePosition.getTableColumn().getCellData(row);
        content.putString(Objects.toString(cellData));
        clipboard.setContent(content);
    }
}
项目:kanphnia2    文件:ToDoOverviewController.java   
@FXML
private void copyToClipboard() throws Exception {
    int selectedIndex = entryTable.getSelectionModel().getSelectedIndex();
       final ClipboardContent content = new ClipboardContent();

    if (selectedIndex >= 0) {
        content.putString(entryTable.getItems().get(selectedIndex).getPassword(false));
        Clipboard.getSystemClipboard().setContent(content);
    }
    else {
        content.putString("");
        Clipboard.getSystemClipboard().setContent(content);
    }
}