21
21
import stroom .dashboard .client .main .AbstractComponentPresenter ;
22
22
import stroom .dashboard .client .main .ComponentRegistry .ComponentType ;
23
23
import stroom .dashboard .client .main .ComponentRegistry .ComponentUse ;
24
- import stroom .dashboard .client .main .Components ;
25
24
import stroom .dashboard .client .main .DashboardContext ;
26
25
import stroom .dashboard .client .main .Queryable ;
27
26
import stroom .dashboard .client .query .QueryInfo ;
@@ -174,12 +173,12 @@ public void setData(final Result componentResult) {
174
173
start = false ;
175
174
}
176
175
177
- if (tableResult .getRows () != null && tableResult .getRows ().size () > 0 ) {
176
+ if (tableResult .getRows () != null && ! tableResult .getRows ().isEmpty () ) {
178
177
hasData = true ;
179
178
}
180
179
181
180
// 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 () ) {
183
182
final QueryTablePreferences queryTablePreferences = QueryTablePreferences
184
183
.copy (getQuerySettings ().getQueryTablePreferences ())
185
184
.columns (tableResult .getColumns ())
@@ -354,13 +353,12 @@ public void runQuery() {
354
353
}
355
354
356
355
@ 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 -> {
361
359
if (initialised ) {
362
- final ExpressionOperator selectionQuery = SelectionHandlerExpressionBuilder
363
- .create ( components . getComponents (), getQuerySettings ().getSelectionQuery ())
360
+ final ExpressionOperator selectionQuery = dashboardContext
361
+ .createSelectionHandlerExpression ( getQuerySettings ().getSelectionQuery ())
364
362
.orElse (null );
365
363
366
364
if (!Objects .equals (currentSelectionQuery , selectionQuery )) {
@@ -370,8 +368,9 @@ public void setComponents(final Components components) {
370
368
}
371
369
372
370
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 ())
375
374
.orElse (null );
376
375
if (!Objects .equals (currentTablePresenter .getCurrentSelectionFilter (), selectionFilter )) {
377
376
currentTablePresenter .setCurrentSelectionFilter (selectionFilter );
@@ -421,6 +420,7 @@ private void updateVisibleResult() {
421
420
private void createNewTable () {
422
421
if (currentTablePresenter == null ) {
423
422
currentTablePresenter = tablePresenterProvider .get ();
423
+ currentTablePresenter .setDashboardContext (getDashboardContext ());
424
424
currentTablePresenter .setQueryTablePreferencesSupplier (() ->
425
425
getQuerySettings ().getQueryTablePreferences ());
426
426
currentTablePresenter .setQueryTablePreferencesConsumer (queryTablePreferences ->
@@ -430,7 +430,8 @@ private void createNewTable() {
430
430
currentTablePresenter .updateQueryTablePreferences ();
431
431
tableHandlerRegistrations .add (currentTablePresenter .addDirtyHandler (e -> setDirty (true )));
432
432
tableHandlerRegistrations .add (currentTablePresenter .getSelectionModel ()
433
- .addSelectionHandler (event -> getComponents ().fireComponentChangeEvent (this )));
433
+ .addSelectionHandler (event ->
434
+ getDashboardContext ().fireComponentChangeEvent (this )));
434
435
435
436
if (currentVisPresenter != null ) {
436
437
currentTablePresenter .setQueryResultVisPresenter (currentVisPresenter );
@@ -452,7 +453,7 @@ private void createNewVis() {
452
453
if (currentVisPresenter == null ) {
453
454
final VisSelectionModel visSelectionModel = new VisSelectionModel ();
454
455
visSelectionModel .addSelectionHandler (event ->
455
- getComponents ().fireComponentChangeEvent (EmbeddedQueryPresenter .this ));
456
+ getDashboardContext ().fireComponentChangeEvent (EmbeddedQueryPresenter .this ));
456
457
457
458
currentVisPresenter = visPresenterProvider .get ();
458
459
currentVisPresenter .setQueryModel (queryModel );
@@ -470,7 +471,7 @@ private void destroyCurrentVis() {
470
471
currentVisPresenter .onRemove ();
471
472
currentVisPresenter = null ;
472
473
if (currentTablePresenter != null ) {
473
- currentTablePresenter .setQueryResultVisPresenter (currentVisPresenter );
474
+ currentTablePresenter .setQueryResultVisPresenter (null );
474
475
}
475
476
}
476
477
}
@@ -567,6 +568,15 @@ public void read(final ComponentConfig componentConfig) {
567
568
.build ());
568
569
}
569
570
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
+
570
580
loadEmbeddedQuery ();
571
581
}
572
582
0 commit comments