Skip to content

Commit ab6b22d

Browse files
committed
Initial code for pathways
1 parent b8738b6 commit ab6b22d

File tree

16 files changed

+129
-418
lines changed

16 files changed

+129
-418
lines changed

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

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
import stroom.widget.util.client.ElementUtil;
77
import stroom.widget.util.client.MouseUtil;
88
import stroom.widget.util.client.SvgImageUtil;
9+
import stroom.widget.util.client.Templates;
910

1011
import com.google.gwt.cell.client.AbstractCell;
1112
import com.google.gwt.cell.client.ValueUpdater;
12-
import com.google.gwt.core.client.GWT;
1313
import com.google.gwt.dom.client.Element;
1414
import com.google.gwt.dom.client.NativeEvent;
15-
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
1615
import com.google.gwt.safehtml.shared.SafeHtml;
1716
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
1817
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
@@ -25,16 +24,9 @@ public class CommandLinkCell extends AbstractCell<CommandLink> implements EventC
2524

2625
private static final String ICON_CLASS_NAME = "svgIcon";
2726
private static final String OPEN_CLASS_NAME = "commandLinkOpen";
28-
// private static final String OPEN_CLASS_NAME = "docRefLinkOpen";
29-
30-
private static Template template;
3127

3228
public CommandLinkCell() {
3329
super(MOUSEDOWN);
34-
35-
if (template == null) {
36-
template = GWT.create(Template.class);
37-
}
3830
}
3931

4032
@Override
@@ -84,40 +76,21 @@ public void render(final Context context, final CommandLink value, final SafeHtm
8476
} else if (value.hasCommand()) {
8577
final String text = value.getText();
8678

87-
final SafeHtml textSafeHtml = template
79+
final SafeHtml textSafeHtml = Templates
8880
.div("commandLinkText", SafeHtmlUtils.fromString(text));
8981

9082
sb.appendHtmlConstant("<div class=\"commandLinkContainer\">");
9183
sb.append(textSafeHtml);
9284

9385
final SafeHtml open = SvgImageUtil.toSafeHtml(SvgImage.OPEN, ICON_CLASS_NAME, OPEN_CLASS_NAME);
94-
sb.append(template.divWithToolTip(
86+
sb.append(Templates.divWithTitle(
9587
value.getTooltip(),
9688
open));
9789

9890
sb.appendHtmlConstant("</div>");
9991

10092
} else {
101-
sb.append(template.text(value.getText()));
93+
sb.appendEscaped(value.getText());
10294
}
10395
}
104-
105-
106-
// --------------------------------------------------------------------------------
107-
108-
109-
interface Template extends SafeHtmlTemplates {
110-
111-
// @Template("<div class=\"CommandLinkCell\" title=\"{1}\">{0}</div>")
112-
// SafeHtml link(String text, String tooltip);
113-
114-
@Template("{0}")
115-
SafeHtml text(String text);
116-
117-
@Template("<div class=\"{0}\">{1}</div>")
118-
SafeHtml div(String cssClass, SafeHtml content);
119-
120-
@Template("<div title=\"{0}\">{1}</div>")
121-
SafeHtml divWithToolTip(String title, SafeHtml content);
122-
}
12396
}

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

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
import stroom.widget.util.client.ElementUtil;
1111
import stroom.widget.util.client.MouseUtil;
1212
import stroom.widget.util.client.SvgImageUtil;
13+
import stroom.widget.util.client.Templates;
1314

1415
import com.google.gwt.cell.client.AbstractCell;
1516
import com.google.gwt.cell.client.ValueUpdater;
16-
import com.google.gwt.core.client.GWT;
1717
import com.google.gwt.dom.client.BrowserEvents;
1818
import com.google.gwt.dom.client.Element;
1919
import com.google.gwt.dom.client.NativeEvent;
2020
import com.google.gwt.event.shared.HasHandlers;
21-
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
2221
import com.google.gwt.safehtml.shared.SafeHtml;
2322
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
2423
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
@@ -41,17 +40,10 @@ public class HoverActionMenuCell<T> extends AbstractCell<T> implements EventCell
4140
private static final String HOVER_ACTION_MENU_CLASS_NAME = "hoverMenuAction";
4241
private static final SvgImage ICON_IMAGE = SvgImage.ELLIPSES_HORIZONTAL;
4342

44-
private static Template template;
45-
4643
private final Function<T, String> cellTextExtractor;
4744
private final Function<T, List<Item>> menuCreator;
4845
private final HasHandlers hasHandlers;
4946

