Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 21:57 Go to next message
Endre Balogh is currently offline Endre BaloghFriend
Messages: 38
Registered: May 2010
Member
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 07:58 Go to previous messageGo to next message
Thomas Beyer is currently offline Thomas BeyerFriend
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
Re: retrieve the emf resource from the diagram currently edited [message #539638 is a reply to message #539524] Fri, 11 June 2010 15:02 Go to previous message
Endre Balogh is currently offline Endre BaloghFriend
Messages: 38
Registered: May 2010
Member
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: Sat Jul 27 01:37:03 GMT 2024

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

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

Back to the top