Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [Databinding] Problem with AggregateValidationStatus
[Databinding] Problem with AggregateValidationStatus [message #334622] Fri, 20 February 2009 15:36 Go to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
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 #334628 is a reply to message #334622] Fri, 20 February 2009 16:09 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
Kai Schlamp wrote:
> 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?

My guess is that because you are using MAX_SEVERITY you might not be
editing the field that has the current max severity, (i.e. you are
editing a field with a lower severity validation status.

> 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).

Have you tried WizardPageSupport.create(DataBindingContext, WizardPage)?

Matthew
Re: [Databinding] Problem with AggregateValidationStatus [message #334630 is a reply to message #334628] Fri, 20 February 2009 17:46 Go to previous messageGo to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
Comments below.

> My guess is that because you are using MAX_SEVERITY you might not be
> editing the field that has the current max severity, (i.e. you are
> editing a field with a lower severity validation status.

It doesn't work whatever text field I edit. handleChange is called once
and after that not anymore.
And even when using MERGED I get the same behavior.
What do I have to do that handleChange method is called everytime the
text field is modified?


>> 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).
>
> Have you tried WizardPageSupport.create(DataBindingContext, WizardPage)?

Sounds ok, but it does also some things I don't like (updates the error
message). Also there are several other cases I need the
AggregateValidationStatus to work.
Any suggestions?

By the way I am using Eclipse 3.5M5.

Kai
Re: [Databinding] Problem with AggregateValidationStatus [message #334632 is a reply to message #334630] Fri, 20 February 2009 18:51 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
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.

Matthew

Kai Schlamp wrote:
> Comments below.
>
>> My guess is that because you are using MAX_SEVERITY you might not be
>> editing the field that has the current max severity, (i.e. you are
>> editing a field with a lower severity validation status.
>
> It doesn't work whatever text field I edit. handleChange is called once
> and after that not anymore.
> And even when using MERGED I get the same behavior.
> What do I have to do that handleChange method is called everytime the
> text field is modified?
>
>
>>> 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).
>>
>> Have you tried WizardPageSupport.create(DataBindingContext, WizardPage)?
>
> Sounds ok, but it does also some things I don't like (updates the error
> message). Also there are several other cases I need the
> AggregateValidationStatus to work.
> Any suggestions?
>
> By the way I am using Eclipse 3.5M5.
>
> Kai
Re: [Databinding] Problem with AggregateValidationStatus [message #334634 is a reply to message #334632] Fri, 20 February 2009 19:27 Go to previous messageGo to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
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.
Re: [Databinding] Problem with AggregateValidationStatus [message #334636 is a reply to message #334634] Fri, 20 February 2009 21:39 Go to previous message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
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.
>
>
>
Previous Topic:Radio tool item with pulldown menu
Next Topic:SelectionProvider is not set in the WindowSelectionService
Goto Forum:
  


Current Time: Sun Nov 10 18:14:05 GMT 2024

Powered by FUDForum. Page generated in 0.04041 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top