diff options
author | Ken Ryall | 2010-09-21 18:38:43 +0000 |
---|---|---|
committer | Ken Ryall | 2010-09-21 18:38:43 +0000 |
commit | a0b5fe2c89208472779f8eadbc07652c2913be28 (patch) | |
tree | 59705013b0ea4b605c1714625213c1a28177d37c /debug/org.eclipse.cdt.debug.ui/src/org | |
parent | 45f057367af53ef2dc3f325ac03fc5df08c6e73c (diff) | |
download | org.eclipse.cdt-a0b5fe2c89208472779f8eadbc07652c2913be28.tar.gz org.eclipse.cdt-a0b5fe2c89208472779f8eadbc07652c2913be28.tar.xz org.eclipse.cdt-a0b5fe2c89208472779f8eadbc07652c2913be28.zip |
Bug 325773 - Support copy in the Executables View. Fix up line endings.
Diffstat (limited to 'debug/org.eclipse.cdt.debug.ui/src/org')
-rw-r--r-- | debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewCopyHandler.java | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewCopyHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewCopyHandler.java index d53443aca30..baa2199f98f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewCopyHandler.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewCopyHandler.java @@ -10,6 +10,9 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.views.executables; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; import java.util.Iterator; import org.eclipse.cdt.core.model.ITranslationUnit; @@ -50,22 +53,30 @@ public class ExecutablesViewCopyHandler extends AbstractHandler { } if (selection instanceof IStructuredSelection) { - StringBuilder sb = new StringBuilder(); - Iterator<?> iter = ((IStructuredSelection) selection).iterator(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(baos); + + Iterator<?> iter = ((IStructuredSelection) selection).iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj instanceof Executable) { Executable exe = (Executable) obj; - sb.append(exe.getName()).append("\n"); //$NON-NLS-1$ + ps.println(exe.getName()); } else if (obj instanceof ITranslationUnit) { ITranslationUnit tu = (ITranslationUnit) obj; - sb.append(tu.getLocation().toFile().getName()).append("\n"); //$NON-NLS-1$ + ps.println(tu.getLocation().toFile().getName()); } else - sb.append(obj.toString()).append("\n"); //$NON-NLS-1$ + ps.println(obj.toString()); } + ps.flush(); + try { + baos.flush(); + } catch (IOException e) { + throw new ExecutionException("", e); //$NON-NLS-1$ + } Clipboard cp = getClipboard(); - cp.setContents(new Object[] { sb.toString().trim() }, + cp.setContents(new Object[] { baos.toString().trim() }, new Transfer[] { TextTransfer.getInstance() }); } |