summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2011-12-02 04:56:29 (EST)
committer Steffen Pingel2011-12-02 04:56:29 (EST)
commit71d317f128271fa11827435e9a8096e9b9e5aa85 (patch)
tree35776058e27815a16c46e6d0f93ccb50e6939314
parent9b88e7cbfa520afb94a8ef957ef1e8644fb9bda1 (diff)
downloadorg.eclipse.mylyn.commons-71d317f128271fa11827435e9a8096e9b9e5aa85.zip
org.eclipse.mylyn.commons-71d317f128271fa11827435e9a8096e9b9e5aa85.tar.gz
org.eclipse.mylyn.commons-71d317f128271fa11827435e9a8096e9b9e5aa85.tar.bz2
NEW - bug 364892: replace invocations to CommonUiUtil.toLabel() with
LegacyActionTools.escapeMnemonics() https://bugs.eclipse.org/bugs/show_bug.cgi?id=364892 Change-Id: I3c7d0fc3daa5ee03a6a85bde883c2134b2924d43
-rw-r--r--org.eclipse.mylyn.commons.notifications/src/org/eclipse/mylyn/internal/commons/ui/notifications/popup/NotificationPopup.java6
-rw-r--r--org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/ui/CommonUiUtilTest.java18
-rw-r--r--org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonUiUtil.java6
3 files changed, 17 insertions, 13 deletions
diff --git a/org.eclipse.mylyn.commons.notifications/src/org/eclipse/mylyn/internal/commons/ui/notifications/popup/NotificationPopup.java b/org.eclipse.mylyn.commons.notifications/src/org/eclipse/mylyn/internal/commons/ui/notifications/popup/NotificationPopup.java
index b16d44b..3f2628f 100644
--- a/org.eclipse.mylyn.commons.notifications/src/org/eclipse/mylyn/internal/commons/ui/notifications/popup/NotificationPopup.java
+++ b/org.eclipse.mylyn.commons.notifications/src/org/eclipse/mylyn/internal/commons/ui/notifications/popup/NotificationPopup.java
@@ -14,12 +14,12 @@ package org.eclipse.mylyn.internal.commons.ui.notifications.popup;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jface.action.LegacyActionTools;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.mylyn.commons.ui.notifications.AbstractNotification;
import org.eclipse.mylyn.internal.commons.ui.CommonsUiPlugin;
import org.eclipse.mylyn.internal.provisional.commons.ui.AbstractNotificationPopup;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonColors;
-import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil;
import org.eclipse.mylyn.internal.provisional.commons.ui.ScalingHyperlink;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -88,7 +88,7 @@ public class NotificationPopup extends AbstractNotificationPopup {
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(itemLink);
itemLink.setForeground(CommonColors.HYPERLINK_WIDGET);
itemLink.registerMouseTrackListener();
- itemLink.setText(CommonUiUtil.toLabel(notification.getLabel()));
+ itemLink.setText(LegacyActionTools.escapeMnemonics(notification.getLabel()));
itemLink.setImage(notification.getNotificationImage());
itemLink.setBackground(parent.getBackground());
itemLink.addHyperlinkListener(new HyperlinkAdapter() {
@@ -116,7 +116,7 @@ public class NotificationPopup extends AbstractNotificationPopup {
}
if (descriptionText != null && !descriptionText.trim().equals("")) { //$NON-NLS-1$
Label descriptionLabel = new Label(notificationComposite, SWT.NO_FOCUS);
- descriptionLabel.setText(CommonUiUtil.toLabel(descriptionText));
+ descriptionLabel.setText(LegacyActionTools.escapeMnemonics(descriptionText));
descriptionLabel.setBackground(parent.getBackground());
GridDataFactory.fillDefaults()
.span(2, SWT.DEFAULT)
diff --git a/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/ui/CommonUiUtilTest.java b/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/ui/CommonUiUtilTest.java
index bd1de69..3b32f7a 100644
--- a/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/ui/CommonUiUtilTest.java
+++ b/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/ui/CommonUiUtilTest.java
@@ -12,7 +12,7 @@ package org.eclipse.mylyn.commons.tests.ui;
import junit.framework.TestCase;
-import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil;
+import org.eclipse.jface.action.LegacyActionTools;
/**
* @author Steffen Pingel
@@ -20,14 +20,14 @@ import org.eclipse.mylyn.internal.provisional.commons.ui.CommonUiUtil;
public class CommonUiUtilTest extends TestCase {
public void testToLabel() {
- assertNull(CommonUiUtil.toLabel(null));
- assertEquals("", CommonUiUtil.toLabel(""));
- assertEquals(" ", CommonUiUtil.toLabel(" "));
- assertEquals("abc def", CommonUiUtil.toLabel("abc def"));
- assertEquals("a&&b", CommonUiUtil.toLabel("a&b"));
- assertEquals("a&&b&&c", CommonUiUtil.toLabel("a&b&c"));
- assertEquals("&&", CommonUiUtil.toLabel("&"));
- assertEquals("&&&&", CommonUiUtil.toLabel("&&"));
+ assertNull(LegacyActionTools.escapeMnemonics(null));
+ assertEquals("", LegacyActionTools.escapeMnemonics(""));
+ assertEquals(" ", LegacyActionTools.escapeMnemonics(" "));
+ assertEquals("abc def", LegacyActionTools.escapeMnemonics("abc def"));
+ assertEquals("a&&b", LegacyActionTools.escapeMnemonics("a&b"));
+ assertEquals("a&&b&&c", LegacyActionTools.escapeMnemonics("a&b&c"));
+ assertEquals("&&", LegacyActionTools.escapeMnemonics("&"));
+ assertEquals("&&&&", LegacyActionTools.escapeMnemonics("&&"));
}
}
diff --git a/org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonUiUtil.java b/org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonUiUtil.java
index b1db670..f89e395 100644
--- a/org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonUiUtil.java
+++ b/org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonUiUtil.java
@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.jface.action.LegacyActionTools;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.operation.IRunnableContext;
@@ -227,7 +228,10 @@ public class CommonUiUtil {
/**
* Returns text masking the &-character from decoration as an accelerator in SWT labels.
+ *
+ * @deprecated use {@link LegacyActionTools#extractMnemonic(String)} instead
*/
+ @Deprecated
public static String toLabel(String text) {
return (text != null) ? text.replaceAll("&", "&&") : null; // mask & from SWT //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -244,7 +248,7 @@ public class CommonUiUtil {
if (label.contains("@")) { //$NON-NLS-1$
label += "\t"; //$NON-NLS-1$
}
- return CommonUiUtil.toLabel(label);
+ return LegacyActionTools.escapeMnemonics(label);
}
public static String getProductName() {