Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » [databinding] ObservableTreeContentProvider and WritableList used together?(There is any possibility to use together ObservableTreeContentProvider and WritableList?)
icon5.gif  [databinding] ObservableTreeContentProvider and WritableList used together? [message #522673] Tue, 23 March 2010 14:59 Go to next message
Marco Vettorello is currently offline Marco VettorelloFriend
Messages: 4
Registered: March 2010
Junior Member
Hello everybody,

I'm working in a project where we currently want need to provide a simple view in form of tree of a WritableList.

Since I start using WritableList and TableViewer there was no problem using the ObservableListContentProvider.

Now, that i need to use a TreeViewer, I have problem with the respective ObservableTreeContentProvider.
It need 2 the implementation of an ObservableFactory and a TreeSctureAdvisor.

Inside the WritableList I have either parents and childrens all toghether and at the moment I can't change the implementation of this list.

I really can't understand how to implement the ObservableFactory having this WritableList as unique a model.

Somebody can help me?
Thanks

Marco

[Updated on: Tue, 23 March 2010 15:00]

Report message to a moderator

Re: ObservableTreeContentProvider and WritableList used together? [message #523350 is a reply to message #522673] Fri, 26 March 2010 05:03 Go to previous messageGo to next message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
I'm guessing you're having a problem using the WritableList as both the
input and the IObservableList for the root nodes. You can get around
this by checking whether the element is the input and returning a new
WritableList that is bound to the input.

final DataBindingContext bindingContext = ...
final WritableList input = ...

IObservableFactory childrenFactory = new IObservable() {
public IObservable createObservable(Object element) {
if (element==input) {
IObservableList rootElements = new WritableList();
bindingContext.bindList(rootElements, input);
return rootElements;
}
return BeanProperties.list("children").observe(element);
}
};

Does this help?

Matthew

Marco Vettorello wrote:
> Hello everybody,
>
> I'm working in a project where we currently want need to provide a
> simple view in form of tree of a WritableList.
>
> Since I start using WritableList and TableViewer there was no problem
> using the ObservableListContentProvider.
>
> Now, that i need to use a TreeViewer, I have problem with the respective
> ObservableTreeContentProvider.
> It need 2 the implementation of an ObservableFactory and a
> TreeSctureAdvisor.
>
> Inside the WritableList I have either parents and childrens all
> toghether and at the moment I can't change the implementation of this list.
>
> I really can't understand how to implement the ObservableFactory having
> this WritableList as unique a model.
>
> Somebody can help me?
> Thanks
>
> Marco
Re: ObservableTreeContentProvider and WritableList used together? [message #523404 is a reply to message #523350] Fri, 26 March 2010 10:32 Go to previous messageGo to next message
Marco Vettorello is currently offline Marco VettorelloFriend
Messages: 4
Registered: March 2010
Junior Member
Dear Matthew,

Thanks so much for your help, this partially solve my problem.
your solution put a light on my darkness onside the IObservableFactory.

I managed to change a little bit my Model separating parents and leafs, using inside each parents a WritableList for the children like this:

public IObservable createObservable(final Object element){
  if (element instanceof WritableList) { //parents
    return ModelProvider.getInstance().getGateways(); //writableList
  }
  else if (element instanceof Gateway) { //childrens
    return ((Gateway)element).getChilds(); //writablelist
  }
  return BeanProperties.list("children").observe(element);
 }


This solve my problem on the IObservableFactory, looking for elements and returning childrens WritableList or parents WritableList.

However, did you think I really neccessary to bind my model WritableList to a new one inside the IObservableFactory, or i ca just return my model WritableList?
Thanks for your help!

Marco

[Updated on: Fri, 26 March 2010 10:34]

Report message to a moderator

Re: ObservableTreeContentProvider and WritableList used together? [message #523591 is a reply to message #523404] Fri, 26 March 2010 22:54 Go to previous message
Matthew Hall is currently offline Matthew HallFriend
Messages: 368
Registered: July 2009
Senior Member
The only thing for sure is that you shouldn't

Marco Vettorello wrote:
> However, did you think I really neccessary to bind my model WritableList
> to a new one inside the IObservableFactory, or i ca just return my model
> WritableList?

You can try it, I seem to remember there being a problem doing that, but
I don't remember what it was. Give it a try, let me know if it works
for you.

Matthew
Previous Topic:API Breakage(-ish) in 3.6 M6 ?
Next Topic:[DataBinding] JFace Databinding with JavaAgent to avoid coding PropertyChangeSupport into bean
Goto Forum:
  


Current Time: Fri Apr 19 02:43:12 GMT 2024

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

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

Back to the top