Skip to content

Commit 7d17802

Browse files
authored
Merge pull request #4186 from gchq/help-btn
Add help btns, colour swatch cell and conditional rule updatable tick boxes
2 parents 2cf7572 + 0862048 commit 7d17802

File tree

53 files changed

+1889
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1889
-272
lines changed

stroom-app-gwt/src/main/java/stroom/app/client/App.java

+43
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import com.google.gwt.core.client.GWT;
2424
import com.gwtplatform.mvp.client.DelayedBindRegistry;
2525

26+
import java.util.Arrays;
27+
import java.util.stream.Collectors;
28+
2629
/**
2730
* Entry point classes define <code>onModuleLoad()</code>.
2831
*/
@@ -37,6 +40,23 @@ public void onModuleLoad() {
3740
// This is required for Gwt-Platform proxy's generator.
3841
DelayedBindRegistry.bind(ginjector);
3942

43+
// GWT.setUncaughtExceptionHandler(e -> {
44+
// GWT.log(e.getClass().getName());
45+
//
46+
// final StringBuilder stringBuilder = new StringBuilder();
47+
// appendStackTraces(e, stringBuilder);
48+
//// final String stack;
49+
//// if (e.getCause() != null && e.getCause().getStackTrace() != null) {
50+
//// stack = appendStackTraces(e.getCause().getStackTrace());
51+
//// } else if (e.getStackTrace() != null) {
52+
//// stack = appendStackTraces(e.getStackTrace());
53+
//// } else {
54+
//// stack = "";
55+
//// }
56+
//
57+
// Window.alert("ERROR: " + stringBuilder);
58+
// });
59+
4060
final UserPreferencesManager userPreferencesManager = ginjector.getPreferencesManager();
4161
userPreferencesManager.fetch(preferences -> {
4262
userPreferencesManager.setCurrentPreferences(preferences);
@@ -55,4 +75,27 @@ public void onModuleLoad() {
5575
// ginjector.getPlaceManager().revealCurrentPlace();
5676
});
5777
}
78+
79+
private void appendStackTraces(final Throwable e, final StringBuilder stringBuilder) {
80+
if (e.getStackTrace() != null) {
81+
//noinspection SizeReplaceableByIsEmpty // cos GWT
82+
if (stringBuilder.length() > 0) {
83+
stringBuilder.append("\n");
84+
}
85+
stringBuilder.append(e.getClass().getName())
86+
.append(" - ")
87+
.append(e.getMessage())
88+
.append(":\n");
89+
90+
final String stack = Arrays.stream(e.getStackTrace())
91+
.map(StackTraceElement::toString)
92+
.collect(Collectors.joining("\n"));
93+
stringBuilder.append(stack);
94+
95+
final Throwable cause = e.getCause();
96+
if (cause != null) {
97+
appendStackTraces(cause, stringBuilder);
98+
}
99+
}
100+
}
58101
}

