Skip to content

Commit 15a1062

Browse files
committed
#4806 Add filter/group/sort indicators to hidden field menu items
1 parent a210d41 commit 15a1062

File tree

16 files changed

+191
-87
lines changed

16 files changed

+191
-87
lines changed

stroom-core-client-widget/src/main/java/stroom/cell/info/client/HoverActionMenuCell.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,14 @@ public void render(final Context context, final T value, final SafeHtmlBuilder s
162162
if (menuItems.size() == 1
163163
&& menuItems.get(0) instanceof MenuItem
164164
&& ((MenuItem) menuItems.get(0)).getCommand() != null) {
165+
final MenuItem menuItem = ((MenuItem) menuItems.get(0));
166+
165167
// Single item with a command so no menu popup needed
166-
final String menuItemText = ((MenuItem) menuItems.get(0)).getText();
167-
sb.append(template.divWithToolTip(menuItemText, icon));
168+
final SafeHtml tooltip = GwtNullSafe.getOrElse(menuItem, MenuItem::getTooltip, menuItem.getText());
169+
sb.append(template.divWithTitle(tooltip.asString(), icon));
168170
} else {
169171
// Build the menu popup
170-
sb.append(template.divWithToolTip("Actions...", icon));
172+
sb.append(template.divWithTitle("Actions...", icon));
171173
}
172174

173175
sb.appendHtmlConstant("</div>");
@@ -192,6 +194,6 @@ interface Template extends SafeHtmlTemplates {
192194
SafeHtml div(String className, SafeHtml content);
193195

194196
@Template("<div title=\"{0}\">{1}</div>")
195-
SafeHtml divWithToolTip(String title, SafeHtml content);
197+
SafeHtml divWithTitle(String title, SafeHtml content);
196198
}
197199
}

stroom-core-client-widget/src/main/java/stroom/widget/menu/client/presenter/IconMenuItem.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import stroom.util.shared.GwtNullSafe;
2323
import stroom.widget.util.client.KeyBinding.Action;
2424

25+
import com.google.gwt.safehtml.shared.SafeHtml;
2526
import com.google.gwt.user.client.Command;
2627

