Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Element order inside compartments
Element order inside compartments [message #1017830] Tue, 12 March 2013 16:01 Go to next message
Florian W. is currently offline Florian W.Friend
Messages: 15
Registered: January 2013
Junior Member
Hi,

I have created an Ecore model from an XML schema. Now I am trying to build an Editor for this model using GMF. Most things already work fine. But now, I got stuck with the following problem:

The model contains a class referencing a set of other classes. This corresponds to the following structure in the original XML schema:

<xsd:element name="a">
  <xsd:complexType>
    <xsd:sequence maxOccurs="unbounded">
      <xsd:group ref="elementgroup" />
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

<xsd:group name="elementgroup">
  <xsd:choice>
    <xsd:element name"element1" ... />
    <xsd:element name"element2" ... />
    <xsd:element name"element3" ... />
  </xsd:choice>
</xsd:group


The class created for element "a" corresponds to a node in the diagram editor. I would like to display the members of the group inside this node. I have already created a compartment displaying the elements defined in the group. However, they are not displayed in the order as they appear in the XML file. Instead, they are grouped by type and the order is defined by the order of the child references in the mapping model.

For example, if the imput file has the following structure ...

<a>
  <element1 />
  <element3 />
  <element1 />
  <element2 />
</a>


... the list in the comparment will look like this:

element1
element1
element2
element3


How can I preserve the original order of the elements as they appear in the XML input file?

[Updated on: Tue, 12 March 2013 16:02]

Report message to a moderator

Re: Element order inside compartments [message #1018148 is a reply to message #1017830] Wed, 13 March 2013 09:07 Go to previous messageGo to next message
Thomas Beyer is currently offline Thomas BeyerFriend
Messages: 55
Registered: February 2013
Member
Hi Florian,

maybe you simply want to change the order of your children inside the compartment?
See http://wiki.eclipse.org/Graphical_Modeling_Framework/Recipes

A brief description, why your compartment-entries (I believe you are talking about your domain elements though) are sorted the way they are:
GMF strictly seperates the notation model from the domain model.
In the domain model, you could have several distinct containment features, like
Parent 
 -> boys:Child
 -> girls:Child

EMF will sort the features by their name, always! So no matter how you many girls, or boys you will create in any order, the boys feature will always be serialized before the girls-feature.
If you do not like this, abstract the boys and girls feature to "children" and you can have any order, you like.
So your domain model can distinguish between the child relations boys and girls.

The notation model "only" knows views, and only one containment-feature for its children. So here is already the abstraction, that gives you free sorting of the elements.

This means, that your graphical representation (the notation model) can actually have a different element order than the corresponding domain-elements.

Regards
Thomas
Re: Element order inside compartments [message #1018162 is a reply to message #1018148] Wed, 13 March 2013 09:37 Go to previous messageGo to next message
Florian W. is currently offline Florian W.Friend
Messages: 15
Registered: January 2013
Junior Member
Hi Thomas,

thanks for your reply! I definitely do not want to change the order of the elements inside the compartment (at least not now).

I have already created the standard EMF editor. The tree view of this editor displays elements exactly in the same order as they appear in the underlying XML document. I would also like to have this order for my compartment. And in general, this seems to work! I have already defined a compartemt for another part of the XML document and the items in this compartment are displayed in serialization order by default.

The problem in the example from my first post seems to be that the children of the compartment do not correspond to the same domain element. This makes it necessary to define multiple child references in the mapping model. This again seems to cause the items to be grouped by type (as shown in my example) in the compartment. But I would like them to appear in serialization order.

I hope that this clarifies my problem a bit. Please excuse me if my explanation is a bit weird but I have started with GMF only a short time ago ...

Regards,

Florian

[Updated on: Wed, 13 March 2013 09:38]

Report message to a moderator

Re: Element order inside compartments [message #1018246 is a reply to message #1018162] Wed, 13 March 2013 13:38 Go to previous messageGo to next message
Thomas Beyer is currently offline Thomas BeyerFriend
Messages: 55
Registered: February 2013
Member
Hi Florian,

a GMF-compartment does not (resp. its underlying notation element) group anything by default, since it does not know another relationship containment-relationship than children -> View.
So how you map your view to your domain element, is not known to the compartment.

However, you could use a ListCompartment (maybe you are already), that allows for the following sortings of its notation elements:
- none, no sorting
- automatic, which I believe synchronizes the order according to the order of the domain elements
- manual, where you can explicitely define the position of each child.
You can also filter elements, if you like.

However, this is just modifying the display of the elements in a sorted manner. The underlying notation-element order is not changed.

If that suits, what you need, check your generated XXXViewProvider to find out, how the compartment is created. This would be your entry-point for modification, if sorting is what you want.

Regards
Thomas

Re: Element order inside compartments [message #1018321 is a reply to message #1018246] Wed, 13 March 2013 16:00 Go to previous message
Florian W. is currently offline Florian W.Friend
Messages: 15
Registered: January 2013
Junior Member
Hi Thomas,

thanks for your kind help. I fully agree with you that there is no sorting of diagram elements belonging to the same domain element. However, the compartment contains elements belonging to different domain elements. In my initial example these domain elements where "element1", "element2" and "element3". In my Ecore model all domain elements which I want to be displayed in the compartement have a common base class. However, I had to define a node reference for every single subclass (i. e. element1, element2, element3). I created the compartment as shown in the mindmap tutorial. The node to which the compartment belongs is a container for objects of type element1, element2, element3. In ecore this containment relationship is represented with a feature map and EList-getters for the different structural features in this map. As GMF only allows me to create mappings to these getters and not to the map, the comparment displays all contents of the container but not in the same order as they are stored in the feature map. However, I need a one-to-one realationship: The display order of the elemnts in GMF has to correspond to the order one gets when iterating over the feature map.

Regards,

Florian
Previous Topic:GMF not shows diagnostic messages after validation
Next Topic:ERROR IN GMF
Goto Forum:
  


Current Time: Thu Mar 28 08:17:02 GMT 2024

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

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

Back to the top