Skip to main content



      Home
Home » Eclipse Projects » GEF » How can I dynamically add child to parent objects.
How can I dynamically add child to parent objects. [message #145785] Sat, 31 July 2004 06:01 Go to next message
Eclipse UserFriend
Originally posted by: justinaruja.isletsystems.com

Hello All.

Please anyone give me some good reference for adding child objects to
parent objects dynamically



Thanks in advance

Justin
Re: How can I dynamically add child to parent objects. [message #145804 is a reply to message #145785] Sat, 31 July 2004 10:09 Go to previous message
Eclipse UserFriend
Originally posted by: rlemaigr.ulb.ac.be

> Please anyone give me some good reference for adding child objects=
to
> parent objects dynamically

Hi,

If you want examples, the HelloGef Examples are very useful:

http://eclipse-wiki.info/GefExamples


If you want an explanation attempt, here it is:

You have a parent model object and its children (I call "children" here =
=

the objects
you want to be represented inside of the parent representation, I don't =
=

know about the official
definition of that).

- When you add a child model object to its parent model object, the pare=
nt =

should notify
this event to its listeners. You have to implement yourself this =

notification mecanism in your model,
maybe with the java.beans.* classes.

- The parent EditPart (the EditPart of the parent model object) must be =
=

listening for these events.
You add it as a listener of its model object by overriding its activate(=
) =

method and calling smthg like
((ParentModelClass)getModel()).addListener(this).

- When the parent EditPart receives such an event, in the =

propertyChange(d?) method you must call
this.refreshChildren() (if you don't mind about efficiency). The =

refreshChildren() method will call
getModelChildren(), a method you should already have implemented in the =
=

parent EditPart that
should be returning the list of model objects that must be represented i=
n =

its content pane. With this information,
the parent EditPart will update the list of children EditParts / Figures=
=

according to the getModelChildren List.

- to create new EditParts for the children model object, the parent =

EditPart will call createChild(Object model),
which delegate the job to the EditPartFactory of the EditPartViewer (you=
=

should already have implemented that
if your model is displayed).

I think that's all you have to know...

bye

r=E9gis
Previous Topic:View Part ?
Next Topic:Logic Example Documentation
Goto Forum:
  


Current Time: Wed Jul 23 19:47:20 EDT 2025

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

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

Back to the top