Proper way to reflectively add/remove value from multi-valued feature? [message #416670] |
Mon, 11 February 2008 22:50 |
Eclipse User |
|
|
|
Originally posted by: struck.stottlerhenke.com
Are there equivalent methods to eSet for adding and removing values from
an object's multi-valued feature (i.e. a feature that returns true for
isMany)? I know that I can do something along the lines of:
AdeptObject aObj = ...
EStructuralFeature esf = aObj.eClass().getEStructuralFeature(...);
if(esf.isMany()) {
EList<Object> list = (EList<Object>)aObj.eGet(esf);
list.add(...);
}
But if I attach a listener to the object, will the listener be notified of
a change when this occurs?
Thanks,
David
|
|
|
Re: Proper way to reflectively add/remove value from multi-valued feature? [message #416671 is a reply to message #416670] |
Tue, 12 February 2008 00:10 |
David Steinberg Messages: 489 Registered: July 2009 |
Senior Member |
|
|
Hi David,
Yup, you're proposing to do it the right way. Simply obtain the list via
eGet() and then manipulate it directly. The list is instrumented to send
notifications, just like in the generated case.
As a convenience, you can also call eSet(), passing in a list. However,
under the covers, that just obtains the feature's list, clears it, and
adds the items in the list you specified.
Cheers,
Dave
David Struck wrote:
> Are there equivalent methods to eSet for adding and removing values from
> an object's multi-valued feature (i.e. a feature that returns true for
> isMany)? I know that I can do something along the lines of:
>
> AdeptObject aObj = ...
> EStructuralFeature esf = aObj.eClass().getEStructuralFeature(...);
> if(esf.isMany()) {
> EList<Object> list = (EList<Object>)aObj.eGet(esf);
> list.add(...);
> }
>
> But if I attach a listener to the object, will the listener be notified
> of a change when this occurs?
>
> Thanks,
>
> David
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03020 seconds