@Override protected Transferable createTransferable(JComponent c) { if (!(c instanceof XDebuggerTree)) { return null; } XDebuggerTree tree = (XDebuggerTree)c; //noinspection deprecation TreePath[] selectedPaths = tree.getSelectionPaths(); if (selectedPaths == null || selectedPaths.length == 0) { return null; } StringBuilder plainBuf = new StringBuilder(); StringBuilder htmlBuf = new StringBuilder(); htmlBuf.append("<html>\n<body>\n<ul>\n"); TextTransferable.ColoredStringBuilder coloredTextContainer = new TextTransferable.ColoredStringBuilder(); for (TreePath path : selectedPaths) { htmlBuf.append(" <li>"); Object node = path.getLastPathComponent(); if (node != null) { if (node instanceof XDebuggerTreeNode) { ((XDebuggerTreeNode)node).appendToComponent(coloredTextContainer); coloredTextContainer.appendTo(plainBuf, htmlBuf); } else { String text = node.toString(); plainBuf.append(text); htmlBuf.append(text); } } plainBuf.append('\n'); htmlBuf.append("</li>\n"); } // remove the last newline plainBuf.setLength(plainBuf.length() - 1); htmlBuf.append("</ul>\n</body>\n</html>"); return new TextTransferable(htmlBuf.toString(), plainBuf.toString()); }
@Override protected Transferable createTransferable(JComponent c) { if (!(c instanceof XDebuggerFramesList)) { return null; } XDebuggerFramesList list = (XDebuggerFramesList)c; //noinspection deprecation Object[] values = list.getSelectedValues(); if (values == null || values.length == 0) { return null; } StringBuilder plainBuf = new StringBuilder(); StringBuilder htmlBuf = new StringBuilder(); TextTransferable.ColoredStringBuilder coloredTextContainer = new TextTransferable.ColoredStringBuilder(); htmlBuf.append("<html>\n<body>\n<ul>\n"); for (Object value : values) { htmlBuf.append(" <li>"); if (value != null) { if (value instanceof XStackFrame) { ((XStackFrame)value).customizePresentation(coloredTextContainer); coloredTextContainer.appendTo(plainBuf, htmlBuf); } else { String text = value.toString(); plainBuf.append(text); htmlBuf.append(text); } } plainBuf.append('\n'); htmlBuf.append("</li>\n"); } // remove the last newline plainBuf.setLength(plainBuf.length() - 1); htmlBuf.append("</ul>\n</body>\n</html>"); return new TextTransferable(htmlBuf.toString(), plainBuf.toString()); }
@Override public void actionPerformed(AnActionEvent e) { if (myLineNumber < 0) return; final VcsRevisionNumber revisionNumber = myAnnotation.getLineRevisionNumber(myLineNumber); if (revisionNumber != null) { final String revision = revisionNumber.asString(); CopyPasteManager.getInstance().setContents(new TextTransferable(revision)); } }
@Override public void actionPerformed(AnActionEvent e) { try { CopyPasteManager.getInstance().setContents(new TextTransferable(myAllocation.getText())); } catch (HeadlessException e1) { LOG.error(e1); } }
private void copyDrawableId() { DrawableModel drawableModel = drawableModelList.get(itemList.getMinSelectionIndex()); String fileName = drawableModel.getFileName(); int position = fileName.lastIndexOf("."); if (position >= 0) { fileName = fileName.substring(0, position); } final String fileNameWithoutExtension = fileName; CopyPasteManager.getInstance().setContents(new TextTransferable("R.drawable." + fileNameWithoutExtension)); }
@NotNull public Transferable doCopy(@NotNull T container, @NotNull Object commonValue) { return new TextTransferable(commonValue.toString()); }
private void copyOutput(XmlOutput xmlOutput) { CopyPasteManager.getInstance().setContents(new TextTransferable(xmlOutput.getText())); }