stroom-app-gwt/src/main/java/stroom/app/client/gin/AppModule.java

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import stroom.data.grid.client.PagerViewImpl;
3636
import stroom.entity.client.presenter.LinkTabPanelView;
3737
import stroom.entity.client.view.LinkTabPanelViewImpl;
38+
import stroom.event.client.StaticEventBus;
3839
import stroom.explorer.client.presenter.AbstractFindPresenter;
3940
import stroom.explorer.client.presenter.EntityCheckTreePresenter;
4041
import stroom.explorer.client.presenter.EntityCheckTreePresenter.EntityCheckTreeView;
@@ -103,6 +104,8 @@ public class AppModule extends AbstractPresenterModule {
103104
protected void configure() {
104105
// Default implementation of standard resources
105106
bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
107+
bind(StaticEventBus.class).asEagerSingleton();
108+
106109
bind(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class);
107110
bind(RootPresenter.class).asEagerSingleton();
108111
bind(PlaceManager.class).to(InactivePlaceManager.class).in(Singleton.class);

stroom-app-gwt/src/main/resources/stroom/app/App.gwt.xml

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
<inherits name='stroom.Stroom'/>
2828
<inherits name='stroom.core.Core'/>
29+
<inherits name='stroom.event.Event' />
2930
<inherits name='stroom.task.Task'/>
3031
<inherits name='stroom.main.Main'/>
3132
<inherits name='stroom.widget.popup.Popup'/>
@@ -49,6 +50,7 @@
4950
<inherits name="stroom.widget.menu.Menu" />
5051
<inherits name="stroom.widget.button.Button" />
5152
<inherits name="stroom.widget.form.Form" />
53+
<inherits name="stroom.widget.help.Help" />
5254
<inherits name="stroom.widget.popup.Popup" />
5355
<inherits name="stroom.widget.progress.Progress" />
5456
<inherits name="stroom.widget.tickbox.TickBox" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.colourSwatchCell {
2+
3+
}
4+
5+
.colourSwatchCell-container {
6+
display: flex;
7+
flex-direction: row;
8+
align-items: center;
9+
gap: 0.2em;
10+
}
11+
12+
.colourSwatchCell-swatch {
13+
min-width: 14px;
14+
min-height: 14px;
15+
max-width: 14px;
16+
max-height: 14px;
17+
width: 14px;
18+
height: 14px;
19+
margin: 0.1em;
20+
border-style: solid;
21+
border-width: 1px;
22+
border-color: var(--text-color);
23+
}
24+
25+
.colourSwatchCell-text {
26+
}
27+
28+
.dataGridDisabledCell .colourSwatchCell-swatch {
29+
opacity: 0.3;
30+
}

stroom-app/src/main/resources/ui/css/QuickFilter.css

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
height: 18px;
4848
}
4949

50+
/* quickFilter-tooltip is also used by the HelpManager so bear that in mind.
51+
Probably ought to be moved to a common css */
5052
.quickFilter-tooltip {
5153
background-color: var(--tooltip__background-color);
5254
color: var(--tooltip__text-color);

stroom-app/src/main/resources/ui/css/app.css

+1
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@
7272
@import url("prismjs/prismjs-light.css");
7373
@import url("markdown.css");
7474
@import url("icon-colours.css");
75+
@import url("ColourSwatchCell.css");

stroom-app/src/main/resources/ui/css/celltable/DataGrid.css

+9-3
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,18 @@
178178
}
179179

180180
.dataGridDisabledCell {
181-
color: var(--text-color--disabled);
181+
color: var(--text-color--disabled);
182+
}
183+
184+
.dataGridDisabledCell .tickBox {
185+
cursor: default;
186+
color: #000;
187+
opacity: 0.3;
182188
}
183189

184190
.dataGridSelectedRow {
185-
background-color: var(--row__background-color--selected);
186-
color: var(--row__text-color--selected);
191+
background-color: var(--row__background-color--selected);
192+
color: var(--row__text-color--selected);
187193
}
188194

189195
.dataGridOddRow:hover,

stroom-app/src/main/resources/ui/css/components.css

+49
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,10 @@ button.main-menu svg {
16481648
flex-direction: column;
16491649
}
16501650

1651+
.form-group > div:has(> label) {
1652+
display: flex;
1653+
}
1654+
16511655

16521656
.form-group:not(:first-child) {
16531657
margin-top: 0.3em;
@@ -1659,6 +1663,51 @@ button.main-menu svg {
16591663
margin-top: 0;
16601664
}
16611665

1666+
.form-group-label-container .form-label{
1667+
margin-bottom: 0;
1668+
}
1669+
1670+
.form-group-label-container {
1671+
display: flex;
1672+
flex-direction: row;
1673+
gap: var(--control__gap--horizontal);
1674+
align-items: center;
1675+
margin-bottom: 0.25rem;
1676+
}
1677+
1678+
.form-group .help-button {
1679+
margin-bottom: 0rem;
1680+
}
1681+
1682+
.help-button-tooltip {
1683+
/* width: 500px; */
1684+
max-width: 500px;
1685+
border-width: 2px;
1686+
border-color: var(--heading-color);
1687+
border-style: solid;
1688+
border-radius: 6px;
1689+
}
1690+
1691+
.help-button-tooltip .popupContent {
1692+
margin: 5px;
1693+
font-weight: 400;
1694+
}
1695+
1696+
.help-button-tooltip .popupContent div {
1697+
font-weight: 400;
1698+
}
1699+
1700+
.form-group .help-button .icon-button {
1701+
width: 18px;
1702+
height: 18px;
1703+
}
1704+
1705+
.form-group .help-button svg {
1706+
width: 16px;
1707+
height: 16px;
1708+
/* margin-bottom: 0.6em; */
1709+
}
1710+
16621711
.form-heading {
16631712
font-weight: 500;
16641713
font-size: var(--font-size-19);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package stroom.cell.info.client;
2+
3+
import stroom.util.shared.GwtNullSafe;
4+
5+
import com.google.gwt.cell.client.AbstractCell;
6+
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
7+
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
8+
9+
public class ColourSwatchCell extends AbstractCell<String> {
10+
11+
public ColourSwatchCell() {
12+
}
13+
14+
@Override
15+
public void render(final Context context,
16+
final String cssColour,
17+
final SafeHtmlBuilder sb) {
18+
19+
if (GwtNullSafe.isBlankString(cssColour)) {
20+
sb.append(SafeHtmlUtils.EMPTY_SAFE_HTML);
21+
} else {
22+
sb.appendHtmlConstant("<div class=\"colourSwatchCell colourSwatchCell-container\">");
23+
24+
sb.appendHtmlConstant("<div class=\"colourSwatchCell-swatch\" style=\"background-color:");
25+
sb.appendEscaped(cssColour);
26+
sb.appendHtmlConstant("\">");
27+
sb.appendHtmlConstant("</div>");
28+
29+
sb.appendHtmlConstant("<div class=\"colourSwatchCell-text\">");
30+
sb.appendEscaped(cssColour);
31+
sb.appendHtmlConstant("</div>");
32+
33+
sb.appendHtmlConstant("</div>");
34+
}
35+
}
36+
}

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

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// volume/stream sizes, however it probably ought to become a ByteValueCell and ByteValueColumn
1111
// with a standard approach for formatting the byte value and the tooltip. Leaving it here
1212
// in case such a thing ever happens.
13+
1314
/**
1415
* A text cell with a tool tip
1516
*/
@@ -26,7 +27,12 @@ public void render(Context context, ToolTipCellValue value, SafeHtmlBuilder sb)
2627
}
2728
}
2829

30+
31+
// --------------------------------------------------------------------------------
32+
33+
2934
public static class ToolTipCellValue {
35+
3036
private final String cellValue;
3137
private final String toolTipValue;
3238

stroom-core-client-widget/src/main/java/stroom/cell/tickbox/client/TickBoxCell.java

+4
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ public SafeHtml getHTML(final TickBoxState value) {
271271
}
272272
}
273273

274+
275+
// --------------------------------------------------------------------------------
276+
277+
274278
public interface Template extends SafeHtmlTemplates {
275279

276280
@Template("<div class=\"{0}\"><div class=\"{1}\"></div></div>")

stroom-core-client-widget/src/main/java/stroom/data/grid/client/MyDataGrid.java

+18-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,24 @@ public void addAutoResizableColumn(final Column<R, ?> column,
488488
colSettings.add(new ColSettings(true, true));
489489
}
490490

491-
public void addResizableColumn(final Column<R, ?> column, final Header<?> header, final int width) {
491+
/**
492+
* Add a resizable column that will initially expand so that the table fills the available space.
493+
* Unless manually resized, it will expand to fill but not go below the initialMinimumWidth.
494+
* Once the user resizes it, it becomes a fixed width column under their control.
495+
*
496+
* @param initialMinimumWidth Initial minimum width in pixels. Ignored once the user has resized it.
497+
*/
498+
public void addAutoResizableColumn(final Column<R, ?> column,
499+
final Header<?> header,
500+
final int initialMinimumWidth) {
501+
super.addColumn(column, header);
502+
setAutoColumnWidth(column, 100, initialMinimumWidth);
503+
colSettings.add(new ColSettings(true, true));
504+
}
505+
506+
public void addResizableColumn(final Column<R, ?> column,
507+
final Header<?> header,
508+
final int width) {
492509
super.addColumn(column, header);
493510
setColumnWidth(column, width, Unit.PX);
494511
colSettings.add(new ColSettings(true, true));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package stroom.event.client;
2+
3+
import com.google.inject.Inject;
4+
import com.google.inject.Singleton;
5+
import com.google.web.bindery.event.shared.Event;
6+
import com.google.web.bindery.event.shared.EventBus;
7+
8+
/**
9+
* Somewhat hacky class to allow us to fire events from composites.
10+
*/
11+
@Singleton
12+
public class StaticEventBus {
13+
14+
private static EventBus eventBus = null;
15+
16+
@Inject
17+
public StaticEventBus(final EventBus eventBus) {
18+
StaticEventBus.eventBus = eventBus;
19+
}
20+
21+
public static EventBus getEventBus() {
22+
if (eventBus == null) {
23+
throw new RuntimeException("Static eventBus has not been initialised");
24+
}
25+
return eventBus;
26+
}
27+
28+
public static <T> void fire(final Event<T> event) {
29+
getEventBus().fireEvent(event);
30+
}
31+
}

0 commit comments

Comments
 (0)