Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2014-02-26 16:37:55 +0000
committerDani Megert2014-02-26 16:37:55 +0000
commit9636aeed9ef5cb681a2f22db8ff2177a45414671 (patch)
tree445e132bbb4a378e7892ff8940e1aebfd34b544d
parentb58659079d4ca44704291d0480d0a855c087d02d (diff)
downloadeclipse.platform.text-9636aeed9ef5cb681a2f22db8ff2177a45414671.tar.gz
eclipse.platform.text-9636aeed9ef5cb681a2f22db8ff2177a45414671.tar.xz
eclipse.platform.text-9636aeed9ef5cb681a2f22db8ff2177a45414671.zip
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java
index 761278d67..f92bce387 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -30,6 +30,8 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -38,8 +40,10 @@ import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
+
public class CopyToClipboardAction extends Action {
+
private StructuredViewer fViewer;
public CopyToClipboardAction(StructuredViewer viewer) {
@@ -100,7 +104,7 @@ public class CopyToClipboardAction extends Action {
if (shell == null || fViewer == null)
return;
- ILabelProvider labelProvider= (ILabelProvider)fViewer.getLabelProvider();
+ IBaseLabelProvider labelProvider= fViewer.getLabelProvider();
String lineDelim= System.getProperty("line.separator"); //$NON-NLS-1$
StringBuffer buf= new StringBuffer();
Iterator iter= getSelection();
@@ -108,7 +112,7 @@ public class CopyToClipboardAction extends Action {
if (buf.length() > 0) {
buf.append(lineDelim);
}
- buf.append(labelProvider.getText(iter.next()));
+ buf.append(getText(labelProvider, iter.next()));
}
if (buf.length() > 0) {
@@ -116,6 +120,15 @@ public class CopyToClipboardAction extends Action {
}
}
+ private static String getText(IBaseLabelProvider labelProvider, Object object) {
+ if (labelProvider instanceof ILabelProvider)
+ return ((ILabelProvider)labelProvider).getText(object);
+ else if (labelProvider instanceof DelegatingStyledCellLabelProvider)
+ return ((DelegatingStyledCellLabelProvider)labelProvider).getStyledStringProvider().getStyledText(object).toString();
+ else
+ return object.toString();
+ }
+
private void copyToClipboard(String text, Shell shell) {
text= TextProcessor.deprocess(text);
Clipboard clipboard= new Clipboard(shell.getDisplay());

Back to the top