Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Proper way to reflectively add/remove value from multi-valued feature?
Proper way to reflectively add/remove value from multi-valued feature? [message #416670] Mon, 11 February 2008 22:50 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
David Steinberg is currently offline David SteinbergFriend
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
>
Re: Proper way to reflectively add/remove value from multi-valued feature? [message #417074 is a reply to message #416671] Mon, 25 February 2008 21:00 Go to previous message
Eclipse UserFriend
Originally posted by: struck.stottlerhenke.com

Thanks Dave, I appreciate the help.
Previous Topic:How to access EList template type at runtime
Next Topic:Getting the Resource.Factory from the EPackage
Goto Forum:
  


Current Time: Fri Apr 26 19:12:04 GMT 2024

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

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

Back to the top