Search code examples
eclipse-rcpjface

Manually calling DataBindingContext.updateModels() causes UnsupportedOperationException


I am updating an RCP application from 2015 to 2018-09 (last version that supports a 32-bit JVM).

On a managed form with multiple sections each with their own DataBindingConext (dbc), I keep track of all validation errors and warning messages using an AggregateValidationStatus in the master dbc.

At one point in the user flow, I need to present a list of all validation error and warning messages. When I originally wrote the code in 2015, I wanted to be sure all the validation code had executed prior to displaying to the user, so I manually called masterDbc.updateModels(). This executed without exceptions.

Now manually calling masterDbc.updateModels() causes an UnsupportedOperationException on the return of AggregateValidationStatus.calculate(). Note this exception happens when manually calling updateModels() on any dbc, not just the master dbc.

Two questions:

  1. Is this expected behavior?
  2. Given that the user has to choose a menu option / button to get the summary of validation issues, do I need to call updateModels() manually?

Thanks, Timothy


Solution

  • The solution to the issue is to pass in a targetToModel UpdateValueStrategy with POLICY_NEVER so that no attempt to update the read only AggregateValidationStatus is made.

    this.dbc.bindValue(WidgetProperties.text().observe(lblErrMsg),
        new AggregateValidationStatus(this.dbc, AggregateValidationStatus.MAX_SEVERITY),
                    new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);