Skip to content

Commit 155636d

Browse files
committed
#4484 Change selection handling to use fully qualified keys
1 parent ed442b1 commit 155636d

Some content is hidden

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

41 files changed

+950
-375
lines changed

stroom-core-client-widget/src/main/java/stroom/hyperlink/client/HyperlinkEvent.java

+17-2
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,30 @@
2525
public class HyperlinkEvent extends GwtEvent<HyperlinkEvent.Handler> {
2626

2727
private static Type<Handler> TYPE;
28+
2829
private final Hyperlink hyperlink;
2930
private final TaskMonitorFactory taskMonitorFactory;
31+
private final Object context;
3032

3133
private HyperlinkEvent(final Hyperlink hyperlink,
32-
final TaskMonitorFactory taskMonitorFactory) {
34+
final TaskMonitorFactory taskMonitorFactory,
35+
final Object context) {
3336
this.hyperlink = hyperlink;
3437
this.taskMonitorFactory = taskMonitorFactory;
38+
this.context = context;
3539
}
3640

3741
public static void fire(final HasHandlers handlers,
3842
final Hyperlink hyperlink,
3943
final TaskMonitorFactory taskMonitorFactory) {
40-
handlers.fireEvent(new HyperlinkEvent(hyperlink, taskMonitorFactory));
44+
handlers.fireEvent(new HyperlinkEvent(hyperlink, taskMonitorFactory, null));
45+
}
46+
47+
public static void fire(final HasHandlers handlers,
48+
final Hyperlink hyperlink,
49+
final TaskMonitorFactory taskMonitorFactory,
50+
final Object context) {
51+
handlers.fireEvent(new HyperlinkEvent(hyperlink, taskMonitorFactory, context));
4152
}
4253

4354
public static Type<Handler> getType() {
@@ -65,6 +76,10 @@ public TaskMonitorFactory getTaskMonitorFactory() {
6576
return taskMonitorFactory;
6677
}
6778

79+
public Object getContext() {
80+
return context;
81+
}
82+
6883
public interface Handler extends EventHandler {
6984

7085
void onLink(HyperlinkEvent event);

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public DashboardPlugin(final EventBus eventBus,
7373
this.restFactory = restFactory;
7474

7575
registerHandler(eventBus.addHandler(ShowDashboardEvent.getType(),
76-
event -> openParameterisedDashboard(event.getHref())));
76+
event -> openParameterisedDashboard(event.getContext(), event.getHref())));
7777
registerHandler(eventBus.addHandler(ReopenResultStoreEvent.getType(),
7878
event -> reopen(event.getResultStoreInfo())));
7979
}
@@ -90,25 +90,26 @@ public MyPresenterWidget<?> open(final DocRef docRef,
9090
return super.open(docRef, forceOpen, fullScreen, selectedLinkTab, taskMonitorFactory);
9191
}
9292

93-
private void openParameterisedDashboard(final String href) {
93+
private void openParameterisedDashboard(final Object context, final String href) {
9494
final Map<String, String> map = buildListParamMap(href);
9595
final String title = map.get("title");
9696
String uuid = map.get("uuid");
9797
final String params = map.get("params");
9898
final boolean queryOnOpen = !Boolean.FALSE.toString().equalsIgnoreCase(map.get("queryOnOpen"));
9999

100-
if (uuid == null || uuid.trim().length() == 0) {
100+
if (uuid == null || uuid.trim().isEmpty()) {
101101
uuid = currentUuid;
102102
}
103103

104-
if (uuid == null || uuid.trim().length() == 0) {
104+
if (uuid == null || uuid.trim().isEmpty()) {
105105
AlertEvent.fireError(this, "No dashboard UUID has been provided for link", null);
106106
} else {
107107
final DocRef docRef = new DocRef(DashboardDoc.TYPE, uuid);
108108

109109
// If the item isn't already open but we are forcing it open then,
110110
// create a new presenter and register it as open.
111111
final DashboardSuperPresenter presenter = dashboardSuperPresenterProvider.get();
112+
presenter.setParentContext(context);
112113
presenter.setParamsFromLink(params);
113114
presenter.setCustomTitle(title);
114115
presenter.setQueryOnOpen(queryOnOpen);

stroom-core-client/src/main/java/stroom/dashboard/client/embeddedquery/EmbeddedQueryPresenter.java

+24-14
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import stroom.dashboard.client.main.AbstractComponentPresenter;
2222
import stroom.dashboard.client.main.ComponentRegistry.ComponentType;
2323
import stroom.dashboard.client.main.ComponentRegistry.ComponentUse;
24-
import stroom.dashboard.client.main.Components;
2524
import stroom.dashboard.client.main.DashboardContext;
2625
import stroom.dashboard.client.main.Queryable;
2726
import stroom.dashboard.client.query.QueryInfo;
@@ -174,12 +173,12 @@ public void setData(final Result componentResult) {
174173
start = false;
175174
}
176175

177-
if (tableResult.getRows() != null && tableResult.getRows().size() > 0) {
176+
if (tableResult.getRows() != null && !tableResult.getRows().isEmpty()) {
178177
hasData = true;
179178
}
180179

181180
// Update the columns that are known to the query table preferences.
182-
if (tableResult.getColumns() != null && tableResult.getColumns().size() > 0) {
181+
if (tableResult.getColumns() != null && !tableResult.getColumns().isEmpty()) {
183182
final QueryTablePreferences queryTablePreferences = QueryTablePreferences
184183
.copy(getQuerySettings().getQueryTablePreferences())
185184
.columns(tableResult.getColumns())
@@ -354,13 +353,12 @@ public void runQuery() {
354353
}
355354

356355
@Override
357-
public void setComponents(final Components components) {
358-
super.setComponents(components);
359-
360-
registerHandler(components.addComponentChangeHandler(event -> {
356+
public void setDashboardContext(final DashboardContext dashboardContext) {
357+
super.setDashboardContext(dashboardContext);
358+
registerHandler(dashboardContext.addComponentChangeHandler(event -> {
361359
if (initialised) {
362-
final ExpressionOperator selectionQuery = SelectionHandlerExpressionBuilder
363-
.create(components.getComponents(), getQuerySettings().getSelectionQuery())
360+
final ExpressionOperator selectionQuery = dashboardContext
361+
.createSelectionHandlerExpression(getQuerySettings().getSelectionQuery())
364362
.orElse(null);
365363

366364
if (!Objects.equals(currentSelectionQuery, selectionQuery)) {
@@ -370,8 +368,9 @@ public void setComponents(final Components components) {
370368
}
371369

372370
if (currentTablePresenter != null) {
373-
final ExpressionOperator selectionFilter = SelectionHandlerExpressionBuilder
374-
.create(components.getComponents(), getQuerySettings().getSelectionFilter())
371+
currentTablePresenter.setDashboardContext(dashboardContext);
372+
final ExpressionOperator selectionFilter = dashboardContext
373+
.createSelectionHandlerExpression(getQuerySettings().getSelectionFilter())
375374
.orElse(null);
376375
if (!Objects.equals(currentTablePresenter.getCurrentSelectionFilter(), selectionFilter)) {
377376
currentTablePresenter.setCurrentSelectionFilter(selectionFilter);
@@ -421,6 +420,7 @@ private void updateVisibleResult() {
421420
private void createNewTable() {
422421
if (currentTablePresenter == null) {
423422
currentTablePresenter = tablePresenterProvider.get();
423+
currentTablePresenter.setDashboardContext(getDashboardContext());
424424
currentTablePresenter.setQueryTablePreferencesSupplier(() ->
425425
getQuerySettings().getQueryTablePreferences());
426426
currentTablePresenter.setQueryTablePreferencesConsumer(queryTablePreferences ->
@@ -430,7 +430,8 @@ private void createNewTable() {
430430
currentTablePresenter.updateQueryTablePreferences();
431431
tableHandlerRegistrations.add(currentTablePresenter.addDirtyHandler(e -> setDirty(true)));
432432
tableHandlerRegistrations.add(currentTablePresenter.getSelectionModel()
433-
.addSelectionHandler(event -> getComponents().fireComponentChangeEvent(this)));
433+
.addSelectionHandler(event ->
434+
getDashboardContext().fireComponentChangeEvent(this)));
434435

435436
if (currentVisPresenter != null) {
436437
currentTablePresenter.setQueryResultVisPresenter(currentVisPresenter);
@@ -452,7 +453,7 @@ private void createNewVis() {
452453
if (currentVisPresenter == null) {
453454
final VisSelectionModel visSelectionModel = new VisSelectionModel();
454455
visSelectionModel.addSelectionHandler(event ->
455-
getComponents().fireComponentChangeEvent(EmbeddedQueryPresenter.this));
456+
getDashboardContext().fireComponentChangeEvent(EmbeddedQueryPresenter.this));
456457

457458
currentVisPresenter = visPresenterProvider.get();
458459
currentVisPresenter.setQueryModel(queryModel);
@@ -470,7 +471,7 @@ private void destroyCurrentVis() {
470471
currentVisPresenter.onRemove();
471472
currentVisPresenter = null;
472473
if (currentTablePresenter != null) {
473-
currentTablePresenter.setQueryResultVisPresenter(currentVisPresenter);
474+
currentTablePresenter.setQueryResultVisPresenter(null);
474475
}
475476
}
476477
}
@@ -567,6 +568,15 @@ public void read(final ComponentConfig componentConfig) {
567568
.build());
568569
}
569570

571+
// Fix legacy selection filters.
572+
setSettings(getQuerySettings()
573+
.copy()
574+
.selectionQuery(SelectionHandlerExpressionBuilder
575+
.fixLegacySelectionHandlers(getQuerySettings().getSelectionQuery()))
576+
.selectionFilter(SelectionHandlerExpressionBuilder
577+
.fixLegacySelectionHandlers(getQuerySettings().getSelectionFilter()))
578+
.build());
579+
570580
loadEmbeddedQuery();
571581
}
572582

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

+5-19
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public abstract class AbstractComponentPresenter<V extends View>
4141

4242
private final Provider<?> settingsPresenterProvider;
4343
private TabLayout tabLayout;
44-
private Components components;
4544
private ComponentConfig componentConfig;
4645
private TabConfig tabConfig;
4746
private SettingsPresenter settingsPresenter;
@@ -56,16 +55,13 @@ public AbstractComponentPresenter(final EventBus eventBus,
5655
}
5756

5857
@Override
59-
public Components getComponents() {
60-
return components;
58+
public DashboardContext getDashboardContext() {
59+
return dashboardContext;
6160
}
6261

63-
/**
64-
* Called just after a component is created from the component registry.
65-
*/
6662
@Override
67-
public void setComponents(final Components components) {
68-
this.components = components;
63+
public void setDashboardContext(final DashboardContext dashboardContext) {
64+
this.dashboardContext = dashboardContext;
6965
}
7066

7167
@Override
@@ -112,7 +108,7 @@ public void showSettings() {
112108
settingsPresenter = (SettingsPresenter) settingsPresenterProvider.get();
113109
}
114110

115-
settingsPresenter.setComponents(components);
111+
settingsPresenter.setDashboardContext(dashboardContext);
116112
settingsPresenter.read(componentConfig);
117113

118114
final PopupSize popupSize = PopupSize.resizable(800, 650);
@@ -219,16 +215,6 @@ public boolean isCloseable() {
219215
//# End TabData
220216
//###############
221217

222-
223-
@Override
224-
public void setDashboardContext(final DashboardContext dashboardContext) {
225-
this.dashboardContext = dashboardContext;
226-
}
227-
228-
protected DashboardContext getDashboardContext() {
229-
return dashboardContext;
230-
}
231-
232218
@Override
233219
public void setDesignMode(final boolean designMode) {
234220
this.designMode = designMode;

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@
2424
public abstract class AbstractSettingsTabPresenter<V extends View> extends MyPresenterWidget<V>
2525
implements ComponentDataModifier {
2626

27-
private Components components;
27+
private DashboardContext dashboardContext;
2828

2929
@Inject
3030
public AbstractSettingsTabPresenter(final EventBus eventBus, final V view) {
3131
super(eventBus, view);
3232
}
3333

3434
@Override
35-
public Components getComponents() {
36-
return components;
35+
public DashboardContext getDashboardContext() {
36+
return dashboardContext;
3737
}
3838

3939
@Override
40-
public void setComponents(final Components components) {
41-
this.components = components;
40+
public void setDashboardContext(final DashboardContext dashboardContext) {
41+
this.dashboardContext = dashboardContext;
4242
}
4343
}

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
public interface Component extends TabData, Layer, HasDisplayValue {
2929

30-
Components getComponents();
30+
DashboardContext getDashboardContext();
3131

32-
void setComponents(Components components);
32+
void setDashboardContext(DashboardContext dashboardContext);
3333

3434
ComponentType getComponentType();
3535

@@ -68,7 +68,5 @@ public interface Component extends TabData, Layer, HasDisplayValue {
6868

6969
ComponentConfig write();
7070

71-
void setDashboardContext(DashboardContext dashboardContext);
72-
7371
void setDesignMode(boolean designMode);
7472
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public interface ComponentDataModifier extends HasTaskMonitorFactory {
2525

2626
boolean isDirty(ComponentConfig componentConfig);
2727

28-
Components getComponents();
28+
DashboardContext getDashboardContext();
2929

30-
void setComponents(Components components);
30+
void setDashboardContext(DashboardContext dashboardContext);
3131

3232
void read(ComponentConfig componentConfig);
3333

0 commit comments

Comments
 (0)