Sorry to be a pain, but nobody followed up on this. Is it
impossible
to reparent figures deeper down the image hierarchy? Do
figures for *direct* model children mc_1, ..., mc_n of
model m have to be *direct* children fc_1, ..., fc_n of
the corresponding figure f (for model m)?
And if so, why? Is there any workaround to get what I
want? Or is there any good reason I do not actually want
that?
Regards, Thomas.
Thomas Maier wrote:
Hi all,
I have a figure of type FigureA and I want its children
of type Model1 and Model2 not to be placed in its
contentPane but in two other Panels
of type Panel1 or Panel2 that are children of the
contentPane. I thought I could tell the editparts of
type EditPart1 (and EditPart2, respectively) something
like (in createFigure(), casts omitted)
Figure1 figure1 = new Figure1();
getParent().getFigure().getPanel1().add(figure1);
return figure1;
but GEF reparents the figure to FigureA's contentPane.
So I thought I say, in EditPart1::refreshVisuals():
getParent().getFigure().remove(getFigure());
getParent().getFigure().getPanel1().add(getFigure());
I tried it with the remove and without. For some objects
it works and displays correctly, for some it throws an
exception:
> [...]
I have skimmed some GEF methods and it seems to like to
keep the indices for models, editparts and figures
identical, so at
there is
protected void addChildVisual(EditPart childEditPart, int
index) {
IFigure child =
((GraphicalEditPart)childEditPart).getFigure();
getContentPane().add(child, index);
}
which leads to the IndexOutOfBoundsException later on in
Figure.add(), because the children are "kidnapped" and
there are less than GEF supposes.
It seems to me GEF does not like it when reparenting
children this way.
Is there another way to achieve it? From a user point of
view I would have thought (and actually did) that when
returning a figure from createFigure() that already has a
parent, that might be respected and a
new parent only set when it is null. Thoughts?
Thanks and regards, Thomas.