Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Update all child figures when adding new one?
Update all child figures when adding new one? [message #144824] Wed, 28 July 2004 12:07 Go to next message
Eclipse UserFriend
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 #144831 is a reply to message #144824] Wed, 28 July 2004 12:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mastr.arcor.de

Martin S. wrote:

> Where do I have to say that the child figures have to relayout?

I call refreshChildren() in the parent EditPart's propertyChanged() method.
But the only figure updated is the new one. All other child-figure's
refreshVisuals() method are not called.

Any idea why?

Thanks in advance.
Re: Update all child figures when adding new one? [message #144849 is a reply to message #144824] Wed, 28 July 2004 13:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

This is a multi-part message in MIME format.

------=_NextPart_000_0052_01C47486.7480BC10
Content-Type: text/plain;
charset="ISO-8859-15"
Content-Transfer-Encoding: quoted-printable


"Martin S." <mastr@arcor.de> wrote in message =
news:ce84tf$io8$1@eclipse.org...
> Hey!
>=20
> 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.
>=20
> Now I want the other figures to resize when adding the new figure (it
> looks something like a matrix).
> =20
> 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
>=20
> 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.
>=20
> Where do I have to say that the child figures have to relayout?

It depends on how the containment hierarchy looks. Is that just one =
figure with a bunch of children? Adding a figure is enough to cause =
layout to occur.
------=_NextPart_000_0052_01C47486.7480BC10
Content-Type: text/html;
charset="ISO-8859-15"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-15">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>"Martin S." &lt;</FONT><A=20
href=3D"mailto:mastr@arcor.de"><FONT face=3DArial=20
size=3D2>mastr@arcor.de</FONT></A><FONT face=3DArial size=3D2>&gt; wrote =
in message=20
</FONT><A href=3D"news:ce84tf$io8$1@eclipse.org"><FONT face=3DArial=20
size=3D2>news:ce84tf$io8$1@eclipse.org</FONT></A><FONT face=3DArial=20
size=3D2>...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt; Hey!<BR>&gt; <BR>&gt; My Editor =
shows some=20
figures. I add a new figure to my parent one via a<BR>&gt; palette =
CreationTool=20
(better its assigned CreateCommand).<BR>&gt; The figure is added =
correctly with=20
the wanted layout constraint.<BR>&gt; <BR>&gt; Now I want the other =
figures to=20
resize when adding the new figure (it<BR>&gt; looks something like a=20
matrix).<BR>&gt; &nbsp;<BR><FONT face=3DCourier>&gt;=20
&nbsp;PPPPPPPPPPPPPPPPPPPPPPPPP<BR>&gt;=20
&nbsp;P&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
P<BR>&gt; &nbsp;P&nbsp;&nbsp;&nbsp;&nbsp; LLL&nbsp; LLL&nbsp;=20
LLL&nbsp;&nbsp;&nbsp;&nbsp; P<BR>&gt; &nbsp;P&nbsp; SSS&nbsp;&nbsp;=20
SS&nbsp;&nbsp; SS&nbsp;&nbsp; SSS&nbsp; P<BR>&gt;=20
&nbsp;P&nbsp;&nbsp;&nbsp;&nbsp; LLL&nbsp; LLL&nbsp; =
LLL&nbsp;&nbsp;&nbsp;&nbsp;=20
P<BR>&gt; &nbsp;P&nbsp; SSS&nbsp;&nbsp; SS&nbsp;&nbsp; SS&nbsp;&nbsp; =
SSS&nbsp;=20
P<BR>&gt; &nbsp;P&nbsp;&nbsp;&nbsp;&nbsp; LLL&nbsp; LLL&nbsp;=20
LLL&nbsp;&nbsp;&nbsp;&nbsp; P<BR>&gt;=20
&nbsp;P&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
P<BR>&gt; &nbsp;PPPPPPPPPPPPPPPPPPPPPPPPP<BR></FONT>&gt; <BR>&gt; So if =
I would=20
add a new L-figure all S-figures have to enlarge their width.<BR>&gt; If =
I would=20
a new S-figure all L-figures have to enlarge their height.<BR>&gt; The =
algorithm=20
for setting this constraint is implemented.<BR>&gt; <BR>&gt; Where do I =
have to=20
say that the child figures have to relayout?<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>It depends on how the containment =
hierarchy=20
looks.&nbsp;&nbsp;Is that just one figure with a bunch of =
children?&nbsp; Adding=20
a figure is enough to cause layout to occur.</FONT><FONT face=3DArial=20
size=3D2></DIV></FONT></BODY></HTML>

------=_NextPart_000_0052_01C47486.7480BC10--
Re: Update all child figures when adding new one? [message #144890 is a reply to message #144849] Wed, 28 July 2004 13:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mastr.arcor.de

Randy Hudson wrote:

> "Martin S." <mastr@arcor.de> wrote in message
news:ce84tf$io8$1@eclipse.org...
> > 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?

> It depends on how the containment hierarchy looks. Is that just one figure
with a bunch of children? Adding a figure is enough to cause layout to occur.

I have a parent container(P) which has the children L and S which are both
the same hierachy level. You can imagine each S-line (horizontal) crosses
each L-line (vertical) and the other way round (they overlap because they
are not opaque).
Re: Update all child figures when adding new one? [message #144897 is a reply to message #144890] Wed, 28 July 2004 13:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

In that case, I don't see the issue. You add a child, which calls
revalidate(), which causes the parent container to reposition all of the
children. Are you saying this isn't happening?

"Martin S." <mastr@arcor.de> wrote in message
news:ce8b69$vun$1@eclipse.org...
> Randy Hudson wrote:
>
> > "Martin S." <mastr@arcor.de> wrote in message
> news:ce84tf$io8$1@eclipse.org...
> > > 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?
>
> > It depends on how the containment hierarchy looks. Is that just one
figure
> with a bunch of children? Adding a figure is enough to cause layout to
occur.
>
> I have a parent container(P) which has the children L and S which are both
> the same hierachy level. You can imagine each S-line (horizontal) crosses
> each L-line (vertical) and the other way round (they overlap because they
> are not opaque).
>
>
Re: Update all child figures when adding new one? [message #144914 is a reply to message #144897] Wed, 28 July 2004 14:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mastr.arcor.de

Randy Hudson wrote:

> In that case, I don't see the issue. You add a child, which calls
> revalidate(), which causes the parent container to reposition all of the
> children. Are you saying this isn't happening?

I think we get warmer ;-)

My propertyChange() method in the parent EditPart doesn't call
revalidate().
It calls refreshChildren().
Is that the point why only the new figure's refreshVisuals() method is
called?

What does revalidate() exactly and what does refreshChildren()?
Re: Update all child figures when adding new one? [message #144921 is a reply to message #144831] Wed, 28 July 2004 14:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rlemaigr.ulb.ac.be

>> Where do I have to say that the child figures have to relayout?
>
> I call refreshChildren() in the parent EditPart's propertyChanged() =

> method.
> But the only figure updated is the new one. All other child-figure's
> refreshVisuals() method are not called.

Hello,

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 propertie=
s =

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 metho=
d =

on all the children EditParts...

There may be something strange here, or you may have made a mistake whil=
e =

writing your post ?

r=E9gis
Re: Update all child figures when adding new one? [message #144930 is a reply to message #144921] Wed, 28 July 2004 14:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mastr.arcor.de

> 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.
Re: Update all child figures when adding new one? [message #144938 is a reply to message #144914] Wed, 28 July 2004 14:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rlemaigr.ulb.ac.be

> Randy Hudson wrote:
>> In that case, I don't see the issue. You add a child, which calls
>> revalidate(), which causes the parent container to reposition all of =
the
>> children. Are you saying this isn't happening?
>
> I think we get warmer ;-)
>
> My propertyChange() method in the parent EditPart doesn't call
> revalidate().

I think what Randy Hudson meant was: when you add a child to a Figure, t=
he =

revalidate method is called automatically and the layout will occur when=
=

it is time without you having to worry about it. So you don't have to ca=
ll =

revalidate() yourself.

> It calls refreshChildren().

And that's all you should have to do...

> Is that the point why only the new figure's refreshVisuals() method is=

> called?

GEF has no reason to call the refreshVisuals() method on all the childre=
n =

EditParts when you call refreshChildren(). RefreshVisuals() is just call=
ed =

once on the newly created EditPart(s) to initialize their views. If the =
=

model objects of the other children EditParts don't change, their is no =
=

reason to call refreshVisuals() on them. I think your problem is there. =
=

Could you explain why you want to call refreshVisuals() on the other =

children as well ?
Re: Update all child figures when adding new one? [message #144947 is a reply to message #144914] Wed, 28 July 2004 14:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rlemaigr.ulb.ac.be

I am reading your answer on the other side now ;-)
Re: Update all child figures when adding new one? [message #144964 is a reply to message #144930] Wed, 28 July 2004 14:57 Go to previous messageGo to next message
Eclipse UserFriend
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 #144981 is a reply to message #144930] Wed, 28 July 2004 14:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mastr.arcor.de

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.
Re: Update all child figures when adding new one? [message #144987 is a reply to message #144964] Wed, 28 July 2004 15:09 Go to previous messageGo to next message
Eclipse UserFriend
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 #144993 is a reply to message #144987] Wed, 28 July 2004 15:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rlemaigr.ulb.ac.be

> Okay, that's another way how to do it. But I designed my model to be k=
ept
> free from any constraint/layout information.
> I designed my parent EditPart
> (which holds the root of my model) to calculate the constraint for eac=
h
> model child. Each child EditPart gets its constraint when it is create=
d.
> If a new model child is added to root model the constraint is calculat=
ed
> 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 an=
d
> drop) this is a good solution.
>
> Thanx regis for this profitable discussion.
> CU

Ok I see where the problem came from, now.
But if it works...it works :D !

bye
Re: Update all child figures when adding new one? [message #145027 is a reply to message #144981] Wed, 28 July 2004 18:28 Go to previous message
Eclipse UserFriend
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.
>
Previous Topic:how could i change my editor to a dirty state
Next Topic:GridEnabled but not displayed ?
Goto Forum:
  


Current Time: Fri Aug 16 22:27:26 GMT 2024

Powered by FUDForum. Page generated in 0.06273 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top