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 12:37 Go to next message
Robert Brodt is currently offline Robert Brodt
Messages: 539
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 12:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25747
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
Re: Sorting an EList for serialization [message #1124551 is a reply to message #1124547] Thu, 03 October 2013 12:52 Go to previous message
Robert Brodt is currently offline Robert Brodt
Messages: 539
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: Sun Apr 20 02:56:18 EDT 2014

Powered by FUDForum. Page generated in 0.03698 seconds