|
|
|
|
Re: How to access an EObject's position and size? [message #1834280 is a reply to message #1834276] |
Fri, 06 November 2020 11:41 |
Yufei Zhou Messages: 44 Registered: March 2020 |
Member |
|
|
Hi Anthony,
This is my previous post, where I described my need that I hope to copy&paste an EObject while keeping its layout. I'm finding internal apis to implement it but met some difficulties.
https://www.eclipse.org/forums/index.php/t/1105696/
What I really want to do is let my user choose a device(by typing its name in a textfield so I can find it) and input a location, then the application will place the device to that location. I've finished the first step(choose a device), so I have a Device EObject right now, and I'm finding a method to get and set the Device EObject's location. In other words, I hope to find an api to access a semantic eobject's graphical data.
I don't know if I explained myself well, sorry for the bad English. Thanks very much for your help Anthony, I will appreciate it if you can give me some further information. Any advice would be helpful.
Kindly Regards,
Yufei Zhou
|
|
|
|
|
Re: How to access an EObject's position and size? [message #1834445 is a reply to message #1834322] |
Tue, 10 November 2020 13:37 |
|
Hi,
I already gave you the pointers to crossreferencer in previous comment.
The code should be something like (untested code just written for easy understanding):
Collection<EObject> targetReferences = eObjectQuery.getInverseReferences(ViewpointPackage.Literals.DSEMANTIC_DECORATOR__TARGET);
for (EObject targetReference : targetReferences) {
if (targetReference instanceof DDiagramElementContainer) {
// or (targetReference instanceof DNode) if the expected element is a Node (use a NodeMapping and not a ContainerMapping)
EObjectQuery dDiagElementQuery = new EObjectQuery((DDiagramElementContainer) targetReference);
Collection<EObject> elementReferences = dDiagElementQuery.getInverseReferences(NotationPackage.Literals.VIEW__ELEMENT);
for (EObject elementReference : elementReferences) {
if (elementReference instanceof org.eclipse.gmf.runtime.notation.Node) {
//Do someting with GMF Node
}
}
}
}
Regards,
Laurent
Laurent Redor - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03372 seconds