[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform] Re: [Databinding] Problem with AggregateValidationStatus
|
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.