Home » Eclipse Projects » Sirius » Quick question: Retrieving View eObject
Quick question: Retrieving View eObject [message #1731462] |
Thu, 05 May 2016 11:00  |
Eclipse User |
|
|
|
Hello there,
For element creation tools, specifically for edge creation, there is always two variables: sourceView and targetView that refers to the graphical element of, respectively, source and target. I am navigating through these elements, but I would like to, at some point, access the eObject it represents.
According to some forum topics and tutorials, there is a "target" field or method that retrieves this element, but as I try to use it, Sirius tells me there is no field (target) or method (target(), getTarget()). I believe I have to cast to a specific type (using oclAsType method) to be able to access it, but which type?
My expression, for now:
[sourceView.eContainer().eContainer().getTarget()/], whereas sourceView.eContainer().eContainer() is the diagram itself.
@Edit
For my specific case, I cannot navigate using source and target variables, since their eContainer() is an eObject that is part of another diagram.
[Updated on: Thu, 05 May 2016 11:13] by Moderator
|
|
|
Re: Quick question: Retrieving View eObject [message #1731788 is a reply to message #1731462] |
Tue, 10 May 2016 03:39   |
Eclipse User |
|
|
|
On 05/05/2016 05:00 PM, Eduardo Silva wrote:
> Hello there,
Hi,
>
> For element creation tools, specifically for edge creation, there is
> always two variables: sourceView and targetView that refers to the
> graphical element of, respectively, source and target. I am navigating
> through these elements, but I would like to, at some point, access the
> eObject that it represents.
>
> According to some forum topics and tutorials, there is a "target" field
> or method that retrieves this element, but as I try to use it, Sirius
> tells me there is no field (target) or method (target(), getTarget()). I
> believe I have to cast to a specific type (using oclAsType method) to be
> able to access it, but which type?
>
> My expression, for now:
> [sourceView.eContainer().eContainer().getTarget()/], whereas
> sourceView.eContainer().eContainer() is the diagram itself.
If you are sure about the expected type you can cast (with oclAsType)
the eContainer() result to DSemanticDecorator which is the interface for
all DDiagramElements with a semantic target.
Regards,
--
Florian - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
Re: Quick question: Retrieving View eObject [message #1731905 is a reply to message #1731788] |
Tue, 10 May 2016 14:25  |
Eclipse User |
|
|
|
DSemanticDecorator worked fine. DNode also worked, in this case.
Thanks.
@Edit
Is there any way to retrieve the DDiagram for the current diagram from any context? Just like Like var:diagram, but in an edge creation tool, for instance.
[Updated on: Tue, 10 May 2016 15:26] by Moderator
|
|
|
Goto Forum:
Current Time: Sun Mar 23 21:11:18 EDT 2025
Powered by FUDForum. Page generated in 0.02712 seconds
|