Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Getting Mapped Model
Getting Mapped Model [message #89935] Fri, 05 January 2007 23:01 Go to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

I am trying to write my own "tool" with GMF that affects elements in my
EMF model. I have created a Generic Tool, and set the class to a
subclass of a GEF tool. Now this works well, and I get the proper GEF
requests, etc...

Now when I button is pressed I need to get the EMF model element mapped
to that editpart. The edit part is correct, but getModel() returns a
NodeImpl (an GMF class) not the EMF model element I have mapped to this
edit part. Is there a way to get the EMF model element that was mapped
to a particular edit part? There must be a way since GMF is doing it
all over the place.

cheers,
ian
Re: Getting Mapped Model [message #89951 is a reply to message #89935] Sat, 06 January 2007 01:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: reneschm.cs.tu-berlin.de

Hi Ian,
maybe this is what you are looking for?
/**
* Gets the semantic element associated to this editpart's view.
* @return the semantic element or <code>null</code> if the semantic
element was
* <code>null</code> or unresolvable
*/
public EObject resolveSemanticElement();

its from the IGraphicalEditPart Interface in
oeg.runtime.diagram.ui.editparts

cheers,

Rene Schmutzler
TU Berlin - Tiger Team

Ian Bull schrieb:
> I am trying to write my own "tool" with GMF that affects elements in my
> EMF model. I have created a Generic Tool, and set the class to a
> subclass of a GEF tool. Now this works well, and I get the proper GEF
> requests, etc...
>
> Now when I button is pressed I need to get the EMF model element mapped
> to that editpart. The edit part is correct, but getModel() returns a
> NodeImpl (an GMF class) not the EMF model element I have mapped to this
> edit part. Is there a way to get the EMF model element that was mapped
> to a particular edit part? There must be a way since GMF is doing it
> all over the place.
>
> cheers,
> ian
Re: Getting Mapped Model [message #89966 is a reply to message #89951] Sat, 06 January 2007 04:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

Thanks so much!

I also found getElement on the node model.

((View)getTargetEditPart().getModel()).getElement())

Not sure what the difference is. The one you found seems to do a few
more checks.

Cheers,
Ian


Threne schmutzler wrote:
> Hi Ian,
> maybe this is what you are looking for?
> /**
> * Gets the semantic element associated to this editpart's view.
> * @return the semantic element or <code>null</code> if the semantic
> element was
> * <code>null</code> or unresolvable
> */
> public EObject resolveSemanticElement();
>
> its from the IGraphicalEditPart Interface in
> oeg.runtime.diagram.ui.editparts
>
> cheers,
>
> Rene Schmutzler
> TU Berlin - Tiger Team
>
> Ian Bull schrieb:
>> I am trying to write my own "tool" with GMF that affects elements in
>> my EMF model. I have created a Generic Tool, and set the class to a
>> subclass of a GEF tool. Now this works well, and I get the proper GEF
>> requests, etc...
>>
>> Now when I button is pressed I need to get the EMF model element
>> mapped to that editpart. The edit part is correct, but getModel()
>> returns a NodeImpl (an GMF class) not the EMF model element I have
>> mapped to this edit part. Is there a way to get the EMF model element
>> that was mapped to a particular edit part? There must be a way since
>> GMF is doing it all over the place.
>>
>> cheers,
>> ian
Re: Getting Mapped Model [message #90070 is a reply to message #89966] Sat, 06 January 2007 17:15 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Ian,

> ((View)getTargetEditPart().getModel()).getElement())
Is a proper way.

-----------------
Alex Shatalin
Previous Topic:GMF and Extended EMF Models
Next Topic:TreeView and PropertySheet
Goto Forum:
  


Current Time: Wed Feb 05 06:57:49 GMT 2025

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

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

Back to the top