Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Getting back model elements
Getting back model elements [message #120625] Thu, 19 April 2007 06:20 Go to next message
Eclipse UserFriend
Originally posted by: bagnard.natacha.free.fr

Hi,
I'm new to GMF and I'm trying to find how to get back my model elements
because I want to know how many instances of each one I've already made
and be able to get attributes values for each too.
I use the modelFactory for create them, but it has no methods to get
them back ... And I haven't find where it is.

Does someone know how I could do that ?

Thanks,

Natacha
Re: Getting back model elements [message #120638 is a reply to message #120625] Thu, 19 April 2007 06:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evaandoli.dodo.com.au

So can I guess:-
When you create a 'Node' on the diagram you wish to see what other objects
have been created and set certain attributes depending on what you find ?
is that about right ?

If so then.
Try looking at subclasses of
CreateElementCommand

you could override method

doDefaultElementCreation()

As at this point you have the container class.

A cleaner way and maybe the one I prefer is if you new Node been to
interrigate the top level container class then make it a reference in your
object model and after the node is created you can play with it until you
have what you want.



Hope that helps a little,

Stu


"natch" <bagnard.natacha@free.fr> wrote in message
news:f07fnb$qiu$1@build.eclipse.org...
> Hi,
> I'm new to GMF and I'm trying to find how to get back my model elements
> because I want to know how many instances of each one I've already made
> and be able to get attributes values for each too.
> I use the modelFactory for create them, but it has no methods to get them
> back ... And I haven't find where it is.
>
> Does someone know how I could do that ?
>
> Thanks,
>
> Natacha
Re: Getting back model elements [message #120743 is a reply to message #120638] Thu, 19 April 2007 09:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bagnard.natacha.free.fr

Stu a écrit :
> So can I guess:-
> When you create a 'Node' on the diagram you wish to see what other objects
> have been created and set certain attributes depending on what you find ?
> is that about right ?
It's nearly the same. I create new element at the plugin start.
I do it this way :
/** Model Initialisation **/
MyElement elem = DataModelFactory.eINSTANCE.createMyElement();

This element can't be create graphically on the diagram but is linked to
a diagramElement.
So when, I create a diagram element I want that I could do
diagramElement.setMyElement(elem).But I need to get elem back ...
>
> If so then.
> Try looking at subclasses of
> CreateElementCommand
>
> you could override method
>
> doDefaultElementCreation()
>
> As at this point you have the container class.
I don't know how to use this container class to get my elements. I've
try tu use DataModelPackage.eINSTANCE.eContainer but I haven't success
to find my elements with it.

>
> A cleaner way and maybe the one I prefer is if you new Node been to
> interrigate the top level container class then make it a reference in your
> object model and after the node is created you can play with it until you
> have what you want.
So only way I've find now is to store lists for each element of my model
and then add them to those list when I call a createElement method. I'm
sure those elements are already store somewhere, but I didn't understand
how to use container to get it.

>
>
>
> Hope that helps a little,
>
> Stu
Re: Getting back model elements [message #121001 is a reply to message #120743] Fri, 20 April 2007 10:55 Go to previous message
Eclipse UserFriend
Hello !

I have the same problem. I would like to be able to get all the
instances of all classes implemented (even if they have not graphical
representation). To create instances I use factory, but does soemeone
can explain me which class i have to use to get its back?

Thanks,

Julien
Previous Topic:Using GMF to displaying Charts (bar chart and Pie chart)
Next Topic:Problems with integration of GMF Editor into a RCP Application
Goto Forum:
  


Current Time: Sat Jun 21 12:28:39 EDT 2025

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

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

Back to the top