Home » Eclipse Projects » GEF » EditPart controling a sub-figure ?
EditPart controling a sub-figure ? [message #216649] |
Tue, 23 May 2006 08:40 |
Eclipse User |
|
|
|
Originally posted by: nospam.thx.you
Hi,
I've followed the ShapesEditor tutorial. I've then managed to make my
own editor without reading the tutorial, it worked, cool.
Now, I started my real editor (the one I need), bu I came to a problem
whom answer I could not find yet : in my editor, the figure are
hierachical, that mean s that figures of the sub-part of a model element
must be displayed into the figure of the element. What I would like to do
is have a square, in which you can add squares, and you can add squares
(or even rounds, it's a powerfull editor) into the squares and so on.
My problem is that when the getFigure method is called, I could not find
the "good" way to have my figure added to the father-editPart's figure
instead of being added to the root-editPart's figure.
Any hint about this ?
regards,
Jaune.
|
|
|
Re: EditPart controling a sub-figure ? [message #216743 is a reply to message #216649] |
Wed, 24 May 2006 03:59 |
Sebu Thomas Messages: 12 Registered: July 2009 |
Junior Member |
|
|
Jaune d'Eau wrote:
> Hi,
>
> I've followed the ShapesEditor tutorial. I've then managed to make my
> own editor without reading the tutorial, it worked, cool.
>
> Now, I started my real editor (the one I need), bu I came to a problem
> whom answer I could not find yet : in my editor, the figure are
> hierachical, that mean s that figures of the sub-part of a model element
> must be displayed into the figure of the element. What I would like to
> do is have a square, in which you can add squares, and you can add
> squares (or even rounds, it's a powerfull editor) into the squares and
> so on.
>
> My problem is that when the getFigure method is called, I could not
> find the "good" way to have my figure added to the father-editPart's
> figure instead of being added to the root-editPart's figure.
>
> Any hint about this ?
>
> regards,
> Jaune.
>
There are two keys here i) add the child component's model to parent
component's model and override getModelChildren() of the parent to
return the children as a list. ii) override addChildVisual() in the
parent EditPart to add the child figure correctly to the parent. You
might not need step (ii)
protected void addChildVisual(EditPart childEditPart, int index) {
IFigure child = ((GraphicalEditPart)childEditPart).getFigure();
((MyFigure)getFigure()).addChild(child, index);
}
In the above code, ((MyFigure)getFigure()).addChild(child, index) takes
care of adding the child in the correct position within the parent.
HTH.
Sebu
|
|
|
Problem with layout (was Re: EditPart controling a sub-figure ?) [message #216751 is a reply to message #216743] |
Wed, 24 May 2006 06:19 |
Eclipse User |
|
|
|
Originally posted by: nospam.thx.you
Thanks you sebu.
In fact, I just re-checked and fuond the problem half an hour ago : In
fact, the figures of the childrens ARE added to the figure of the father,
the problem is that there seems to be big layout issues : My figures are
displayed just as I want using XY layouts in a LightweightSystem, but when
I used them in a GraphicalEditor, XY layout do not work (I still haveto
understand why nothing is displayed), I have to use a FreeFormLayout, and
then my figures are displayed in one column. (with the LightweightSystem,
they work fine : the figures is displayed, and under it every sub-figure
is displayed in one line, and so on. I use 1 vertical FlowLayout and 1
horizontal FlowLayout for this). I tryed other layout for my content's
EditPart's figure (flow layout, ...), but the problem is always the same :
my figure are displayed in one column, and in reverse order. (the sub
figures are added to the good parent figure, but the problem seems to come
from the layouting).
Any hint ?
Regards,
Fabien.
|
|
| |
Goto Forum:
Current Time: Thu Sep 19 18:25:25 GMT 2024
Powered by FUDForum. Page generated in 0.03175 seconds
|