use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.
the class TextCopyProvider method performCopy.
@Override
public void performCopy(@NotNull DataContext dataContext) {
Collection<String> lines = getTextLinesToCopy();
if (lines != null && !lines.isEmpty()) {
String text = StringUtil.join(lines, getLinesSeparator());
CopyPasteManager.getInstance().setContents(new StringSelection(text));
}
}
use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.
the class CopyUrlAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
String url = findUrlAtCaret(e);
assert url != null;
CopyPasteManager.getInstance().setContents(new StringSelection(url));
}
use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.
the class EditorCopyPasteHelperImpl method copySelectionToClipboard.
@Override
public void copySelectionToClipboard(@NotNull Editor editor) {
ApplicationManager.getApplication().assertIsDispatchThread();
List<TextBlockTransferableData> extraData = new ArrayList<>();
String s = editor.getCaretModel().supportsMultipleCarets() ? getSelectedTextForClipboard(editor, extraData) : editor.getSelectionModel().getSelectedText();
if (s == null)
return;
s = TextBlockTransferable.convertLineSeparators(s, "\n", extraData);
Transferable contents = editor.getCaretModel().supportsMultipleCarets() ? new TextBlockTransferable(s, extraData, null) : new StringSelection(s);
CopyPasteManager.getInstance().setContents(contents);
}
use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.
the class CopyConcatenatedStringToClipboardIntention method processIntention.
@Override
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
if (!(element instanceof PsiPolyadicExpression)) {
return;
}
final PsiPolyadicExpression concatenationExpression = (PsiPolyadicExpression) element;
final IElementType tokenType = concatenationExpression.getOperationTokenType();
if (tokenType != JavaTokenType.PLUS) {
return;
}
final PsiType type = concatenationExpression.getType();
if (type == null || !type.equalsToText(JAVA_LANG_STRING)) {
return;
}
final StringBuilder text = buildConcatenationText(concatenationExpression, new StringBuilder());
CopyPasteManager.getInstance().setContents(new StringSelection(text.toString()));
}
use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.
the class EditorMultiCaretTest method testPastingLineWithBreakFromOutside.
public void testPastingLineWithBreakFromOutside() throws Exception {
initText("<caret>\n" + "<caret>");
CopyPasteManager.getInstance().setContents(new StringSelection("abc\n"));
paste();
checkResultByText("abc<caret>\n" + "abc<caret>");
}
Aggregations