Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » retrieve the emf resource from the diagram currently edited
retrieve the emf resource from the diagram currently edited [message #539479] Thu, 10 June 2010 17:57 Go to next message
Eclipse UserFriend
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
Re: retrieve the emf resource from the diagram currently edited [message #539524 is a reply to message #539479] Fri, 11 June 2010 03:58 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: retrieve the emf resource from the diagram currently edited [message #539638 is a reply to message #539524] Fri, 11 June 2010 11:02 Go to previous message
Eclipse UserFriend
Hi Thomas,

Thanks for the tip, the following:

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDiagramWorkbenchPart diagramPart = (IDiagramWorkbenchPart)page.getActiveEditor();
ModelEditPart editPart = (ModelEditPart) diagramPart.getDiagramEditPart();


did solve my problem.

Cheers,
Endre
Previous Topic:Un Set Command
Next Topic:Problems on using GMF generated Editor
Goto Forum:
  


Current Time: Tue Jul 01 12:02:02 EDT 2025

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

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

Back to the top