Skip to main content



      Home
Home » Eclipse Projects » Sirius » How to add nodes to containers via layers?
icon5.gif  How to add nodes to containers via layers? [message #1732168] Fri, 13 May 2016 04:07 Go to next message
Eclipse UserFriend
In my default layer, I have a container X with some inner elements (border nodes, sub nodes, sub containers). In a second layer, I want to put additional elements into container X without having the original inner elements disappear.

I managed this already to a great extend by using a "container import" on the second layer ("Imported mapping": container X; same "Domain Class" and "Semantic Candidates Expression" than for container X) and attaching my additional elements to the container import. If I also set the "Reused Node/Container/Border Node Mappings" to the elements container X includes, mostly everything looks like I wanted in the resulting editor.

Still, I have some issues and questions with that solution:

1) Is this the way to go to define layers that attach additional elements to containers?
It appears to be quite bad that I have to specify reused mappings as this can turn into a maintenance hell (whenever I add new elements to the default layer, I would have to update the second layer as well). A default like "reuse everything" would be way better for my use-case.

2) I used a custom style for border nodes of my container X. The second layer seems to ignore this custom style and does not visualize the reused border nodes correctly. Is that a bug?

[Updated on: Sat, 14 May 2016 06:06] by Moderator

Re: Additional nodes to containers via layers [message #1732468 is a reply to message #1732168] Tue, 17 May 2016 10:04 Go to previous messageGo to next message
Eclipse UserFriend
Hi Sebastien,

Firstly I want explain you how work these 2 Sirius behaviors:

- The Container Import work as a super Class. The container imported is
the "super class" and the mapping Container Import is the "herited
class". This behavior is used when you want redifine existing mapping.

- The reused mapping work as a reused Object. The context must be the
same as define in the mapping reused.

In your case I think you don't have need to use the Container Import.
You can find attached an example as you want to do.

I just used the reused node mapping. In my example I use Ecore metamodel
and I want to display packages that contain classes that contain
references. With the second layer I want to display attributes contained
in the class.

I defined the mapping for attributes in the second Layer and I reused
this in the class mapping.

Regards,
--
Julien - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Additional nodes to containers via layers [message #1732679 is a reply to message #1732468] Thu, 19 May 2016 02:39 Go to previous messageGo to next message
Eclipse UserFriend
Thank you Julien, that clarifies already a lot. Still, I have one issue left:

My reused element from the second layer includes a "Semantic Candidates Expression" of the form "[self. ... /]". Before I moved the element to the second layer, "self" used to refer to the container. With the reused mapping solution, the context of self is however not this container.

In your example, "Attributes" use the expression "feature:eAttributes". This expression is actually evaluated in the context of the container ("Class" in you case). If you use a "[self. ... /]" expression in your example, the context moves to "Package". Why isn't that the same behavior as for "feature:eAttributes"?
Re: Additional nodes to containers via layers [message #1734660 is a reply to message #1732679] Fri, 10 June 2016 04:27 Go to previous message
Eclipse UserFriend
Hi Sebastien,

Le 19/05/2016 à 08:39, Sebastian Lehrig a écrit :
> Thank you Julien, that clarifies already a lot. Still, I have one issue
> left:
>
> My reused element from the second layer includes a "Semantic Candidates
> Expression" of the form "[self. ... /]". Before I moved the element to
> the second layer, "self" used to refer to the container. With the reused
> mapping solution, the context of self is however not this container.

For a mapping, the context of self is the domain class of the parent
mapping or diagram description for root mappings.

>
> In your example, "Attributes" use the expression "feature:eAttributes".
> This expression is actually evaluated in the context of the container
> ("Class" in you case).

In the provided sample, the mapping is defined as children of the
Attributes Layer but also reused from the Class mapping. Sirius will
evaluate it in to situations: as a root mapping on the diagram targeting
an EPackage: it will produce nothing as the feature eAttributes will not
be found on this concept and then it will be evaluated as a resued
mapping from the Class mapping, this time it will find elements if the
current EClass has some attributes defined.

If you use a "[self. ... /]" expression in your
> example, the context moves to "Package". Why isn't that the same
> behavior as for "feature:eAttributes"?

If you use feature: and call the completion proposal, you will see that
eAttributes is not proposed. The context is EPackage as it is the domain
class of the diagram description and the Attributes mapping it a root
mapping. The completion proposal computation does not take into account
the "reuse" locations.

The provided sample is not a valid VSM, if you launch the validation it
will indicate that the ecore::EPackage class does not have the feature
named eAttributes.
But it shows you that you can define a mapping somewhere and reuse it
correctly from another place and that you have to do that carefully to
be sure it will be valid on all places in which you want it to produce
some result. If you define/reuse it from mappings with different domain
class, you can use a more complex query or Java service to do a semantic
candidate expression which will handle both cases.

>

Regards,

--
Maxime - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:add an action to submenu
Next Topic:Sirius with JDT
Goto Forum:
  


Current Time: Sat Mar 15 00:19:57 EDT 2025

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

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

Back to the top