|
Re: retrieve the emf resource from the diagram currently edited [message #539524 is a reply to message #539479] |
Fri, 11 June 2010 07:58 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Thomas Beyer![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=thomas.beyer.external%40eads.com) Messages: 93 Registered: July 2009 |
Member |
|
|
Hi Andre,
an easy way to retrieve the editingdomain from the currently active
diagram (be sure, it is active) could be as follows:
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
(IDiagramWorkbenchPart) diagramPart = (IDiagramWorkbenchPart)
page.getActiveEditor();
IDiagramEditDomain domain = diagramPart.getDiagramEditDomain();
From the IDiagramWorkbenchPart you can also retrieve the
DiagramEditPart and its contained children.
Make sure to add proper instanceof and null checks, if you cannot assure
he correctness of the cast to the IDiagramWorkbenchPart.
HTH,
Thomas
On 10.06.2010 23:57, Endre Balogh wrote:
> Hi,
>
> I need to retrieve the EMF resource from the diagram currently being
> edited. I got an earlier tip to do this via calling
> resolveSemanticElement on one of the edit parts generated by GMF and
> then call eResource on the returned EObject:
>
> final Resource resource = yourEditPart.resolveSemanticElement().eResource;
>
> But I'm quite new to GMF (as in, I have only used its high level
> functions, and have never got this deep into directly working with java
> code), and I don't quite know how to do this (as in, how do I get the
> desired editpart).
> The code will be invoked from a wizard created using Epsilon Wizard
> Language.
>
> Any tips on how to do this would be appreciated (using the presented
> approach or any other way to do it), but please specify full source code.
>
> Cheers,
> Endre
|
|
|
|
Powered by
FUDForum. Page generated in 0.03051 seconds