Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Unable to understand how GEF works to map models onto editparts?!!!!!!!!!
Unable to understand how GEF works to map models onto editparts?!!!!!!!!! [message #207776] Sat, 21 January 2006 06:17 Go to next message
Eclipse UserFriend
Originally posted by: asha_ramegowda.yahoo.com

Hello...


I am completely new to Eclipse and I have to work with GEF plugin! I
have to develop a Graphical Editor for some existing model. I am iterating
through that examples to understand how it works! So far I have understood
how GEF allows to develop based on MVC architecture but I am surprised to
see just calling getHost().getModel() in an editpart would magically set the
corresponding model object though no where it's explicitly set as the
concerned model for that editpart!
I hope some one would explain me what mechanism GEF uses to return the
corresponding model when some one calls the getModel() method? How it sets
the model for an editpart? Is there something that happens behind the scenes
like... how a request object is created when some one simply select a tool
in the pallette in GEF?


Thank you.
Re: Unable to understand how GEF works to map models onto editparts?!!!!!!! [message #207793 is a reply to message #207776] Sun, 22 January 2006 19:49 Go to previous messageGo to next message
venkataramana m is currently offline venkataramana mFriend
Messages: 86
Registered: July 2009
Member
Asha, well as I can understand the GEF framework it goes something like this ... (Please be patient till your questions are answered after a long story)

Everything starts with the tool selected. Thats where the entry starts ...

1. Tool converts low-level mouse and keyboard events to high level events which can be captured by overriding certain methods AbstractTargetingTool etc.,
Thats where the REQUEST is created by us in a method like createTargetRequest. (NOTE: The method names may not be exactly the same as what I stated).

2. The created REQUEST is then routed to the editpart returned by getTargetEditpart (which usually is the editpart under the mouse location). The editpart then checks whether it can satisfy the request by iterating through all the editpolicies.

AbstractEditpolicy::getTargetEditpart should then return the appropriate editpart (if host does not serve the request) if request can be satisfied else return "null".
Also AbstractEditpolicy::getCommand should return a COMMAND if the request can be satisfied or return "null" otherwise.

3. After the Command is returned, AbstractTool then executes the command depending on the state of it (STATE_TERMINAL etc.,)..Once the COMMAND is executed, MODEL will change. Editparts interested in MODEL-changes will be notified. Editpart then responds to the MODEL-change events appropriately to refresh visuals by calling any of refreshVisuals, refreshChildren, refreshSourceConnections etc.,

4. Let us say a new model element has been created which needs to be reflected in the visuals, then the parent editpart is requested to return its children by a call to AbstractGarphicalEditpart::getModelChildren. Framework iterates through the children and if a child is found to be new (mean editpart does not exist), then EDITPARTFACTORY installed with the GraphicalEditor is requested to created editpart for that model-child. EditPartFactory then creates the appropriate EditPart by some type-checking. EditPartFactory also SETS THE MODEL into the edipart by calling setModel. (I think this is what you wanted to know :-))

5. After the editpart is returned by EditpartFactory, the new Editpart is requsted to create its figure by a call to createFigure method. Once the new figure is returned, it is added to the parent figure. After the figure addition, parent figure requests its layoutmanager to lay its children again. Each figure when being laid out is refreshed by a call to refreshVisuals. RefreshVisuals is where the editpart pumps the visual info like position, names etc., from the model into the figure.

Thats it ;-) ... It helps if you can write down the sequence and glance through the GEF source code simultaneously for a much concrete understanding. I think I have put forth the right details.

Thanks
~Venkat
Re: Unable to understand how GEF works to map models onto editparts?!!!!!!!!! [message #207990 is a reply to message #207776] Wed, 25 January 2006 04:48 Go to previous message
Eclipse UserFriend
Originally posted by: asha_ramegowda.yahoo.com

Hello...

Thank you very much for your concerned reply! It seems to be what I
wanted to know. I hope atleast following your suggestions I will be able to
plug-in to GEF development to which my mind refused plug-in earlier!

Thank you once again.

Asha R.

"Asha R" <asha_ramegowda@yahoo.com> wrote in message
news:dqsjv7$su8$1@utils.eclipse.org...
> Hello...
>
>
> I am completely new to Eclipse and I have to work with GEF plugin! I
> have to develop a Graphical Editor for some existing model. I am iterating
> through that examples to understand how it works! So far I have understood
> how GEF allows to develop based on MVC architecture but I am surprised to
> see just calling getHost().getModel() in an editpart would magically set
the
> corresponding model object though no where it's explicitly set as the
> concerned model for that editpart!
> I hope some one would explain me what mechanism GEF uses to return the
> corresponding model when some one calls the getModel() method? How it sets
> the model for an editpart? Is there something that happens behind the
scenes
> like... how a request object is created when some one simply select a tool
> in the pallette in GEF?
>
>
> Thank you.
>
>
Previous Topic:Rounded border with a label
Next Topic:question on connection restrictions
Goto Forum:
  


Current Time: Tue Apr 23 13:06:10 GMT 2024

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

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

Back to the top