Skip to main content



      Home
Home » Modeling » EMF » Sorting an EList for serialization
Sorting an EList for serialization [message #1124536] Thu, 03 October 2013 12:37 Go to next message
Eclipse UserFriend
Hi all,

I have a need to sort the objects in an EList feature in my model (for the purposes of limiting the number of forward references) prior to saving but I need to restore their original order immediately after the save is complete.

I've added a hack to save the original EList order, do the sort (using ECollections) and then restoring the EList contents using ECollections.setEList(). This seems to work, but is really ugly.

My question: is there support for doing this kind of thing in EMF core (similar to reordering features using XMLSaveImpl.Lookup), or do I need to use this ugly hack?

Thanks!
Bob
Re: Sorting an EList for serialization [message #1124547 is a reply to message #1124536] Thu, 03 October 2013 12:47 Go to previous messageGo to next message
Eclipse UserFriend
Bob,

No, there's nothing to support something like that directly. The
feature's value is fetched by
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getValue(EObject,
EStructuralFeature), so perhaps you hook into that to substitute a list
with a different order; be cause that the list must implement internal APIs.


On 03/10/2013 6:37 PM, Robert Brodt wrote:
> Hi all,
>
> I have a need to sort the objects in an EList feature in my model (for
> the purposes of limiting the number of forward references) prior to
> saving but I need to restore their original order immediately after
> the save is complete.
>
> I've added a hack to save the original EList order, do the sort (using
> ECollections) and then restoring the EList contents using
> ECollections.setEList(). This seems to work, but is really ugly.
>
> My question: is there support for doing this kind of thing in EMF core
> (similar to reordering features using XMLSaveImpl.Lookup), or do I
> need to use this ugly hack?
>
> Thanks!
> Bob
Re: Sorting an EList for serialization [message #1124551 is a reply to message #1124547] Thu, 03 October 2013 12:52 Go to previous message
Eclipse UserFriend
Thanks Ed. It looks like ECollections.setEList() was made for exactly this kind of thing Wink so I'll continue to use that.
Previous Topic:EMF Installation
Next Topic:EAnnotation Validation
Goto Forum:
  


Current Time: Tue Jul 22 20:43:11 EDT 2025

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

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

Back to the top