Find target EObject of an edge on delete action [message #1410264] |
Wed, 20 August 2014 04:45  |
Eclipse User |
|
|
|
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...
|
|
|
|
|
|
|
|
Re: Find target EObject of an edge on delete action [message #1413284 is a reply to message #1412064] |
Thu, 28 August 2014 03:56   |
Eclipse User |
|
|
|
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
|
|
|
Re: Find target EObject of an edge on delete action [message #1443863 is a reply to message #1413284] |
Mon, 13 October 2014 05:58   |
Eclipse User |
|
|
|
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?
|
|
|
Re: Find target EObject of an edge on delete action [message #1736775 is a reply to message #1443863] |
Fri, 01 July 2016 11:41  |
Eclipse User |
|
|
|
I had the same problem.
I managed to resolve it using the following structure (adapted to your question):
Begin
|_ Change Context var:element
|_ Unset (Feature Name = successors
Element Expression = aql:elementView.targetNode.target
Where succesors correspond to the [0..*] cardinality name and elementView corresponds to the given variable.
Target is used to access the semantic element of the graphical DNode
|
|
|
Powered by
FUDForum. Page generated in 0.03548 seconds