java - BeanProperties.list().observe() does not propagate ListChangeEvent -
i have data
class contains observable list of items:
public class data { private final iobservablelist items = writablelist.withelementtype(item.class); public iobservablelist getitems() { return items; } }
when bind directly items fine:
data.addlistchangelistener(mylistener); //ok
but when bind items via beanproperties.list()
listchangeevent
not propagated
beanproperties.list(data.class, "items", item.class). observe(data).addlistchangelistener(mylistener); //not working
my goal automatically add rows (and remove from) tree.
realm realm = swtobservables.getrealm(composite.getdisplay()); ilistproperty listproperty = beanproperties.list(data.class, "items", item.class); iobservablefactory observablefactory = listproperty.listfactory(realm); observablelisttreecontentprovider contentprovider = new observablelisttreecontentprovider(observablefactory, null); treeviewer.setcontentprovider(contentprovider);
it seems beanproperties
not expect property iobservablelist
. have implemented own observablelistproperty
. works only properties of iobservablelist
type.
public class observablelistproperty extends listproperty { private final propertydescriptor propertydescriptor; private final class elementtype; public observablelistproperty(class beanclass, string propertyname) { this(beanclass, propertyname, null); } public observablelistproperty(class beanclass, string propertyname, class elementtype) { propertydescriptor = beanpropertyhelper.getpropertydescriptor(beanclass, propertyname); if (elementtype == null) { elementtype = beanpropertyhelper.getcollectionpropertyelementtype(propertydescriptor); } this.elementtype = elementtype; } @override public object getelementtype() { return elementtype; } @override public iobservablelist observe(realm realm, object source) { iobservablelist list = (iobservablelist)beanpropertyhelper.readproperty(source, propertydescriptor); return new decoratingobservablelist(list, false); } }
Comments
Post a Comment