[Databinding] How to bind Tree that contains nodes with different types. [message #331057] |
Fri, 22 August 2008 10:04 |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: ilya.khodyakov.gmail.com
Hi there,
I am trying to learn databinding and I have a following problem:
I have a model where bean contains same lists with different types, for
example:
Model.class as root.
-ParentNode1 (Parent.class)
-- Type1Nodes (list "types1" with Type1.class)
-- Type2Nodes (list "types2" with Type2.class)
-ParentNode2 (Parent.class)
-- Type1Nodes (list "types1" with Type1.class)
-- Type3Nodes (list "types3" with Type3.class)
How to write correct observable content provider for this Tree?
Now, I use ObservableListTreeContentProvider and create
ModelObservableFactory:
public class ModelObservableFactory implements IObservableFactory{
public ModelObservableFactory() {
super();
}
public IObservable createObservable(Object target) {
if( target instanceof Model ){
return BeansObservables.observeList(Realm.getDefault(),
target, "parents", Parent.class);
}else if( target instanceof Parent ){
// What should I write here to create IObservable for
"types1", "types2", "types3" ????
}else{
return new EmptyObservableList(Realm.getDefault(), null);
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.02877 seconds