[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] Re: Reparenting child figures to children from contentPane

ryanp wrote:
If you have editparts for those panels, you can also
override the getTargetEditPart(Request req) method in
editPartA, and delegate requests, i.e. REQ_CREATE_CHILDREN,
REQ_MOVE_CHILDREN to the panel editparts.


I guess I do not have editparts for the panels, because I do not have objects for the panels on the model side. Having models would not be the right thing. So I guess this one doesn't work either?


Thanks anyway, Thomas.


Thomas Maier wrote on 2004-5-4 15:35:


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


org.eclipse.gef.editparts.AbstractGraphicalEditPart.addChildVisual

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.






--
Thomas Maier <Thomas.Maier@xxxxxxxxxxxxx>