50-
51-
static {
52-
template = GWT.create(Template.class);
53-
}
54-
5547
/**
5648
* @param cellTextExtractor Function to supply the text value of the cell
5749
* @param menuCreator A function to create a list of menu items to show when the hover
@@ -65,10 +57,6 @@ public HoverActionMenuCell(final Function<T, String> cellTextExtractor,
6557
final HasHandlers hasHandlers) {
6658
super(BrowserEvents.MOUSEDOWN);
6759

68-
if (template == null) {
69-
template = GWT.create(Template.class);
70-
}
71-
7260
this.menuCreator = menuCreator;
7361
this.cellTextExtractor = cellTextExtractor;
7462
this.hasHandlers = hasHandlers;
@@ -148,7 +136,7 @@ public void render(final Context context, final T value, final SafeHtmlBuilder s
148136

149137
final List<Item> menuItems = NullSafe.get(menuCreator, mc -> mc.apply(value));
150138
if (NullSafe.hasItems(menuItems)) {
151-
final SafeHtml textSafeHtml = template
139+
final SafeHtml textSafeHtml = Templates
152140
.div("commandLinkText", SafeHtmlUtils.fromString(cellText));
153141

154142
sb.appendHtmlConstant("<div class=\"commandLinkContainer\">");
@@ -164,10 +152,10 @@ public void render(final Context context, final T value, final SafeHtmlBuilder s
164152
menuItem.getCommand() != null) {
165153
// Single item with a command so no menu popup needed
166154
final SafeHtml tooltip = NullSafe.getOrElse(menuItem, MenuItem::getTooltip, menuItem.getText());
167-
sb.append(template.divWithTitle(tooltip.asString(), icon));
155+
sb.append(Templates.divWithTitle(tooltip.asString(), icon));
168156
} else {
169157
// Build the menu popup
170-
sb.append(template.divWithTitle("Actions...", icon));
158+
sb.append(Templates.divWithTitle("Actions...", icon));
171159
}
172160

173161
sb.appendHtmlConstant("</div>");
@@ -181,17 +169,4 @@ public void render(final Context context, final T value, final SafeHtmlBuilder s
181169
}
182170
}
183171
}
184-
185-
186-
// --------------------------------------------------------------------------------
187-
188-
189-
interface Template extends SafeHtmlTemplates {
190-
191-
@Template("<div class=\"{0}\">{1}</div>")
192-
SafeHtml div(String className, SafeHtml content);
193-
194-
@Template("<div title=\"{0}\">{1}</div>")
195-
SafeHtml divWithTitle(String title, SafeHtml content);
196-
}
197172
}

stroom-core-client-widget/src/main/java/stroom/item/client/SelectionItemCell.java

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,15 @@
2020
import stroom.util.shared.NullSafe;
2121
import stroom.widget.util.client.SafeHtmlUtil;
2222
import stroom.widget.util.client.SvgImageUtil;
23+
import stroom.widget.util.client.Templates;
2324

2425
import com.google.gwt.cell.client.AbstractCell;
25-
import com.google.gwt.core.client.GWT;
26-
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
2726
import com.google.gwt.safehtml.shared.SafeHtml;
2827
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
2928
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
3029

3130
public class SelectionItemCell<I extends SelectionItem> extends AbstractCell<I> {
3231

33-
private static Template template;
34-
35-
public SelectionItemCell() {
36-
if (template == null) {
37-
template = GWT.create(Template.class);
38-
}
39-
}
40-
4132
private String getCellClassName() {
4233
return "selectionItemCell";
4334
}
@@ -58,11 +49,11 @@ public void render(final Context context, final I row, final SafeHtmlBuilder sb)
5849
content.append(iconSafeHtml);
5950
}
6051
if (row.hasRenderedLabel()) {
61-
content.append(template.div(
52+
content.append(Templates.div(
6253
getCellClassName() + "-content",
6354
row.getRenderedLabel()));
6455
} else {
65-
content.append(template.div(
56+
content.append(Templates.div(
6657
getCellClassName() + "-text",
6758
SafeHtmlUtil.getSafeHtml(row.getLabel())));
6859
}
@@ -74,16 +65,10 @@ public void render(final Context context, final I row, final SafeHtmlBuilder sb)
7465
String className = getCellClassName() + "-expander";
7566
className += " " + expanderIcon.getClassName();
7667
expanderIconSafeHtml = SafeHtmlUtils.fromTrustedString(expanderIcon.getSvg());
77-
content.append(template.div(className, expanderIconSafeHtml));
68+
content.append(Templates.div(className, expanderIconSafeHtml));
7869
}
7970

80-
sb.append(template.div("explorerCell", content.toSafeHtml()));
71+
sb.append(Templates.div("explorerCell", content.toSafeHtml()));
8172
}
8273
}
83-
84-
interface Template extends SafeHtmlTemplates {
85-
86-
@Template("<div class=\"{0}\">{1}</div>")
87-
SafeHtml div(String className, SafeHtml content);
88-
}
8974
}

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

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import stroom.util.shared.NullSafe;
2222
import stroom.widget.util.client.KeyBinding;
2323
import stroom.widget.util.client.SvgImageUtil;
24+
import stroom.widget.util.client.Templates;
2425

2526
import com.google.gwt.cell.client.AbstractCell;
2627
import com.google.gwt.core.client.GWT;
@@ -65,25 +66,13 @@ public interface Appearance<I extends Item> {
6566

6667
public static class SeparatorAppearance implements Appearance<Separator> {
6768

68-
private static final Template TEMPLATE = GWT.create(Template.class);
69-
7069
public SeparatorAppearance() {
7170
}
7271

7372
@Override
7473
public void render(final MenuItemCell cell, final Context context, final Separator value,
7574
final SafeHtmlBuilder sb) {
76-
sb.append(TEMPLATE.separator("menuItem-separator"));
77-
}
78-
79-
80-
// --------------------------------------------------------------------------------
81-
82-
83-
public interface Template extends SafeHtmlTemplates {
84-
85-
@Template("<div class=\"{0}\"></div>")
86-
SafeHtml separator(String className);
75+
sb.append(Templates.div("menuItem-separator"));
8776
}
8877
}
8978

@@ -93,27 +82,15 @@ public interface Template extends SafeHtmlTemplates {
9382

9483
public static class GroupHeadingAppearance implements Appearance<GroupHeading> {
9584

96-
private static final Template TEMPLATE = GWT.create(Template.class);
97-
9885
public GroupHeadingAppearance() {
9986
}
10087

10188
@Override
10289
public void render(final MenuItemCell cell, final Context context, final GroupHeading value,
10390
final SafeHtmlBuilder sb) {
104-
sb.append(TEMPLATE.groupHeading("menuItem-groupHeading",
91+
sb.append(Templates.div("menuItem-groupHeading",
10592
SafeHtmlUtils.fromTrustedString(value.getGroupName())));
10693
}
107-
108-
109-
// --------------------------------------------------------------------------------
110-
111-
112-
public interface Template extends SafeHtmlTemplates {
113-
114-
@Template("<div class=\"{0}\">{1}</div>")
115-
SafeHtml groupHeading(String className, SafeHtml groupName);
116-
}
11794
}
11895

11996

stroom-core-client-widget/src/main/java/stroom/widget/util/client/SvgImageUtil.java

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@
44
import stroom.svg.shared.SvgImage;
55
import stroom.util.shared.NullSafe;
66

7-
import com.google.gwt.core.client.GWT;
87
import com.google.gwt.dom.client.Element;
9-
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
108
import com.google.gwt.safehtml.shared.SafeHtml;
119
import com.google.gwt.user.client.ui.UIObject;
1210

1311
import java.util.Objects;
1412

1513
public class SvgImageUtil {
1614

17-
private static final Template TEMPLATE = GWT.create(Template.class);
18-
1915
private SvgImageUtil() {
2016
}
2117

@@ -38,15 +34,14 @@ public static SafeHtml toSafeHtml(final String title,
3834
+ NullSafe.join(" ", classNames);
3935
final SafeHtml svgHtml = SafeHtmlUtil.getSafeHtmlFromSafeConstant(svgImage.getSvg());
4036

41-
final SafeHtml safeHtml = NullSafe.isBlankString(title)
42-
? TEMPLATE.icon(allClassNames, svgHtml)
43-
: TEMPLATE.icon(allClassNames, title, svgHtml);
44-
// GWT.log("safeHtml: " + safeHtml.asString());
45-
return safeHtml;
37+
// GWT.log("safeHtml: " + safeHtml.asString());
38+
return NullSafe.isBlankString(title)
39+
? Templates.div(allClassNames, svgHtml)
40+
: Templates.div(allClassNames, title, svgHtml);
4641
}
4742

4843
public static SafeHtml emptySvg(final String... classNames) {
49-
return TEMPLATE.emptySvg(NullSafe.join(" ", classNames));
44+
return Templates.emptySvg(NullSafe.join(" ", classNames));
5045
}
5146

5247
public static void setSvgAsInnerHtml(final Element element,
@@ -95,20 +90,4 @@ public static void setSvgAsInnerHtml(final Element element,
9590
element.setInnerSafeHtml(safeHtml);
9691
}
9792
}
98-
99-
100-
// --------------------------------------------------------------------------------
101-
102-
103-
interface Template extends SafeHtmlTemplates {
104-
105-
@Template("<div class=\"{0}\"><svg></svg></div>")
106-
SafeHtml emptySvg(String className);
107-
108-
@Template("<div class=\"{0}\">{1}</div>")
109-
SafeHtml icon(String className, SafeHtml icon);
110-
111-
@Template("<div class=\"{0}\" title=\"{1}\">{2}</div>")
112-
SafeHtml icon(String className, String title, SafeHtml icon);
113-
}
11493
}

0 commit comments

Comments
 (0)