diff options
author | Michael Valenta | 2007-05-08 17:00:42 +0000 |
---|---|---|
committer | Michael Valenta | 2007-05-08 17:00:42 +0000 |
commit | eebe3650e5ac48ace1ed399282386b899f11ad1f (patch) | |
tree | cbf7ce713ed5e1a96720a36d018bf13f4df5abd3 /bundles/org.eclipse.team.cvs.ui | |
parent | 3e9009e8f5e5b5df9d45f4d1946184b06b35efc7 (diff) | |
download | eclipse.platform.team-eebe3650e5ac48ace1ed399282386b899f11ad1f.tar.gz eclipse.platform.team-eebe3650e5ac48ace1ed399282386b899f11ad1f.tar.xz eclipse.platform.team-eebe3650e5ac48ace1ed399282386b899f11ad1f.zip |
Bug 94808 [Change Sets] "&" not showing up in dropdown menu
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui')
-rw-r--r-- | bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java index 12476f3b8..f1f9383ce 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. + * Copyright (c) 2006-2007 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Matt McCutchen <hashproduct+eclipse@gmail.com> - Bug 94808 [Change Sets] "&" not showing up in dropdown menu *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.mappings; @@ -82,12 +83,36 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { } } + /** + * Escape a string so it can be used as an action text without '&' + * being interpreted as a mnemonic. Specifically, turn each '&' into '&&'. + */ + private static String escapeActionText(String x) { + // Loosely based on org.eclipse.jface.action.LegacyActionTools#removeMnemonics + int ampersandIndex = x.indexOf('&'); + if (ampersandIndex == -1) + return x; + + int len = x.length(); + StringBuffer sb = new StringBuffer(2 * len + 1); + int doneIndex = 0; + while (ampersandIndex != -1) { + sb.append(x.substring(doneIndex, ampersandIndex)); + sb.append("&&"); //$NON-NLS-1$ + doneIndex = ampersandIndex + 1; + ampersandIndex = x.indexOf('&', doneIndex); + } + if (doneIndex < len) + sb.append(x.substring(doneIndex, len)); + return sb.toString(); + } + private class AddToChangeSetAction extends ModelParticipantAction { private final ActiveChangeSet set; public AddToChangeSetAction(ISynchronizePageConfiguration configuration, ActiveChangeSet set, ISelection selection) { - super(set == null ? TeamUIMessages.ChangeSetActionGroup_2 : set.getTitle(), configuration); + super(set == null ? TeamUIMessages.ChangeSetActionGroup_2 : escapeActionText(set.getTitle()), configuration); this.set = set; selectionChanged(selection); } |