[Databinding] Problem with AggregateValidationStatus [message #334622] |
Fri, 20 February 2009 10:36  |
Eclipse User |
|
|
|
Hello.
I am using a DataBindingContext where three Text's are bound to EMF
models by
bindingContext.bindValue(SWTObservables.observeText(text, SWT.Modify),
EMFObservables.observeValue(eObject, eStructuralFeature), new
UpdateValueStrategy(UpdateValueStrategy.POLICY_CONVERT).setA fterConvertValidator(validator),
new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
Those validator's are called correctly. Whenever I type something into
one of the text fields the validate method is called.
I further added an AggregateValidationStatus by
AggregateValidationStatus aggregateValidationStatus = new
AggregateValidationStatus(bindingContext,
AggregateValidationStatus.MAX_SEVERITY);
and added an IChangeListener.
The problem is that the handleChange method of that listener is only
called once (the first time I type something into one of those text
fields), but not later on anymore.
I would have exspected that the handleChange method is called as often
as one of the validators validate method is called.
How does the AggregateValidationStatus class work?
That leads me to my next question? I want to listen to whenever a
validate method of the above added validator's was called. I need it to
setPageComplete of a WizardPage (as all text fields together have an
influence on that).
Best regards,
Kai
|
|
|
|
|
|
|
Re: [Databinding] Problem with AggregateValidationStatus [message #334636 is a reply to message #334634] |
Fri, 20 February 2009 16:39  |
Eclipse User |
|
|
|
Try using an IValueChangeListener instead of IChangeListener:
aggregateValidationStatus.addValueChangeListener(
new IValueChangeListener() {
public void handleValueChange(ValueChangeEvent event) {
event.getObservableValue().getValue();
}
} );
Matthew
Kai Schlamp wrote:
> So, Schroedinger's cat ... nice analogy ... I hope my
> AggregateValidationStatus doesn't contain any transitional states ;-)
>
> And yes, it works now when calling getValue inside the change listener.
> Is there an easy way to get the AggregateValidationStatus from within
> the change listener? A "(AggregateValidationStatus) event.getSource())"
> results in a ClassCastException (java.lang.ClassCastException:
> org.eclipse.core.databinding.AggregateValidationStatus$1 cannot be
> cast to org.eclipse.core.databinding.AggregateValidationStatus).
> Do I really have to pass the AggregateValidationStatus to the change
> listener myself?
>
> Thank you,
> Kai
>
>> Are you doing anything with the value of the
>> AggregateValidationStatus? in the change listener? AVS is backed by a
>> ComputedValue which fires an event once and doesn't fire any more
>> until you look at the new value. It's kind of like Schroedinger's
>> cat--you don't get any more change events until you look in the safe.
>> See ObservableTracker.getterCalled(IObservable). Then see
>> IObservableValue and look for methods tagged @TrackedGetter.
>>
>> We do this to avoid an event storm if several observables are changed
>> rapidly. I think it will fix your problem just to call getValue() on
>> the AVS inside the change listener.
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03589 seconds