Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » MultiValidator does not attach to empty IObservableList
MultiValidator does not attach to empty IObservableList [message #487434] Wed, 23 September 2009 09:17 Go to next message
Aniruddha Deshpande is currently offline Aniruddha DeshpandeFriend
Messages: 4
Registered: July 2009
Junior Member
I have an observable list which needs to be validated. I used following snippet for validating this observable.

WritableList myList = new WritableList(realm...);
...
...
MultiValidator listValidtor = new MultiValidator() {
            protected IStatus validate() {
                if (myList.isEmpty()) {
                     return new Status(IStatus.ERROR....);
                 }

                return ValidationStatus.ok();
            }
};
bindingContext.addValidationStatusProvider(listValidtor);
...
...


I then have a code which attaches to validation status observables.

Problem I see is this: When MultiValidator.getValidationStatus() method is called for the first time it runs validation for first time using ObservableTracker.runAndMonitor.

After that it fetches all observables and adds them to a list. Now this is the list of observables which were found when running validate() method. In my case this results to a list containing only one observable, which is myList.

As a precautionary measure MultiValidator removes any internal observables which it uses from the list in order to avoid dependency loop.

Here is the issue. It maintains a observable named "targets' which is also a WritableList. Apparently this list is empty in the beginning. The code to remove internal observables from the list apparently removes myList because two empty lists are considered equal.

This is a snippet of revalidate() method in MultiValidator.
  // myList is added to newTargets
  List newTargets = new ArrayList(Arrays.asList(dependencies));
  
  targets.retainAll(newTargets);
  newTargets.removeAll(targets);
  newTargets.remove(validationStatus);
  newTargets.remove(unmodifiableValidationStatus);
  
  // Even though targets is not myList it gets removed because
  // Two empty list's equals method return true.
  ***newTargets.remove(targets);***
  
  newTargets.remove(unmodifiableTargets);
  newTargets.remove(models);


Is this a known issue? Or am I doing anything wrong.
Re: MultiValidator does not attach to empty IObservableList [message #488404 is a reply to message #487434] Mon, 28 September 2009 14:42 Go to previous messageGo to next message
Aniruddha Deshpande is currently offline Aniruddha DeshpandeFriend
Messages: 4
Registered: July 2009
Junior Member
There is already bug reported on this Bug 251003.
Re: MultiValidator does not attach to empty IObservableList [message #488486 is a reply to message #488404] Mon, 28 September 2009 20:57 Go to previous message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
Aniruddha, that bug is already marked as resolved. Which version of
data binding are you using?

Matthew

Aniruddha Deshpande wrote:
> There is already bug reported on this
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=251003.
Previous Topic:TreeViewer find node
Next Topic:[Databinding] ValueChangeListers on MultiValidator ValidationStatus don't fire
Goto Forum:
  


Current Time: Thu Nov 27 07:03:30 GMT 2014

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

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