use of java.awt.datatransfer.StringSelection in project intellij-plugins by JetBrains.
the class DartServerHighlightingTest method testServerDataUpdateOnPaste.
public void testServerDataUpdateOnPaste() {
initServerDataTest();
final DartAnalysisServerService service = DartAnalysisServerService.getInstance(getProject());
final VirtualFile file = getFile().getVirtualFile();
checkServerDataInitialState(file);
CopyPasteManager.getInstance().setContents(new StringSelection("long text 012345678901234567890123456789"));
// paste a lot at the beginning of the region
getEditor().getCaretModel().moveToOffset(27);
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PASTE);
checkRegions(service.getNavigation(file), TextRange.create(7, 18), TextRange.create(67, 78), TextRange.create(87, 98));
checkRegions(service.getHighlight(file), TextRange.create(0, 19), TextRange.create(0, 6), TextRange.create(7, 18), TextRange.create(20, 79), TextRange.create(20, 26), TextRange.create(67, 78), TextRange.create(80, 99), TextRange.create(80, 86), TextRange.create(87, 98));
undoAndUpdateHighlighting(file);
// paste a lot in the middle of the region
getEditor().getCaretModel().moveToOffset(29);
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PASTE);
checkRegions(service.getNavigation(file), TextRange.create(7, 18), /*TextRange.create(28, 39),*/
TextRange.create(87, 98));
checkRegions(service.getHighlight(file), TextRange.create(0, 19), TextRange.create(0, 6), TextRange.create(7, 18), TextRange.create(20, 79), TextRange.create(20, 26), TextRange.create(27, 78), TextRange.create(80, 99), TextRange.create(80, 86), TextRange.create(87, 98));
undoAndUpdateHighlighting(file);
// paste a lot at the end of the region
getEditor().getCaretModel().moveToOffset(38);
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PASTE);
checkRegions(service.getNavigation(file), TextRange.create(7, 18), TextRange.create(27, 38), TextRange.create(87, 98));
checkRegions(service.getHighlight(file), TextRange.create(0, 19), TextRange.create(0, 6), TextRange.create(7, 18), TextRange.create(20, 79), TextRange.create(20, 26), TextRange.create(27, 38), TextRange.create(80, 99), TextRange.create(80, 86), TextRange.create(87, 98));
}
use of java.awt.datatransfer.StringSelection in project android by JetBrains.
the class TranslationsEditorTest method translationTextFieldFontCanDisplayPastedHebrew.
@Test
public void translationTextFieldFontCanDisplayPastedHebrew() {
myTranslationsEditor.getTable().selectCell(TableCell.row(1).column(5));
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection("יישום פשוט"), EmptyClipboardOwner.INSTANCE);
JTextComponentFixture translationTextField = myTranslationsEditor.getTranslationTextField();
KeyStroke keyStroke = getKeyStroke(translationTextField.target().getInputMap(), DefaultEditorKit.pasteAction);
translationTextField.pressAndReleaseKey(KeyPressInfo.keyCode(keyStroke.getKeyCode()).modifiers(keyStroke.getModifiers()));
assertEquals(-1, translationTextField.font().target().canDisplayUpTo("יישום פשוט"));
}
use of java.awt.datatransfer.StringSelection in project android by JetBrains.
the class RenderErrorContributor method reportThrowable.
/**
* Display the problem list encountered during a render.
*
* @return if the throwable was hidden.
*/
private boolean reportThrowable(@NotNull HtmlBuilder builder, @NotNull final Throwable throwable, boolean hideIfIrrelevant) {
StackTraceElement[] frames = throwable.getStackTrace();
int end = -1;
boolean haveInterestingFrame = false;
for (int i = 0; i < frames.length; i++) {
StackTraceElement frame = frames[i];
if (isInterestingFrame(frame)) {
haveInterestingFrame = true;
}
String className = frame.getClassName();
if (className.equals(RENDER_SESSION_IMPL_FQCN)) {
end = i;
break;
}
}
if (end == -1 || !haveInterestingFrame) {
// Not a recognized stack trace range: just skip it
if (hideIfIrrelevant) {
if (RenderLogger.isLoggingAllErrors()) {
ShowExceptionFix detailsFix = new ShowExceptionFix(myResult.getModule().getProject(), throwable);
builder.addLink("Show Exception", myLinkManager.createRunnableLink(detailsFix));
}
return true;
} else {
// List just the top frames
for (int i = 0; i < frames.length; i++) {
StackTraceElement frame = frames[i];
if (!isVisible(frame)) {
end = i;
if (end == 0) {
// Find end instead
for (int j = 0; j < frames.length; j++) {
frame = frames[j];
String className = frame.getClassName();
if (className.equals(RENDER_SESSION_IMPL_FQCN)) {
end = j;
break;
}
}
}
break;
}
}
}
}
builder.addHtml(StringUtil.replace(throwable.toString(), "\n", "<BR/>")).newline();
boolean wasHidden = false;
int indent = 2;
File platformSource = null;
boolean platformSourceExists = true;
for (int i = 0; i < end; i++) {
StackTraceElement frame = frames[i];
if (isHiddenFrame(frame)) {
wasHidden = true;
continue;
}
String className = frame.getClassName();
String methodName = frame.getMethodName();
builder.addNbsps(indent);
builder.add("at ").add(className).add(".").add(methodName);
String fileName = frame.getFileName();
if (fileName != null && !fileName.isEmpty()) {
int lineNumber = frame.getLineNumber();
String location = fileName + ':' + lineNumber;
if (isInterestingFrame(frame)) {
if (wasHidden) {
builder.addNbsps(indent).add(" ...").newline();
wasHidden = false;
}
String url = myLinkManager.createOpenStackUrl(className, methodName, fileName, lineNumber);
builder.add("(").addLink(location, url).add(")");
} else {
// Try to link to local documentation
String url = null;
if (isFramework(frame) && platformSourceExists) {
// try to link to documentation, if available
if (platformSource == null) {
IAndroidTarget target = myResult.getRenderTask() != null ? myResult.getRenderTask().getConfiguration().getRealTarget() : null;
platformSource = target != null ? AndroidSdks.getInstance().findPlatformSources(target) : null;
platformSourceExists = platformSource != null;
}
if (platformSourceExists) {
File classFile = new File(platformSource, frame.getClassName().replace('.', File.separatorChar) + DOT_JAVA);
if (!classFile.exists()) {
// Probably an innerclass like foo.bar.Outer.Inner; the above would look for foo/bar/Outer/Inner.java; try
// again at foo/bar/
File parentFile = classFile.getParentFile();
classFile = new File(parentFile.getParentFile(), parentFile.getName() + DOT_JAVA);
if (!classFile.exists()) {
// in theory we should keep trying this repeatedly for more deeply nested inner classes
classFile = null;
}
}
if (classFile != null) {
url = HtmlLinkManager.createFilePositionUrl(classFile, lineNumber, 0);
}
}
}
if (url != null) {
builder.add("(").addLink(location, url).add(")");
} else {
builder.add("(").add(location).add(")");
}
}
builder.newline();
}
}
builder.addLink("Copy stack to clipboard", myLinkManager.createRunnableLink(() -> {
String text = Throwables.getStackTraceAsString(throwable);
try {
CopyPasteManager.getInstance().setContents(new StringSelection(text));
RenderErrorPanel.showNotification("Stack trace copied to clipboard");
} catch (Exception ignore) {
}
}));
return false;
}
use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.
the class PsiCopyPasteManager method clear.
public void clear() {
myRecentData = null;
myCopyPasteManager.setContents(new StringSelection(""));
}
use of java.awt.datatransfer.StringSelection in project intellij-community by JetBrains.
the class PsiViewerDialog method createActions.
@NotNull
@Override
protected Action[] createActions() {
AbstractAction copyPsi = new AbstractAction("Cop&y PSI") {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
PsiElement element = parseText(myEditor.getDocument().getText());
List<PsiElement> allToParse = new ArrayList<>();
if (element instanceof PsiFile) {
allToParse.addAll(((PsiFile) element).getViewProvider().getAllFiles());
} else if (element != null) {
allToParse.add(element);
}
String data = "";
for (PsiElement psiElement : allToParse) {
data += DebugUtil.psiToString(psiElement, !myShowWhiteSpacesBox.isSelected(), true);
}
CopyPasteManager.getInstance().setContents(new StringSelection(data));
}
};
return ArrayUtil.mergeArrays(new Action[] { copyPsi }, super.createActions());
}
Aggregations