|
Re: Model element sort in a tree [message #1736525 is a reply to message #1736501] |
Thu, 30 June 2016 08:12 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
I think that you are mistaken in thinking that EMF is doing anything
very clever or helpful.
EMF collections are all lists, so what you see is 'chronological'
addition order.
In the case of your example for which you provide no models, I suspect
that typeA/typeB/typeC are in different child features that are shown
in, I think, metamodel feature order, ie. inheritance+chronological
order wrt the metamodel edit session..
If the order is important to you, you should make it part of your
design, rather than relying on accidental EMF functionality.
For graphics, the order is often irrelevant, so you might prefer to
define your collections as not-ordered, deferring imposition of order
until some save / transformation activity benefits from repeatability.
Regards
Ed Willink
On 29/06/2016 21:44, Alex Kravets wrote:
> I have EMF model that roughly looks like this:
>
> root
> --- typeA.1
> --- typeA.2
> --- typeB.1
> --- typeC.1
> --- typeC.2
> --- typeC.3
>
> if I were to add another element of typeA.3, it would be positioned
> between typeA.2 and typeB.1 - this is out of the box behavior that EMF
> generated editor offers and it's correct. How is the correct order
> kept when I am adding new element?
>
> The reason I am asking is that I am writing a Graphiti editor that
> graphically represents my model differently. Right now when I add new
> element typeA.3, as in the example above, it would be positioned below
> typeC.3, which is not correct ordering of the elements (according to
> EMF model). I can add comparator to the List that is used by Graphiti
> to layout the components, but I rather if possible reuse mechanism by
> which TreeViewer in EMF keeps elements sorted correctly.
>
> Thanks,
> Alex
|
|
|
|
Powered by
FUDForum. Page generated in 0.03524 seconds