Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » DirectEditManager
DirectEditManager [message #139712] Wed, 23 June 2004 17:22 Go to next message
Maged Elaasar is currently offline Maged ElaasarFriend
Messages: 529
Registered: July 2009
Senior Member
Hello,

The DirectEditManager installs an ancestor listener on the editpart's figure
and relocates the cell editor upon handling the event. So basically, if the
label is nested within say 5 containers and one more character is inserted,
that causes the label to revalidate which means all the containers will be
resized appropriately. The problem now is that the relocate will be called 5
times, once for each container (in fact the figure will not have resized
itself appropriately until at the end when its bounds is set). That causes
the text widget to flicker.

Is there a real reason for the ancestor listening? isn't figure bounds
listening enough? Thanks.

Maged Elaasar
Re: DirectEditManager [message #139723 is a reply to message #139712] Wed, 23 June 2004 17:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

"Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
news:cbce8d$vq7$1@eclipse.org...
> Hello,
>
> The DirectEditManager installs an ancestor listener on the editpart's
figure
> and relocates the cell editor upon handling the event. So basically, if
the
> label is nested within say 5 containers and one more character is
inserted,
> that causes the label to revalidate which means all the containers will be
> resized appropriately. The problem now is that the relocate will be called
5

Do all 5 containers change their location as well? If the bounds are not
changing there should be no effect. You should only see two changes, when
the top-left corner moves, and the size.

> times, once for each container (in fact the figure will not have resized
> itself appropriately until at the end when its bounds is set). That causes
> the text widget to flicker.
>
> Is there a real reason for the ancestor listening? isn't figure bounds
> listening enough? Thanks.

The parent may have local coordinates and therefore doesn't translate its
children.

> Maged Elaasar
>
>
Re: DirectEditManager [message #139745 is a reply to message #139723] Wed, 23 June 2004 18:08 Go to previous messageGo to next message
Maged Elaasar is currently offline Maged ElaasarFriend
Messages: 529
Registered: July 2009
Senior Member
1- The ancestor listening also happens if the size only has changed (so you
could get 5 events) In addition, depending on the layouts used, some
parents might really move when the label's size changes.

2- Can you elaborate on the case where parents use local coordinates? I
thought the bounds of the text widget should be based on those of the label
regardless of parents. So if the label does not move (for some reason or
another) the widget also should not.


"Randy Hudson" <none@us.ibm.com> wrote in message
news:cbcfma$344$1@eclipse.org...
>
> "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> news:cbce8d$vq7$1@eclipse.org...
> > Hello,
> >
> > The DirectEditManager installs an ancestor listener on the editpart's
> figure
> > and relocates the cell editor upon handling the event. So basically, if
> the
> > label is nested within say 5 containers and one more character is
> inserted,
> > that causes the label to revalidate which means all the containers will
be
> > resized appropriately. The problem now is that the relocate will be
called
> 5
>
> Do all 5 containers change their location as well? If the bounds are not
> changing there should be no effect. You should only see two changes, when
> the top-left corner moves, and the size.
>
> > times, once for each container (in fact the figure will not have resized
> > itself appropriately until at the end when its bounds is set). That
causes
> > the text widget to flicker.
> >
> > Is there a real reason for the ancestor listening? isn't figure bounds
> > listening enough? Thanks.
>
> The parent may have local coordinates and therefore doesn't translate its
> children.
>
> > Maged Elaasar
> >
> >
>
>
Re: DirectEditManager [message #139767 is a reply to message #139745] Wed, 23 June 2004 18:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

"Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
news:cbcguq$5t7$1@eclipse.org...
> 1- The ancestor listening also happens if the size only has changed (so
you
> could get 5 events) In addition, depending on the layouts used, some

I know you get 5 events. But is setBounds() called on the CellEditor with 5
unique values? Just put an optimization in your Locator where you don't
call setBounds() if the location is not changing.

> parents might really move when the label's size changes.
>
> 2- Can you elaborate on the case where parents use local coordinates? I
> thought the bounds of the text widget should be based on those of the
label
> regardless of parents. So if the label does not move (for some reason or
> another) the widget also should not.

If any parent has useLocalCoordinates() returning true, or Viewport with
virtual scrolling.

> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:cbcfma$344$1@eclipse.org...
> >
> > "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> > news:cbce8d$vq7$1@eclipse.org...
> > > Hello,
> > >
> > > The DirectEditManager installs an ancestor listener on the editpart's
> > figure
> > > and relocates the cell editor upon handling the event. So basically,
if
> > the
> > > label is nested within say 5 containers and one more character is
> > inserted,
> > > that causes the label to revalidate which means all the containers
will
> be
> > > resized appropriately. The problem now is that the relocate will be
> called
> > 5
> >
> > Do all 5 containers change their location as well? If the bounds are
not
> > changing there should be no effect. You should only see two changes,
when
> > the top-left corner moves, and the size.
> >
> > > times, once for each container (in fact the figure will not have
resized
> > > itself appropriately until at the end when its bounds is set). That
> causes
> > > the text widget to flicker.
> > >
> > > Is there a real reason for the ancestor listening? isn't figure bounds
> > > listening enough? Thanks.
> >
> > The parent may have local coordinates and therefore doesn't translate
its
> > children.
> >
> > > Maged Elaasar
> > >
> > >
> >
> >
>
>
Re: DirectEditManager [message #139990 is a reply to message #139767] Fri, 25 June 2004 11:39 Go to previous messageGo to next message
Maged Elaasar is currently offline Maged ElaasarFriend
Messages: 529
Registered: July 2009
Senior Member
The label I am using supports wrapping. So the locator has code like that:

Text text = (Text) celleditor.getControl();
Rectangle rect = getLabel().getTextBounds().getCopy();
getLabel().translateToAbsolute(rect);

if (getLabel().isTextWrapped())
rect.setSize(new Dimension(text.computeSize(rect.width, rect.height)));
else
rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)));

if (!rect.equals(new Rectangle(text.getBounds())))
text.setBounds(rect.x, rect.y, rect.width, rect.height);

The problem with ancestor listening here is that during all the events I
will be getting except the last one, the label figure will be still
"invalid" (from the addition of the character), which means the
getTextBounds will be calculated using the old size (but with the new text)
which gives incorrect bounds. Eventually when the label is validated, the
correct size is set and the bounds returned is correct. However, I see the
flickering.

Do you have a suggestion to fix that? One way I thought of is to check if
the label figure is valid before relocating. However, I am not sure if this
is as good as removing the ancestor listening and replacing it with a figure
listener (will I loose something?)

I appreciate any feedback



"Randy Hudson" <none@us.ibm.com> wrote in message
news:cbcika$97p$1@eclipse.org...
>
> "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> news:cbcguq$5t7$1@eclipse.org...
> > 1- The ancestor listening also happens if the size only has changed (so
> you
> > could get 5 events) In addition, depending on the layouts used, some
>
> I know you get 5 events. But is setBounds() called on the CellEditor with
5
> unique values? Just put an optimization in your Locator where you don't
> call setBounds() if the location is not changing.
>
> > parents might really move when the label's size changes.
> >
> > 2- Can you elaborate on the case where parents use local coordinates? I
> > thought the bounds of the text widget should be based on those of the
> label
> > regardless of parents. So if the label does not move (for some reason or
> > another) the widget also should not.
>
> If any parent has useLocalCoordinates() returning true, or Viewport with
> virtual scrolling.
>
> > "Randy Hudson" <none@us.ibm.com> wrote in message
> > news:cbcfma$344$1@eclipse.org...
> > >
> > > "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> > > news:cbce8d$vq7$1@eclipse.org...
> > > > Hello,
> > > >
> > > > The DirectEditManager installs an ancestor listener on the
editpart's
> > > figure
> > > > and relocates the cell editor upon handling the event. So basically,
> if
> > > the
> > > > label is nested within say 5 containers and one more character is
> > > inserted,
> > > > that causes the label to revalidate which means all the containers
> will
> > be
> > > > resized appropriately. The problem now is that the relocate will be
> > called
> > > 5
> > >
> > > Do all 5 containers change their location as well? If the bounds are
> not
> > > changing there should be no effect. You should only see two changes,
> when
> > > the top-left corner moves, and the size.
> > >
> > > > times, once for each container (in fact the figure will not have
> resized
> > > > itself appropriately until at the end when its bounds is set). That
> > causes
> > > > the text widget to flicker.
> > > >
> > > > Is there a real reason for the ancestor listening? isn't figure
bounds
> > > > listening enough? Thanks.
> > >
> > > The parent may have local coordinates and therefore doesn't translate
> its
> > > children.
> > >
> > > > Maged Elaasar
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: DirectEditManager [message #140001 is a reply to message #139990] Fri, 25 June 2004 12:39 Go to previous messageGo to next message
Maged Elaasar is currently offline Maged ElaasarFriend
Messages: 529
Registered: July 2009
Senior Member
I just realized that checking for validation won't work since a figure is
validated after it is laid out. Anyways, I think the scenario I am talking
about could also be demostrated as follows:

You have a shape that has a name label which is centered in the shape.
Adding a new character causes the label to revalidate which will also clear
its cached local variables including textLocation. As the cell editor
locator is listening to the label's ancestors being laid out, it calls
getTextBounds() which will cause the textLocation to be recalculated with
the new text but with the old size leading to incorrect bounds. Only when
the label itself is laid out with the correct bounds, that the getTextBounds
returns correct result.

I tried your suggestion of only setting the bounds of the editor with unique
values which reduced the flickering, however, I still get two unique values
per character typed, one when the label has new text but old size, and
another when it has both the new text and size. This would cause flicking,
especially if the two sizes are way off (it shows more in my case due to the
text wrapping).

I appreciate any more suggestions.


"Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
news:cbh2tk$ub3$1@eclipse.org...
> The label I am using supports wrapping. So the locator has code like that:
>
> Text text = (Text) celleditor.getControl();
> Rectangle rect = getLabel().getTextBounds().getCopy();
> getLabel().translateToAbsolute(rect);
>
> if (getLabel().isTextWrapped())
> rect.setSize(new Dimension(text.computeSize(rect.width,
rect.height)));
> else
> rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT,
SWT.DEFAULT)));
>
> if (!rect.equals(new Rectangle(text.getBounds())))
> text.setBounds(rect.x, rect.y, rect.width, rect.height);
>
> The problem with ancestor listening here is that during all the events I
> will be getting except the last one, the label figure will be still
> "invalid" (from the addition of the character), which means the
> getTextBounds will be calculated using the old size (but with the new
text)
> which gives incorrect bounds. Eventually when the label is validated, the
> correct size is set and the bounds returned is correct. However, I see the
> flickering.
>
> Do you have a suggestion to fix that? One way I thought of is to check if
> the label figure is valid before relocating. However, I am not sure if
this
> is as good as removing the ancestor listening and replacing it with a
figure
> listener (will I loose something?)
>
> I appreciate any feedback
>
>
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:cbcika$97p$1@eclipse.org...
> >
> > "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> > news:cbcguq$5t7$1@eclipse.org...
> > > 1- The ancestor listening also happens if the size only has changed
(so
> > you
> > > could get 5 events) In addition, depending on the layouts used, some
> >
> > I know you get 5 events. But is setBounds() called on the CellEditor
with
> 5
> > unique values? Just put an optimization in your Locator where you don't
> > call setBounds() if the location is not changing.
> >
> > > parents might really move when the label's size changes.
> > >
> > > 2- Can you elaborate on the case where parents use local coordinates?
I
> > > thought the bounds of the text widget should be based on those of the
> > label
> > > regardless of parents. So if the label does not move (for some reason
or
> > > another) the widget also should not.
> >
> > If any parent has useLocalCoordinates() returning true, or Viewport with
> > virtual scrolling.
> >
> > > "Randy Hudson" <none@us.ibm.com> wrote in message
> > > news:cbcfma$344$1@eclipse.org...
> > > >
> > > > "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> > > > news:cbce8d$vq7$1@eclipse.org...
> > > > > Hello,
> > > > >
> > > > > The DirectEditManager installs an ancestor listener on the
> editpart's
> > > > figure
> > > > > and relocates the cell editor upon handling the event. So
basically,
> > if
> > > > the
> > > > > label is nested within say 5 containers and one more character is
> > > > inserted,
> > > > > that causes the label to revalidate which means all the containers
> > will
> > > be
> > > > > resized appropriately. The problem now is that the relocate will
be
> > > called
> > > > 5
> > > >
> > > > Do all 5 containers change their location as well? If the bounds
are
> > not
> > > > changing there should be no effect. You should only see two
changes,
> > when
> > > > the top-left corner moves, and the size.
> > > >
> > > > > times, once for each container (in fact the figure will not have
> > resized
> > > > > itself appropriately until at the end when its bounds is set).
That
> > > causes
> > > > > the text widget to flicker.
> > > > >
> > > > > Is there a real reason for the ancestor listening? isn't figure
> bounds
> > > > > listening enough? Thanks.
> > > >
> > > > The parent may have local coordinates and therefore doesn't
translate
> > its
> > > > children.
> > > >
> > > > > Maged Elaasar
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: DirectEditManager [message #140054 is a reply to message #140001] Fri, 25 June 2004 14:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

In the past, we used to add a Verify Listener to the Text control in the
Logic Example. This would enlarge the Text widget prior to the new text
being inserted, which prevents the text from scrolling horizontally when it
doesn't fit.

verifyListener = new VerifyListener() {
public void verifyText(VerifyEvent event) {
Text text = (Text)getCellEditor().getControl();
String oldText = text.getText();
String leftText = oldText.substring(0, event.start);
String rightText = oldText.substring(event.end, oldText .length());
GC gc = new GC(text);
String s = leftText + event.text + rightText;
Point size = gc.textExtent(leftText + event.text + rightText);
gc.dispose();
if (size.x != 0)
size = text.computeSize(size.x, SWT.DEFAULT);
getCellEditor().getControl().setSize(size.x, size.y);
}
};

The control may still be sized multiple times, but it will not shift the
text around which I think is causing the flickering.


"Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
news:cbh6d4$5u1$1@eclipse.org...
> I just realized that checking for validation won't work since a figure is
> validated after it is laid out. Anyways, I think the scenario I am talking
> about could also be demostrated as follows:
>
> You have a shape that has a name label which is centered in the shape.
> Adding a new character causes the label to revalidate which will also
clear
> its cached local variables including textLocation. As the cell editor
> locator is listening to the label's ancestors being laid out, it calls
> getTextBounds() which will cause the textLocation to be recalculated with
> the new text but with the old size leading to incorrect bounds. Only when
> the label itself is laid out with the correct bounds, that the
getTextBounds
> returns correct result.
>
> I tried your suggestion of only setting the bounds of the editor with
unique
> values which reduced the flickering, however, I still get two unique
values
> per character typed, one when the label has new text but old size, and
> another when it has both the new text and size. This would cause flicking,
> especially if the two sizes are way off (it shows more in my case due to
the
> text wrapping).
>
> I appreciate any more suggestions.
>
>
> "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> news:cbh2tk$ub3$1@eclipse.org...
> > The label I am using supports wrapping. So the locator has code like
that:
> >
> > Text text = (Text) celleditor.getControl();
> > Rectangle rect = getLabel().getTextBounds().getCopy();
> > getLabel().translateToAbsolute(rect);
> >
> > if (getLabel().isTextWrapped())
> > rect.setSize(new Dimension(text.computeSize(rect.width,
> rect.height)));
> > else
> > rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT,
> SWT.DEFAULT)));
> >
> > if (!rect.equals(new Rectangle(text.getBounds())))
> > text.setBounds(rect.x, rect.y, rect.width, rect.height);
> >
> > The problem with ancestor listening here is that during all the events I
> > will be getting except the last one, the label figure will be still
> > "invalid" (from the addition of the character), which means the
> > getTextBounds will be calculated using the old size (but with the new
> text)
> > which gives incorrect bounds. Eventually when the label is validated,
the
> > correct size is set and the bounds returned is correct. However, I see
the
> > flickering.
> >
> > Do you have a suggestion to fix that? One way I thought of is to check
if
> > the label figure is valid before relocating. However, I am not sure if
> this
> > is as good as removing the ancestor listening and replacing it with a
> figure
> > listener (will I loose something?)
> >
> > I appreciate any feedback
> >
> >
> >
> > "Randy Hudson" <none@us.ibm.com> wrote in message
> > news:cbcika$97p$1@eclipse.org...
> > >
> > > "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> > > news:cbcguq$5t7$1@eclipse.org...
> > > > 1- The ancestor listening also happens if the size only has changed
> (so
> > > you
> > > > could get 5 events) In addition, depending on the layouts used,
some
> > >
> > > I know you get 5 events. But is setBounds() called on the CellEditor
> with
> > 5
> > > unique values? Just put an optimization in your Locator where you
don't
> > > call setBounds() if the location is not changing.
> > >
> > > > parents might really move when the label's size changes.
> > > >
> > > > 2- Can you elaborate on the case where parents use local
coordinates?
> I
> > > > thought the bounds of the text widget should be based on those of
the
> > > label
> > > > regardless of parents. So if the label does not move (for some
reason
> or
> > > > another) the widget also should not.
> > >
> > > If any parent has useLocalCoordinates() returning true, or Viewport
with
> > > virtual scrolling.
> > >
> > > > "Randy Hudson" <none@us.ibm.com> wrote in message
> > > > news:cbcfma$344$1@eclipse.org...
> > > > >
> > > > > "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> > > > > news:cbce8d$vq7$1@eclipse.org...
> > > > > > Hello,
> > > > > >
> > > > > > The DirectEditManager installs an ancestor listener on the
> > editpart's
> > > > > figure
> > > > > > and relocates the cell editor upon handling the event. So
> basically,
> > > if
> > > > > the
> > > > > > label is nested within say 5 containers and one more character
is
> > > > > inserted,
> > > > > > that causes the label to revalidate which means all the
containers
> > > will
> > > > be
> > > > > > resized appropriately. The problem now is that the relocate will
> be
> > > > called
> > > > > 5
> > > > >
> > > > > Do all 5 containers change their location as well? If the bounds
> are
> > > not
> > > > > changing there should be no effect. You should only see two
> changes,
> > > when
> > > > > the top-left corner moves, and the size.
> > > > >
> > > > > > times, once for each container (in fact the figure will not have
> > > resized
> > > > > > itself appropriately until at the end when its bounds is set).
> That
> > > > causes
> > > > > > the text widget to flicker.
> > > > > >
> > > > > > Is there a real reason for the ancestor listening? isn't figure
> > bounds
> > > > > > listening enough? Thanks.
> > > > >
> > > > > The parent may have local coordinates and therefore doesn't
> translate
> > > its
> > > > > children.
> > > > >
> > > > > > Maged Elaasar
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: DirectEditManager [message #140122 is a reply to message #140054] Fri, 25 June 2004 15:17 Go to previous messageGo to next message
Maged Elaasar is currently offline Maged ElaasarFriend
Messages: 529
Registered: July 2009
Senior Member
In the example I gave, it is the location "not" the size that will be
incorrect. so yes the verify listener would make sure there is enough size,
but the locator that does setBounds will initially set incorrect location
then eventually it will set it correctly when the label is laid out. The
flickering in this case is caused by the location movement.


"Randy Hudson" <none@us.ibm.com> wrote in message
news:cbhbpj$i0v$1@eclipse.org...
> In the past, we used to add a Verify Listener to the Text control in the
> Logic Example. This would enlarge the Text widget prior to the new text
> being inserted, which prevents the text from scrolling horizontally when
it
> doesn't fit.
>
> verifyListener = new VerifyListener() {
> public void verifyText(VerifyEvent event) {
> Text text = (Text)getCellEditor().getControl();
> String oldText = text.getText();
> String leftText = oldText.substring(0, event.start);
> String rightText = oldText.substring(event.end, oldText .length());
> GC gc = new GC(text);
> String s = leftText + event.text + rightText;
> Point size = gc.textExtent(leftText + event.text + rightText);
> gc.dispose();
> if (size.x != 0)
> size = text.computeSize(size.x, SWT.DEFAULT);
> getCellEditor().getControl().setSize(size.x, size.y);
> }
> };
>
> The control may still be sized multiple times, but it will not shift the
> text around which I think is causing the flickering.
>
>
> "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> news:cbh6d4$5u1$1@eclipse.org...
> > I just realized that checking for validation won't work since a figure
is
> > validated after it is laid out. Anyways, I think the scenario I am
talking
> > about could also be demostrated as follows:
> >
> > You have a shape that has a name label which is centered in the shape.
> > Adding a new character causes the label to revalidate which will also
> clear
> > its cached local variables including textLocation. As the cell editor
> > locator is listening to the label's ancestors being laid out, it calls
> > getTextBounds() which will cause the textLocation to be recalculated
with
> > the new text but with the old size leading to incorrect bounds. Only
when
> > the label itself is laid out with the correct bounds, that the
> getTextBounds
> > returns correct result.
> >
> > I tried your suggestion of only setting the bounds of the editor with
> unique
> > values which reduced the flickering, however, I still get two unique
> values
> > per character typed, one when the label has new text but old size, and
> > another when it has both the new text and size. This would cause
flicking,
> > especially if the two sizes are way off (it shows more in my case due to
> the
> > text wrapping).
> >
> > I appreciate any more suggestions.
> >
> >
> > "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> > news:cbh2tk$ub3$1@eclipse.org...
> > > The label I am using supports wrapping. So the locator has code like
> that:
> > >
> > > Text text = (Text) celleditor.getControl();
> > > Rectangle rect = getLabel().getTextBounds().getCopy();
> > > getLabel().translateToAbsolute(rect);
> > >
> > > if (getLabel().isTextWrapped())
> > > rect.setSize(new Dimension(text.computeSize(rect.width,
> > rect.height)));
> > > else
> > > rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT,
> > SWT.DEFAULT)));
> > >
> > > if (!rect.equals(new Rectangle(text.getBounds())))
> > > text.setBounds(rect.x, rect.y, rect.width, rect.height);
> > >
> > > The problem with ancestor listening here is that during all the events
I
> > > will be getting except the last one, the label figure will be still
> > > "invalid" (from the addition of the character), which means the
> > > getTextBounds will be calculated using the old size (but with the new
> > text)
> > > which gives incorrect bounds. Eventually when the label is validated,
> the
> > > correct size is set and the bounds returned is correct. However, I see
> the
> > > flickering.
> > >
> > > Do you have a suggestion to fix that? One way I thought of is to check
> if
> > > the label figure is valid before relocating. However, I am not sure if
> > this
> > > is as good as removing the ancestor listening and replacing it with a
> > figure
> > > listener (will I loose something?)
> > >
> > > I appreciate any feedback
> > >
> > >
> > >
> > > "Randy Hudson" <none@us.ibm.com> wrote in message
> > > news:cbcika$97p$1@eclipse.org...
> > > >
> > > > "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> > > > news:cbcguq$5t7$1@eclipse.org...
> > > > > 1- The ancestor listening also happens if the size only has
changed
> > (so
> > > > you
> > > > > could get 5 events) In addition, depending on the layouts used,
> some
> > > >
> > > > I know you get 5 events. But is setBounds() called on the
CellEditor
> > with
> > > 5
> > > > unique values? Just put an optimization in your Locator where you
> don't
> > > > call setBounds() if the location is not changing.
> > > >
> > > > > parents might really move when the label's size changes.
> > > > >
> > > > > 2- Can you elaborate on the case where parents use local
> coordinates?
> > I
> > > > > thought the bounds of the text widget should be based on those of
> the
> > > > label
> > > > > regardless of parents. So if the label does not move (for some
> reason
> > or
> > > > > another) the widget also should not.
> > > >
> > > > If any parent has useLocalCoordinates() returning true, or Viewport
> with
> > > > virtual scrolling.
> > > >
> > > > > "Randy Hudson" <none@us.ibm.com> wrote in message
> > > > > news:cbcfma$344$1@eclipse.org...
> > > > > >
> > > > > > "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> > > > > > news:cbce8d$vq7$1@eclipse.org...
> > > > > > > Hello,
> > > > > > >
> > > > > > > The DirectEditManager installs an ancestor listener on the
> > > editpart's
> > > > > > figure
> > > > > > > and relocates the cell editor upon handling the event. So
> > basically,
> > > > if
> > > > > > the
> > > > > > > label is nested within say 5 containers and one more character
> is
> > > > > > inserted,
> > > > > > > that causes the label to revalidate which means all the
> containers
> > > > will
> > > > > be
> > > > > > > resized appropriately. The problem now is that the relocate
will
> > be
> > > > > called
> > > > > > 5
> > > > > >
> > > > > > Do all 5 containers change their location as well? If the
bounds
> > are
> > > > not
> > > > > > changing there should be no effect. You should only see two
> > changes,
> > > > when
> > > > > > the top-left corner moves, and the size.
> > > > > >
> > > > > > > times, once for each container (in fact the figure will not
have
> > > > resized
> > > > > > > itself appropriately until at the end when its bounds is set).
> > That
> > > > > causes
> > > > > > > the text widget to flicker.
> > > > > > >
> > > > > > > Is there a real reason for the ancestor listening? isn't
figure
> > > bounds
> > > > > > > listening enough? Thanks.
> > > > > >
> > > > > > The parent may have local coordinates and therefore doesn't
> > translate
> > > > its
> > > > > > children.
> > > > > >
> > > > > > > Maged Elaasar
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: DirectEditManager [message #140252 is a reply to message #140122] Fri, 25 June 2004 17:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

So the label's container moves one way, then the label moves the opposite
way later? I can't picture how that would happen. What type of UI are we
talking about?

"Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
news:cbhfm5$qtt$1@eclipse.org...
> In the example I gave, it is the location "not" the size that will be
> incorrect. so yes the verify listener would make sure there is enough
size,
> but the locator that does setBounds will initially set incorrect location
> then eventually it will set it correctly when the label is laid out. The
> flickering in this case is caused by the location movement.
>
Re: DirectEditManager [message #140284 is a reply to message #140252] Fri, 25 June 2004 21:15 Go to previous message
Maged Elaasar is currently offline Maged ElaasarFriend
Messages: 529
Registered: July 2009
Senior Member
I will try to reproduce using the Logic example code...

However the scenario is like this:

1- a character more is inserted in the text cell editor which reflects in
the Label right away.
2- revalidate of the Label is called, which invalidates the Label and all
its ancestors. Invalidate will clear all the cached variables including
textLocation.
3- update manger now does an update and calls validate on all the ancestors
of the label from top down.
4- With every ancestor being laid out and its bounds changing, an event is
fired and the cell editor tries to relocate, so the first event will cause
the locator to call Label.getTextBounds() which will find the cached vars
cleared and hence will try to rebuild them.
5- The situation now is that the Label has the new text (with the added
char) but its "size" is still not updated. Since the calculation of
textLocation uses the size, the resulting location will not be valid.
6- Finally, the label is laid out and the new size is set. This again
invalidates the Label and its cached vars. Again the locator listens to this
and this time the getTextBound tries to build the textLocation but with the
correct size this time.
7- setting the bounds of the cell editor twice with different bounds
(different locations) will cause flickering.

The reason the label location moves with an extra char is that it is
centered in its parent figure....Also, had the locator used
Label.getBounds() vs. Label.getTextBounds() it would have worked fine, since
the bounds with the first event matches that before the char is inserted, so
in essence you get only one new unique bounds to set to the text editor and
no flickering...However I cannot use that bounds since there could be an
icon.

I will try to demo this using Logic design...meanwhile tell me if that makes
sense.


"Randy Hudson" <none@us.ibm.com> wrote in message
news:cbhnt2$aio$1@eclipse.org...
> So the label's container moves one way, then the label moves the opposite
> way later? I can't picture how that would happen. What type of UI are we
> talking about?
>
> "Maged Elaasar" <melaasar@ca.ibm.com> wrote in message
> news:cbhfm5$qtt$1@eclipse.org...
> > In the example I gave, it is the location "not" the size that will be
> > incorrect. so yes the verify listener would make sure there is enough
> size,
> > but the locator that does setBounds will initially set incorrect
location
> > then eventually it will set it correctly when the label is laid out. The
> > flickering in this case is caused by the location movement.
> >
>
>
Previous Topic:Rules and Guides
Next Topic:how to delete an edit part
Goto Forum:
  


Current Time: Thu Mar 28 23:30:02 GMT 2024

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

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

Back to the top