Sorting an EList for serialization [message #1124536] |
Thu, 03 October 2013 16:37 |
|
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 |
Ed Merks 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/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03389 seconds