use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.
the class EditorActionTest method testPasteInOneLineMode.
public void testPasteInOneLineMode() throws Exception {
init("", TestFileType.TEXT);
((EditorEx) myEditor).setOneLineMode(true);
CopyPasteManager.getInstance().setContents(new StringSelection("a\rb"));
executeAction(IdeActions.ACTION_EDITOR_PASTE);
checkResultByText("a b<caret>");
}
use of java.awt.datatransfer.StringSelection in project otertool by wuntee.
the class GuiWorkshop method setClipboardContents.
public static void setClipboardContents(String s) {
StringSelection stringSelection = new StringSelection(s);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, new ClipboardOwner() {
public void lostOwnership(Clipboard arg0, Transferable arg1) {
}
});
}
use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.
the class CopyLineStatusRangeAction method actionPerformed.
public void actionPerformed(final AnActionEvent e) {
final String content = myLineStatusTracker.getVcsContent(myRange) + "\n";
CopyPasteManager.getInstance().setContents(new StringSelection(content));
}
use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.
the class EnvVariablesTable method createExtraActions.
@NotNull
@Override
protected AnActionButton[] createExtraActions() {
AnActionButton copyButton = new AnActionButton(ActionsBundle.message("action.EditorCopy.text"), AllIcons.Actions.Copy) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
stopEditing();
StringBuilder sb = new StringBuilder();
List<EnvironmentVariable> variables = getSelection();
for (EnvironmentVariable environmentVariable : variables) {
if (environmentVariable.getIsPredefined() || isEmpty(environmentVariable))
continue;
if (sb.length() > 0)
sb.append('\n');
sb.append(StringUtil.escapeChar(environmentVariable.getName(), '=')).append('=').append(StringUtil.escapeChar(environmentVariable.getValue(), '='));
}
CopyPasteManager.getInstance().setContents(new StringSelection(sb.toString()));
}
@Override
public boolean isEnabled() {
return super.isEnabled() && !getSelection().isEmpty();
}
};
AnActionButton pasteButton = new AnActionButton(ActionsBundle.message("action.EditorPaste.text"), AllIcons.Actions.Menu_paste) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
removeSelected();
stopEditing();
String content = CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
if (content == null || !content.contains("="))
return;
List<EnvironmentVariable> parsed = new ArrayList<>();
List<String> lines = StringUtil.split(content, "\n");
for (String line : lines) {
int pos = line.indexOf('=');
if (pos == -1)
continue;
while (pos > 0 && line.charAt(pos - 1) == '\\') {
pos = line.indexOf('=', pos + 1);
}
line = line.replaceAll("[\\\\]{1}", "\\\\\\\\");
parsed.add(new EnvironmentVariable(StringUtil.unescapeStringCharacters(line.substring(0, pos)), StringUtil.unescapeStringCharacters(line.substring(pos + 1)), false));
}
List<EnvironmentVariable> variables = new ArrayList<>(getEnvironmentVariables());
variables.addAll(parsed);
setValues(variables);
}
};
return new AnActionButton[] { copyButton, pasteButton };
}
use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.
the class CopyQuickDocAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
String selected = e.getData(DocumentationManager.SELECTED_QUICK_DOC_TEXT);
if (selected == null || selected.isEmpty()) {
return;
}
CopyPasteManager.getInstance().setContents(new StringSelection(selected));
}
Aggregations