From a0b5fe2c89208472779f8eadbc07652c2913be28 Mon Sep 17 00:00:00 2001 From: Ken Ryall Date: Tue, 21 Sep 2010 18:38:43 +0000 Subject: [PATCH] Bug 325773 - Support copy in the Executables View. Fix up line endings. --- .../ExecutablesViewCopyHandler.java | 23 ++++++++++++++----- 1 file 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() }); }