Skip to content

Commit 1b36f10

Browse files
georgemac-labsbuchen
authored andcommitted
Fix: unescaped tooltip labels
Wrap labels with TextUtil.tooltip() to escape ampersand characters for proper display in SWT/Eclipse menu items and tooltips.
1 parent feab3b8 commit 1b36f10

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/util/BookmarkMenu.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import name.abuchen.portfolio.ui.Messages;
1414
import name.abuchen.portfolio.ui.editor.PortfolioPart;
1515
import name.abuchen.portfolio.ui.views.settings.SettingsView;
16+
import name.abuchen.portfolio.util.TextUtil;
1617

1718
public class BookmarkMenu extends MenuManager
1819
{
@@ -46,7 +47,7 @@ private void addDefaultPages()
4647
}
4748
else
4849
{
49-
add(new SimpleAction(bookmark.getLabel(), a -> securities.stream().limit(10)
50+
add(new SimpleAction(TextUtil.tooltip(bookmark.getLabel()), a -> securities.stream().limit(10)
5051
.forEach(s -> DesktopAPI.browse(bookmark.constructURL(client, s)))));
5152
}
5253
}
@@ -57,7 +58,7 @@ private void addDefaultPages()
5758
{
5859
add(new Separator());
5960
securities.forEach(s -> s.getCustomBookmarks().forEach(
60-
bm -> add(new SimpleAction(bm.getLabel(), a -> DesktopAPI.browse(bm.getPattern())))));
61+
bm -> add(new SimpleAction(TextUtil.tooltip(bm.getLabel()), a -> DesktopAPI.browse(bm.getPattern())))));
6162
}
6263

6364
add(new Separator());
@@ -67,7 +68,7 @@ private void addDefaultPages()
6768

6869
List<Bookmark> templates = ClientSettings.getDefaultBookmarks();
6970
Collections.sort(templates, (r, l) -> r.getLabel().compareTo(l.getLabel()));
70-
templates.forEach(bookmark -> templatesMenu.add(new SimpleAction(bookmark.getLabel(),
71+
templates.forEach(bookmark -> templatesMenu.add(new SimpleAction(TextUtil.tooltip(bookmark.getLabel()),
7172
a -> securities.stream().limit(10)
7273
.forEach(s -> DesktopAPI.browse(bookmark.constructURL(client, s))))));
7374

name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/util/ClientFilterMenu.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import name.abuchen.portfolio.ui.Messages;
3838
import name.abuchen.portfolio.ui.dialogs.EditClientFilterDialog;
3939
import name.abuchen.portfolio.ui.dialogs.ListSelectionDialog;
40+
import name.abuchen.portfolio.util.TextUtil;
4041

4142
public final class ClientFilterMenu implements IMenuListener
4243
{
@@ -148,7 +149,7 @@ private void loadCustomItems()
148149
public void menuAboutToShow(IMenuManager manager)
149150
{
150151
defaultItems.forEach(item -> {
151-
Action action = new SimpleAction(item.label, a -> {
152+
Action action = new SimpleAction(TextUtil.tooltip(item.label), a -> {
152153
selectedItem = item;
153154
listeners.forEach(l -> l.accept(item.filter));
154155
});
@@ -158,7 +159,7 @@ public void menuAboutToShow(IMenuManager manager)
158159

159160
manager.add(new Separator());
160161
customItems.forEach(item -> {
161-
Action action = new SimpleAction(item.label, a -> {
162+
Action action = new SimpleAction(TextUtil.tooltip(item.label), a -> {
162163
selectedItem = item;
163164
listeners.forEach(l -> l.accept(item.filter));
164165
});

name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/util/viewers/ShowHideColumnHelper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,25 +613,25 @@ public void menuAboutToShow(final IMenuManager manager) // NOSONAR
613613
if (column.getGroupLabel() != null)
614614
{
615615
managerToAdd = groups.computeIfAbsent(column.getGroupLabel(), l -> {
616-
MenuManager m = new MenuManager(l);
616+
MenuManager m = new MenuManager(TextUtil.tooltip(l));
617617
manager.add(m);
618618
return m;
619619
});
620620
if (column.hasHeading())
621-
managerToAdd.add(new LabelOnly(column.getHeading()));
621+
managerToAdd.add(new LabelOnly(TextUtil.tooltip(column.getHeading())));
622622
}
623623

624624
if (column.hasOptions())
625625
{
626626
List<Object> options = visible.getOrDefault(column, Collections.emptyList());
627627

628-
MenuManager subMenu = new MenuManager(column.getMenuLabel());
628+
MenuManager subMenu = new MenuManager(TextUtil.tooltip(column.getMenuLabel()));
629629

630630
for (Object option : column.getOptions().getOptions())
631631
{
632632
boolean isVisible = options.contains(option);
633633
String label = column.getOptions().getMenuLabel(option);
634-
addShowHideAction(subMenu, column, label, isVisible, option);
634+
addShowHideAction(subMenu, column, TextUtil.tooltip(label), isVisible, option);
635635

636636
if (isVisible)
637637
options.remove(option);
@@ -640,7 +640,7 @@ public void menuAboutToShow(final IMenuManager manager) // NOSONAR
640640
for (Object option : options)
641641
{
642642
String label = column.getOptions().getMenuLabel(option);
643-
addShowHideAction(subMenu, column, label, true, option);
643+
addShowHideAction(subMenu, column, TextUtil.tooltip(label), true, option);
644644
}
645645

646646
if (column.getOptions().canCreateNewOptions())
@@ -650,7 +650,7 @@ public void menuAboutToShow(final IMenuManager manager) // NOSONAR
650650
}
651651
else
652652
{
653-
addShowHideAction(managerToAdd, column, column.getMenuLabel(), visible.containsKey(column), null);
653+
addShowHideAction(managerToAdd, column, TextUtil.tooltip(column.getMenuLabel()), visible.containsKey(column), null);
654654
}
655655
}
656656

name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/dashboard/TaxonomyConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import name.abuchen.portfolio.ui.Messages;
99
import name.abuchen.portfolio.ui.util.LabelOnly;
1010
import name.abuchen.portfolio.ui.util.SimpleAction;
11+
import name.abuchen.portfolio.util.TextUtil;
1112

1213
public class TaxonomyConfig implements WidgetConfig
1314
{
@@ -32,12 +33,12 @@ public TaxonomyConfig(WidgetDelegate<?> delegate)
3233
public void menuAboutToShow(IMenuManager manager)
3334
{
3435
manager.appendToGroup(DashboardView.INFO_MENU_GROUP_NAME,
35-
new LabelOnly(taxonomy != null ? taxonomy.getName() : Messages.LabelNoName));
36+
new LabelOnly(TextUtil.tooltip(taxonomy != null ? taxonomy.getName() : Messages.LabelNoName)));
3637

3738
MenuManager subMenu = new MenuManager(Messages.LabelTaxonomies);
3839

3940
delegate.getClient().getTaxonomies().forEach(t -> {
40-
SimpleAction action = new SimpleAction(t.getName(), a -> {
41+
SimpleAction action = new SimpleAction(TextUtil.tooltip(t.getName()), a -> {
4142
taxonomy = t;
4243
delegate.getWidget().getConfiguration().put(Dashboard.Config.TAXONOMY.name(), t.getId());
4344

0 commit comments

Comments
 (0)