Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Find target EObject of an edge on delete action
Find target EObject of an edge on delete action [message #1410264] Wed, 20 August 2014 08:45 Go to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 250
Registered: July 2009
Location: Graz, Austria
Senior Member
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 #1410443 is a reply to message #1410264] Wed, 20 August 2014 19:40 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 701
Registered: July 2009
Senior Member
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 #1410709 is a reply to message #1410443] Thu, 21 August 2014 12:40 Go to previous messageGo to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 250
Registered: July 2009
Location: Graz, Austria
Senior Member
Thanks for the reply. I did indeed try my luck with the target. Unfortunately the target of a DEdge points to the source object. Now if the source has a [0..*] relationship there is no way for me to find the correlating target EObject.

So far I have tried to use a
Change context var:self / Unset(Feature Name = "child", Element Expression = "?")

[self.target/] obviously does not work here.

Also tried to use [self.semanticElements/] but regarding the Model requests interpreter view the result is empty.

I'm really lost here.
Re: Find target EObject of an edge on delete action [message #1410754 is a reply to message #1410709] Thu, 21 August 2014 14:36 Go to previous messageGo to next message
Emmanuel Billaud is currently offline Emmanuel BillaudFriend
Messages: 3
Registered: August 2014
Junior Member
I just tried this, and it works fine for me (self is a DEdge in my case) :
[self.targetNode.oclAsType(DNode).target/]
[self.sourceNode.oclAsType(DNode).target/]

Does it solve your problem ?
Re: Find target EObject of an edge on delete action [message #1411194 is a reply to message #1410264] Fri, 22 August 2014 16:29 Go to previous messageGo to next message
Fabien Vignal is currently offline Fabien VignalFriend
Messages: 1
Registered: August 2014
Junior Member
Hi,

I have the same problem with my model. I wanted to unset a property of the edge's target element but targetNode also returns the source node.

I had to chain the Change Context element to obtain the correct node.

index.php/fa/18921/0/


Hope this will help.
Re: Find target EObject of an edge on delete action [message #1412064 is a reply to message #1411194] Mon, 25 August 2014 07:54 Go to previous messageGo to next message
Christian Pontesegger is currently offline Christian PonteseggerFriend
Messages: 250
Registered: July 2009
Location: Graz, Austria
Senior Member
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/]")


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.

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
Re: Find target EObject of an edge on delete action [message #1413284 is a reply to message #1412064] Thu, 28 August 2014 07:56 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
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 Go to previous messageGo to next message
MG Gharib is currently offline MG GharibFriend
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?
Re: Find target EObject of an edge on delete action [message #1736775 is a reply to message #1443863] Fri, 01 July 2016 15:41 Go to previous message
Mario CC is currently offline Mario CCFriend
Messages: 6
Registered: April 2016
Junior Member
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
Previous Topic:Problem in diagram navigation
Next Topic:Autoresize compartment
Goto Forum:
  


Current Time: Thu Mar 28 13:51:11 GMT 2024

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

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

Back to the top