2728
public class IconMenuItem extends MenuItem {
@@ -35,12 +36,13 @@ protected IconMenuItem(final int priority,
3536
final SvgImage enabledIcon,
3637
final SvgImage disabledIcon,
3738
final IconColour iconColour,
38-
final String text,
39+
final SafeHtml text,
40+
final SafeHtml tooltip,
3941
final Action action,
4042
final boolean enabled,
4143
final Command command,
4244
final boolean highlight) {
43-
super(priority, text, action, enabled, command);
45+
super(priority, text, tooltip, action, enabled, command);
4446
this.enabledIcon = enabledIcon;
4547
this.disabledIcon = disabledIcon;
4648
this.iconColour = iconColour;
@@ -124,6 +126,7 @@ public IconMenuItem build() {
124126
disabledIcon,
125127
iconColour,
126128
text,
129+
tooltip,
127130
action,
128131
enabled,
129132
command,

stroom-core-client-widget/src/main/java/stroom/widget/menu/client/presenter/IconParentMenuItem.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import stroom.widget.util.client.FutureImpl;
2323
import stroom.widget.util.client.KeyBinding.Action;
2424

25+
import com.google.gwt.safehtml.shared.SafeHtml;
26+
2527
import java.util.List;
2628

2729
public class IconParentMenuItem extends IconMenuItem implements HasChildren {
@@ -32,12 +34,22 @@ protected IconParentMenuItem(final int priority,
3234
final SvgImage enabledIcon,
3335
final SvgImage disabledIcon,
3436
final IconColour iconColour,
35-
final String text,
37+
final SafeHtml text,
38+
final SafeHtml tooltip,
3639
final Action action,
3740
final boolean enabled,
3841
final boolean highlight,
3942
final Future<List<Item>> children) {
40-
super(priority, enabledIcon, disabledIcon, iconColour, text, action, enabled, null, highlight);
43+
super(priority,
44+
enabledIcon,
45+
disabledIcon,
46+
iconColour,
47+
text,
48+
tooltip,
49+
action,
50+
enabled,
51+
null,
52+
highlight);
4153
this.children = children;
4254
}
4355

@@ -77,6 +89,7 @@ public IconParentMenuItem build() {
7789
disabledIcon,
7890
iconColour,
7991
text,
92+
tooltip,
8093
action,
8194
enabled,
8295
highlight,

stroom-core-client-widget/src/main/java/stroom/widget/menu/client/presenter/InfoMenuItem.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import stroom.widget.util.client.KeyBinding.Action;
44

55
import com.google.gwt.safehtml.shared.SafeHtml;
6+
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
67
import com.google.gwt.user.client.Command;
78

89
public class InfoMenuItem extends MenuItem {
@@ -13,7 +14,7 @@ public InfoMenuItem(final SafeHtml safeHtml,
1314
final Action action,
1415
final Boolean enabled,
1516
final Command command) {
16-
super(0, "", action, enabled, command);
17+
super(0, SafeHtmlUtils.EMPTY_SAFE_HTML, SafeHtmlUtils.EMPTY_SAFE_HTML, action, enabled, command);
1718
this.safeHtml = safeHtml;
1819
}
1920

stroom-core-client-widget/src/main/java/stroom/widget/menu/client/presenter/KeyedParentMenuItem.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import stroom.widget.util.client.FutureImpl;
2323
import stroom.widget.util.client.KeyBinding.Action;
2424

25+
import com.google.gwt.safehtml.shared.SafeHtml;
26+
2527
import java.util.List;
2628
import java.util.Objects;
2729

@@ -34,12 +36,22 @@ public class KeyedParentMenuItem extends IconMenuItem implements HasChildren {
3436
final SvgImage enabledIcon,
3537
final SvgImage disabledIcon,
3638
final IconColour iconColour,
37-
final String text,
39+
final SafeHtml text,
40+
final SafeHtml tooltip,
3841
final Action action,
3942
final boolean enabled,
4043
final MenuItems menuItems,
4144
final MenuKey menuKey) {
42-
super(priority, enabledIcon, disabledIcon, iconColour, text, action, enabled, null, false);
45+
super(priority,
46+
enabledIcon,
47+
disabledIcon,
48+
iconColour,
49+
text,
50+
tooltip,
51+
action,
52+
enabled,
53+
null,
54+
false);
4355
this.menuItems = menuItems;
4456
this.menuKey = menuKey;
4557
}
@@ -98,6 +110,7 @@ public KeyedParentMenuItem build() {
98110
disabledIcon,
99111
iconColour,
100112
text,
113+
tooltip,
101114
action,
102115
enabled,
103116
menuItems,

stroom-core-client-widget/src/main/java/stroom/widget/menu/client/presenter/MenuItem.java

+25-5
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,41 @@
1717
package stroom.widget.menu.client.presenter;
1818

1919
import stroom.widget.util.client.KeyBinding.Action;
20+
import stroom.widget.util.client.SafeHtmlUtil;
2021

22+
import com.google.gwt.safehtml.shared.SafeHtml;
2123
import com.google.gwt.user.client.Command;
2224

2325
public abstract class MenuItem extends Item {
2426

25-
private final String text;
27+
private final SafeHtml text;
28+
private final SafeHtml tooltip;
2629
private final Action action;
2730
private final Command command;
2831
private final boolean enabled;
2932

3033
protected MenuItem(final int priority,
31-
final String text,
34+
final SafeHtml text,
35+
final SafeHtml tooltip,
3236
final Action action,
3337
final boolean enabled,
3438
final Command command) {
3539
super(priority);
3640
this.text = text;
41+
this.tooltip = tooltip;
3742
this.action = action;
3843
this.enabled = enabled;
3944
this.command = command;
4045
}
4146

42-
public String getText() {
47+
public SafeHtml getText() {
4348
return text;
4449
}
4550

51+
public SafeHtml getTooltip() {
52+
return tooltip;
53+
}
54+
4655
public Action getAction() {
4756
return action;
4857
}
@@ -62,16 +71,27 @@ public Command getCommand() {
6271
protected abstract static class AbstractBuilder<T extends MenuItem, B extends MenuItem.AbstractBuilder<T, ?>>
6372
extends Item.AbstractBuilder<T, B> {
6473

65-
protected String text;
74+
protected SafeHtml text;
75+
protected SafeHtml tooltip;
6676
protected Action action;
6777
protected Command command;
6878
protected boolean enabled = true;
6979

70-
public B text(final String text) {
80+
public B text(final SafeHtml text) {
7181
this.text = text;
7282
return self();
7383
}
7484

85+
public B text(final String text) {
86+
this.text = SafeHtmlUtil.from(text);
87+
return self();
88+
}
89+
90+
public B tooltip(final String tooltip) {
91+
this.tooltip = SafeHtmlUtil.from(tooltip);
92+
return self();
93+
}
94+
7595
public B action(final Action action) {
7696
this.action = action;
7797
return self();

stroom-core-client-widget/src/main/java/stroom/widget/menu/client/presenter/MenuItemCell.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static class MenuItemAppearance implements Appearance<MenuItem> {
125125
public void render(final MenuItemCell cell, final Context context, final MenuItem value,
126126
final SafeHtmlBuilder sb) {
127127
if (value.getText() != null) {
128-
sb.append(SafeHtmlUtils.fromTrustedString(value.getText()));
128+
sb.append(value.getText());
129129
}
130130
}
131131
}
@@ -172,7 +172,7 @@ public void render(final MenuItemCell cell,
172172

173173

174174
inner.append(
175-
TEMPLATE.inner("menuItem-text", SafeHtmlUtils.fromTrustedString(value.getText())));
175+
TEMPLATE.inner("menuItem-text", value.getText()));
176176

177177
if (value.getAction() != null) {
178178
final String shortcut = KeyBinding.getShortcut(value.getAction());
@@ -184,7 +184,7 @@ public void render(final MenuItemCell cell,
184184

185185
// If this is a parent menu item, render an arrow to the right-hand side
186186
if ((value instanceof IconParentMenuItem || value instanceof KeyedParentMenuItem)
187-
&& value.isEnabled()) {
187+
&& value.isEnabled()) {
188188
inner.append(SvgImageUtil.toSafeHtml(SvgImage.ARROW_RIGHT, "menuItem-expandArrow"));
189189
}
190190

@@ -235,7 +235,7 @@ public void render(final MenuItemCell cell,
235235
inner.append(
236236
TEMPLATE.inner(
237237
"menuItem-simpleText",
238-
SafeHtmlUtils.fromTrustedString(value.getText())));
238+
value.getText()));
239239

240240
if (value.getAction() != null) {
241241
final String shortcut = KeyBinding.getShortcut(value.getAction());

stroom-core-client-widget/src/main/java/stroom/widget/menu/client/presenter/MenuItems.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static class ItemComparator implements Comparator<Item> {
136136
public int compare(final Item o1, final Item o2) {
137137
if (o1.getPriority() == o2.getPriority()) {
138138
if (o1 instanceof MenuItem && o2 instanceof MenuItem) {
139-
return ((MenuItem) o1).getText().compareTo(((MenuItem) o2).getText());
139+
return ((MenuItem) o1).getText().asString().compareTo(((MenuItem) o2).getText().asString());
140140
} else if (o1 instanceof Separator && o2 instanceof Separator) {
141141
return 0;
142142
} else if (o1 instanceof Separator) {

stroom-core-client-widget/src/main/java/stroom/widget/menu/client/presenter/SimpleMenuItem.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@
1818

1919
import stroom.widget.util.client.KeyBinding.Action;
2020

21+
import com.google.gwt.safehtml.shared.SafeHtml;
2122
import com.google.gwt.user.client.Command;
2223

2324
public class SimpleMenuItem extends MenuItem {
2425

2526
protected SimpleMenuItem(final int priority,
26-
final String text,
27+
final SafeHtml text,
28+
final SafeHtml tooltip,
2729
final Action action,
2830
final boolean enabled,
2931
final Command command) {
30-
super(priority, text, action, enabled, command);
32+
super(priority, text, tooltip, action, enabled, command);
3133
}
3234

3335
public static class Builder extends AbstractBuilder<SimpleMenuItem, Builder> {
@@ -41,6 +43,7 @@ public SimpleMenuItem build() {
4143
return new SimpleMenuItem(
4244
priority,
4345
text,
46+
tooltip,
4447
action,
4548
enabled,
4649
command);

stroom-core-client-widget/src/main/java/stroom/widget/menu/client/presenter/SimpleParentMenuItem.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import stroom.widget.util.client.Future;
2020
import stroom.widget.util.client.FutureImpl;
2121

22+
import com.google.gwt.safehtml.shared.SafeHtml;
2223
import com.google.gwt.user.client.Command;
2324

2425
import java.util.List;
@@ -28,17 +29,19 @@ public class SimpleParentMenuItem extends SimpleMenuItem implements HasChildren
2829
private final List<Item> children;
2930

3031
public SimpleParentMenuItem(final int priority,
31-
final String text,
32+
final SafeHtml text,
33+
final SafeHtml tooltip,
3234
final List<Item> children) {
33-
super(priority, text, null, true, null);
35+
super(priority, text, tooltip, null, true, null);
3436
this.children = children;
3537
}
3638

3739
public SimpleParentMenuItem(final int priority,
38-
final String text,
40+
final SafeHtml text,
41+
final SafeHtml tooltip,
3942
final List<Item> children,
4043
final Command command) {
41-
super(priority, text, null, true, command);
44+
super(priority, text, tooltip, null, true, command);
4245
this.children = children;
4346
}
4447

stroom-core-client/src/main/java/stroom/dashboard/client/main/DashboardPresenter.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
import stroom.widget.util.client.ElementUtil;
7373
import stroom.widget.util.client.MouseUtil;
7474
import stroom.widget.util.client.Rect;
75+
import stroom.widget.util.client.SafeHtmlUtil;
7576

7677
import com.google.gwt.dom.client.Element;
7778
import com.google.gwt.event.dom.client.ClickEvent;
@@ -312,7 +313,11 @@ private void onAdd(final ClickEvent event) {
312313
}
313314

314315
final List<Item> menuItems = new ArrayList<>();
315-
menuItems.add(new SimpleParentMenuItem(1, "Input", inputs));
316+
menuItems.add(new SimpleParentMenuItem(
317+
1,
318+
SafeHtmlUtil.from("Input"),
319+
SafeHtmlUtil.from("Input"),
320+
inputs));
316321
menuItems.addAll(panels);
317322

318323
ShowMenuEvent

stroom-core-client/src/main/java/stroom/dashboard/client/table/ColumnsManager.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import stroom.query.api.v2.ColumnFilter;
2525
import stroom.query.api.v2.Sort;
2626
import stroom.query.api.v2.Sort.SortDirection;
27+
import stroom.query.client.presenter.ColumnHeaderHtmlUtil;
2728
import stroom.svg.shared.SvgImage;
2829
import stroom.util.shared.GwtNullSafe;
2930
import stroom.widget.menu.client.presenter.HideMenuEvent;
@@ -712,7 +713,7 @@ private Item createShowMenu() {
712713
final Item item2 = new IconMenuItem.Builder()
713714
.priority(i++)
714715
.icon(SvgImage.SHOW)
715-
.text(column.getName())
716+
.text(ColumnHeaderHtmlUtil.getSafeHtml(column))
716717
.command(() -> showColumn(column))
717718
.build();
718719
menuItems.add(item2);

0 commit comments

Comments
 (0)