[DataBinding] FeaturePath for "many" features? [message #512232] |
Thu, 04 February 2010 13:14 |
Cyril Jaquier Messages: 80 Registered: July 2009 |
Member |
|
|
Hi all,
My model an "A" EClass which has an EReference "BList" (1..*). "A" has
also an EAttribute "AttrA". The "B" EClass has an EAttribute "AttrB".
A --> B -> AttrB
|-> B -> AttrB
`-> B -> AttrB
A --> B -> AttrB
|-> B -> AttrB
`-> B -> AttrB
Now I display all "A -> AttrA" in a TableViewer with an image in front
of each row. So far so good, the code below works perfectly.
....
IObservableSet set= cp.getKnownElements();
IObservableMap[] map= new IObservableMap[]{
EMFProperties.value(Package.Literals.A__ATTRA)
.observeDetail(set),
};
_viewer.setLabelProvider(new MyObservableMapLabelProvider(map));
....
Now I need to decorate the image a bit. The decoration depends on the
value of "B -> AttrB". My label provider receives an instance of "A",
iterates over the "BList", looks at "AttrB" and can return the right
decoration.
The problem is that my label provider should be notified when either
"BList" or "AttrB" change. I have try to use FeaturePath (see below) but
it does not work because "BList" is multi-valued.
....
IObservableSet set= cp.getKnownElements();
IObservableMap[] map= new IObservableMap[]{
EMFProperties.value(Package.Literals.A__ATTRA)
.observeDetail(set),
EMFProperties.value(FeaturePath.fromList(
Package.Literals.A__BLIST,
Package.Literals.B__ATTRB))
.observeDetail(set)
};
_viewer.setLabelProvider(new MyObservableMapLabelProvider(map));
....
I also try something like:
IObservableList list= EMFProperties.list(Package.Literals.A__BLIST)
.observeDetail(set /* does not compile */);
IObservableValue value = EMFProperties.value(Package.Literals.B__ATTRB)
.observeDetail(list);
But IEMFListProperty can only observe an IObservableValue and not e.g.
IObservableSet (would that make sense?).
I don't see any simple solutions to this but as I'm new to all these
things, I may have missed something. Any suggestions?
Thank you.
Cyril
|
|
|
|
Powered by
FUDForum. Page generated in 0.02680 seconds