[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.gef] Re: Reparenting child figures to children from contentPane
|
or override figureA's add,remove,getChildren,etc methods.
ryanp wrote on 2004-5-4 15:51:
> Thomas,
>
> It might also be achieved by setting a SPECIAL layout
> manager for FigureA. In the layout() method, dispatch
> all children figures into sub panels.
>
> Ryan
>
> Thomas Maier wrote on 2004-4-30 22:21:
>
>> 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:
>>
>> java.lang.IndexOutOfBoundsException: IWAG0001E
>> Figure.add(...) invalid
>> index
>> at org.eclipse.draw2d.Figure.add(Figure.java:101)
>> at org.eclipse.draw2d.Figure.add(Figure.java:148)
>> at
>>
>
org.eclipse.gef.editparts.AbstractGraphicalEditPart.addChildVisual(AbstractGraphicalEditPart.java:182)
>> at
>>
>
org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:183)
>> at
>>
>
org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:742)
>> at
>>
>
org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:694)
>> at
>>
>
org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:538)
>> at
>>
>
org.eclipse.gef.editparts.AbstractEditPart.addNotify(AbstractEditPart.java:221)
>> at
>>
>
org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotify(AbstractGraphicalEditPart.java:196)
>> at
>>
>
org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:184)
>> at
>>
>
org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:742)
>> at
>>
>
org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:694)
>>
>> 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.
>>