Update all child figures when adding new one? [message #144824] |
Wed, 28 July 2004 08:07  |
Eclipse User |
|
|
|
Originally posted by: mastr.arcor.de
Hey!
My Editor shows some figures. I add a new figure to my parent one via a
palette CreationTool (better its assigned CreateCommand).
The figure is added correctly with the wanted layout constraint.
Now I want the other figures to resize when adding the new figure (it
looks something like a matrix).
PPPPPPPPPPPPPPPPPPPPPPPPP
P P
P LLL LLL LLL P
P SSS SS SS SSS P
P LLL LLL LLL P
P SSS SS SS SSS P
P LLL LLL LLL P
P P
PPPPPPPPPPPPPPPPPPPPPPPPP
So if I would add a new L-figure all S-figures have to enlarge their width.
If I would a new S-figure all L-figures have to enlarge their height.
The algorithm for setting this constraint is implemented.
Where do I have to say that the child figures have to relayout?
|
|
|
|
|
|
|
|
|
|
|
|
Re: Update all child figures when adding new one? [message #144964 is a reply to message #144930] |
Wed, 28 July 2004 10:57   |
Eclipse User |
|
|
|
Originally posted by: rlemaigr.ulb.ac.be
> My editor shows something like a matrix. I have to kind of figures,
> horizontal and vertical ones. Each horizontal figure overlaps each
> vertical figure. If I add a new vertical figure, each horizontal figur=
e
> has to enlarge their width (else they don't overlap the new added =
> figure).
Ok, now I see better what you meant, thx.
> That's why the refreshVisuals() method has to be called each time I ad=
d a
> new figure, because there the setLayoutConstraint() method is called t=
o
> layout the figure. (this is exactly what you said, right ;-))
No I still think there is something strange there.
The layout constraint associated with each child Figure should be stored=
=
in its model object. When you add a child
in the model, if the layout constraint associated to the other children =
=
have to change, you have to change them in
the model. So if the layout constraint of a child changes, the model =
object should fire an event, and the propertyChanged
method of its EditPart should call refreshVisuals(), and there the =
constaint associated to the Figure should be updated.
In the model, the add method should look like (it's just an idea, I coul=
d =
be wrong):
add(modelchild)
{
adds the child;
fires an add-event;
updates all the layout constraint in the model (this firing other event=
s, =
and triggering the calls to refreshVisuals when needed);
}
Is this what you do ?
If it is not, could you explain how you do it ?
r=E9gis
|
|
|
|
Re: Update all child figures when adding new one? [message #144987 is a reply to message #144964] |
Wed, 28 July 2004 11:09   |
Eclipse User |
|
|
|
Originally posted by: mastr.arcor.de
> The layout constraint associated with each child Figure should be stored
> in its model object. When you add a child
> in the model, if the layout constraint associated to the other children
> have to change, you have to change them in
> the model. So if the layout constraint of a child changes, the model
> object should fire an event, and the propertyChanged
> method of its EditPart should call refreshVisuals(), and there the
> constaint associated to the Figure should be updated.
> In the model, the add method should look like (it's just an idea, I could
> be wrong):
> add(modelchild)
> {
> adds the child;
> fires an add-event;
> updates all the layout constraint in the model (this firing other events,
> and triggering the calls to refreshVisuals when needed);
> }
> Is this what you do ?
> If it is not, could you explain how you do it ?
> régis
Okay, that's another way how to do it. But I designed my model to be kept
free from any constraint/layout information. I designed my parent EditPart
(which holds the root of my model) to calculate the constraint for each
model child. Each child EditPart gets its constraint when it is created.
If a new model child is added to root model the constraint is calculated
again for each child. I know its not very high-performance but because of
my atypical GEF-Editor (no Figures with connectors and able to drag and
drop) this is a good solution.
Thanx regis for this profitable discussion.
CU
|
|
|
|
Re: Update all child figures when adding new one? [message #145027 is a reply to message #144981] |
Wed, 28 July 2004 14:28  |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
I would recommend writing a simple layout manager which just positions the
children instead of generating Rectangle constraints and having those be
interpreted by XYLayout. The only difference is you'd have to implement
calcaultePreferredSize(), but that should be a simple loop.
"Martin Stransfeldt" <mastr@arcor.de> wrote in message
news:ce8f0f$8vm$1@eclipse.org...
> Martin S. wrote:
>
> > > Why do you want the refreshVisuals() methods of the other children
> > > EditParts to be called ?
>
> > > I think refreshVisuals is a method that should synchronize the
properties
> > > of the model object with those of its view (this including the layout
> > > constaint associated with the view). As the model objects of the other
> > > children EditParts don't change, I don't see a reason to call that
method
> > > on all the children EditParts...
>
> > My editor shows something like a matrix. I have to kind of figures,
> > horizontal and vertical ones. Each horizontal figure overlaps each
> > vertical figure. If I add a new vertical figure, each horizontal figure
> > has to enlarge their width (else they don't overlap the new added
figure).
>
> > That's why the refreshVisuals() method has to be called each time I add
a
> > new figure, because there the setLayoutConstraint() method is called to
> > layout the figure. (this is exactly what you said, right ;-))
>
> > Dont't mind on the performance because the matrix will not be that big.
>
>
> Thank for your supporting answers. It helps much to understand GEF
> architure and design with regards on perfomance.
>
> So I choose to override the refreshChildren() method (against GEF 2.0.2
> API recommendation). I loop over the getChildren() List and call each
> child EditPart's refreshVisuals() method.
>
> Finally, it works for my purpose. Pleace notice that this is a workaround
> and not intended by GEF.
>
> CU, Martin.
>
|
|
|
Powered by
FUDForum. Page generated in 0.06280 seconds