|
Re: Find target EObject of an edge on delete action [message #1410443 is a reply to message #1410264] |
Wed, 20 August 2014 19:40 |
|
Le 20/08/2014 10:45, Christian Pontesegger a écrit :
> I have a Node object with a [0..*] relationship to other Node Objects.
> Creating edges works fine. On the delete action I am using an "Unset".
> Now I am trying to write the according Element Expression.
>
> How can I get the target EObject related to my edge? I would love to
> have a variable pointing to that object...
See my answer to a related question at
https://www.eclipse.org/forums/index.php/mv/msg/800927/1410439/#msg_1410439
Basically we do not provide an explicit variable for this because in the
context in which the tool is evaluated (the DEdge instance), you can
simply follow the "target" reference to get the underlying semantic
EObject. [self.target/] using Acceleo, or feature:target use the raw
feature access for example.
--
Pierre-Charles David - Obeo
Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
|
|
|
Re: Find target EObject of an edge on delete action [message #1413284 is a reply to message #1412064] |
Thu, 28 August 2014 07:56 |
|
Hi Christian,
Le 25/08/2014 09:54, Christian Pontesegger a écrit :
> Still not there.
>
> Maybe I share some more info on my model. I have classes of type
> "Command". Each command has a [0..*] reference to other commands, called
> successors. Now I want to remove 1 successor from the list by deleting
> an edge.command element.
>
> So I do:
>
> Begin
> |_ Change Context var:element
> |_ Unset (Feature Name = "successors"; Element Expression =
> "[self.sourceNode.oclAsType(DNode).target/]")
After a change context, self corresponds to the new context, here you
have the semantic element corresponding to var:element, so
self.sourceNode is not a correct start (see my proposition at the end of
the message).
>
> With that expression I am not able to delete the edge. Still a strange
> thing happens: When my connection was altered regarding drawing (when I
> layouted it manually by moving the edge), it gets redrawn using the
> default routing style.
It seems that the delete tool has deleted the edge, but not the semantic
element, so the "auto-refresh" done on the diagram recreates the same
edge as the model allows it regarding the mapping definition and the
semantic model.
>
> Generally I find it hard to debug whats happening during such actions.
> Eg how do I find out, what variable "element" is all about. Is it the
> edge, the source, the draw object or the model object. I would love to
> see where my context is pointing to. But without information I am pretty
> lost
If you look at the screenshot attached by Fabien Vignal on the previous
message (<lt1n6g$ffc$1@xxxxxxxxe.org>), you will see the following
variables:
. element: the semantic element targeted by the selected diagram element
. elementView: the selected diagram element (an element of the Sirius
internal model: DNode, DEdge, DNodeContainer, DNodeList, DNodeListElement).
. containerView: the diagram container of the elementView (an element
of the Sirius internal model: DDiagram, DNode, DEdge, DNodeContainer,
DNodeList, DNodeListElement).
In your case, I think your edge represent the reference to other
commands: its sourceNode is a "Command A" and its targetNode is one of
its successors. I am pretty sure you are using a Relation Based Edge
Mapping: one consequence of this is that the semantic element of the
DEdge (the one you get with feature:target) should be the CommandA.
So if you want to design a delete tool on your "successor edge", I think
you should try:
Begin
|_ Change Context var:element
|_ Unset
(Feature Name = "successors";
Element Expression=
"[elementView.oclAsType(DEdge)
.targetNode.oclAsType(DNode).target/]")
Regards,
--
Maxime - Obeo
Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Maxime Porhel - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
Re: Find target EObject of an edge on delete action [message #1443863 is a reply to message #1413284] |
Mon, 13 October 2014 09:58 |
MG Gharib Messages: 30 Registered: September 2014 |
Member |
|
|
I have the same problem, and I couldn't sole it yet.
When I try to delete the relation between two nodes, all the similar relations disappears.
For example, 2 modeling constructs Roles and Agent, and the relation between them is "play", i.e., an agent can "play" a role. consider we have agent A that plays both role B and role C, if I want to delete the play relation between agent A and role B, not just role B will be deleted but also the "play" relation with role C, i.e., all the similar relations will be deleted.
Any suggestions?
|
|
|
|
Powered by
FUDForum. Page generated in 0.04773 seconds