[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] Re: Editparts, Figures and children

Hi Randy,

this would be fine for the simple example I cited. However, sometimes I need to build up more complex figures for layout reasons. I.e. one editpart has a figure with any number of nested figures to lay out the EditPart. In this case I might not actually be adding to the EditPart's top level figure, but to one of its children. It also isn't necessarily a case of having a 'content pane' to which child visuals are added. They can be placed anywhere in the figure hierarchy.

I've worked round the problem by having a superclass EditPart which allows 'placeholders' to be added to a figure by subclasses. The placeholders are stored in a List for retrieval later. The signature for the method is

	protected void addPlaceholder(Figure container)

This allows the subclass to determine where the child EditPart's figure will ultimately be placed. The superclass overrides addChildVisual/removeChildVisual to look up the placeholder by index and replaces it with the child editpart's figure. Seems to work well.

BTW as I'm sure you know, overriding add/removeChildVisual to do nothing was not a solution. When createFigure() is called, the parent EditPart doesn't have any child EditParts so it can't add them at that point.

Thanks for the help.

Pat


Randy Hudson wrote:
It sounds like you want 2 children figures to be at figure indexes 0 and 2.
Why not just extend the method and correct the indexed?  In other words, if
index==1, set index := 2.