Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schreiber2017-03-28 09:53:15 -0400
committerMartin Schreiber2018-01-04 00:16:20 -0500
commit5d8385eab6b9e5786a860957d68e5b40258dc494 (patch)
tree96f30cfd0a89355ad04ee43ac296b2ac9ddd33ba
parent9918ee7e4b95e09fded8c210ad3d5e0f046f1045 (diff)
downloadeclipse.platform.debug-5d8385eab6b9e5786a860957d68e5b40258dc494.tar.gz
eclipse.platform.debug-5d8385eab6b9e5786a860957d68e5b40258dc494.tar.xz
eclipse.platform.debug-5d8385eab6b9e5786a860957d68e5b40258dc494.zip
Bug 514319 - Using a dedicated trim method to trim the expressions labels
When selected expressions get copied into the clipboards text transfer, first cut off the leading and tailing quotes. This is done by extending the VirtualCopyToClipboardActionDelegate with a method called trimLabel. Clients (in that case a own action delegate for expressions) could do additional trimming to the label provided by the label provider. Change-Id: I71a5c205f7eb2a8db5d112eec2d3a28dbb237f1e Signed-off-by: Martin Schreiber <m.schreiber@bachmann.info>
-rw-r--r--org.eclipse.debug.ui/plugin.xml2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/CopyExpressionsToClipboardActionDelegate.java35
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualCopyToClipboardActionDelegate.java19
3 files changed, 53 insertions, 3 deletions
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index d5bf76fd1..b301161db 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -1582,7 +1582,7 @@
icon="$nl$/icons/full/elcl16/copy_edit_co.png"
definitionId="org.eclipse.ui.edit.copy"
helpContextId="copy_variables_to_clipboard_action_context"
- class="org.eclipse.debug.internal.ui.viewers.model.VirtualCopyToClipboardActionDelegate"
+ class="org.eclipse.debug.internal.ui.actions.expressions.CopyExpressionsToClipboardActionDelegate"
menubarPath="expressionGroup"
id="org.eclipse.debug.ui.debugview.popupMenu.copyVariablesToClipboard">
<selection
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/CopyExpressionsToClipboardActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/CopyExpressionsToClipboardActionDelegate.java
new file mode 100644
index 000000000..e5621fe36
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/CopyExpressionsToClipboardActionDelegate.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Bachmann electronic GmbH 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bachmann electronic GmbH - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.actions.expressions;
+
+import org.eclipse.debug.internal.ui.viewers.model.VirtualCopyToClipboardActionDelegate;
+
+public class CopyExpressionsToClipboardActionDelegate extends VirtualCopyToClipboardActionDelegate {
+
+ private static final String QUOTE = "\""; //$NON-NLS-1$
+
+ @Override
+ protected String trimLabel(String rawLabel) {
+ String label = super.trimLabel(rawLabel);
+ if (label == null) {
+ return null;
+ }
+ if (label.startsWith(QUOTE)) {
+ label = label.substring(1);
+ }
+ if (label.endsWith(QUOTE)) {
+ label = label.substring(0, label.length() - 1);
+ }
+ return label;
+ }
+
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualCopyToClipboardActionDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualCopyToClipboardActionDelegate.java
index be623e7d4..688ac3f63 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualCopyToClipboardActionDelegate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualCopyToClipboardActionDelegate.java
@@ -144,8 +144,8 @@ public class VirtualCopyToClipboardActionDelegate extends AbstractDebugActionDel
String[] labels = (String[]) item.getData(VirtualItem.LABEL_KEY);
if(labels != null && labels.length > 0) {
for (int i = 0; i < labels.length; i++) {
- String text = labels[i];
- if(text != null && !text.trim().equals(IInternalDebugCoreConstants.EMPTY_STRING)) {
+ String text = trimLabel(labels[i]);
+ if (text != null && !text.equals(IInternalDebugCoreConstants.EMPTY_STRING)) {
buffer.append(text+TAB);
}
}
@@ -153,6 +153,21 @@ public class VirtualCopyToClipboardActionDelegate extends AbstractDebugActionDel
}
}
+ /**
+ * Trims the given String. Subclasses might want to cut off additional
+ * things from the given label retrieved by the label provider by overriding
+ * this method.
+ *
+ * @param label the label that should be trimmed (might be null)
+ * @return the trimmed label or null if label is null
+ */
+ protected String trimLabel(String label) {
+ if (label == null) {
+ return null;
+ }
+ return label.trim();
+ }
+
private class ItemsToCopyVirtualItemValidator implements IVirtualItemValidator {
Set<VirtualItem> fItemsToCopy = Collections.EMPTY_SET;

Back to the top