Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Sorting an EList for serialization
Sorting an EList for serialization [message #1124536] Thu, 03 October 2013 16:37 Go to next message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 811
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

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 16:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Sorting an EList for serialization [message #1124551 is a reply to message #1124547] Thu, 03 October 2013 16:52 Go to previous message
Robert Brodt is currently offline Robert BrodtFriend
Messages: 811
Registered: August 2010
Location: Colorado Springs, CO
Senior Member

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: Thu Apr 25 21:45:30 GMT 2024

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

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

Back to the top