Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » ILazyContentProvider updateElement(index) gets called for non-existent elements
ILazyContentProvider updateElement(index) gets called for non-existent elements [message #331291] Fri, 29 August 2008 05:22 Go to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
R3.3; WinXP

I have a virtual TableViewer (i.e., JFace, not SWT), which loads fast
and scrolls nicely; all good.

Now I add filtering, done via the content-provider and my model-class,
i.e., GUI-events cause model-changes, which change the total number of
items to be shown in the table, and the content-provider is asked to
recreate the array of elements (the model produces that array quite
rapidly, order of 10's to a few 100 msec, so no problems there).

For example, the filter might reduce the number of elements from 300 to
60, say.

My ILazyContentProvider.updateElement(int index) has code like this:

<code n="1">
if (index < _elements.length) {
_viewer.replace(_elements[index], index);
} else {
System.err.println("updateElement(), attempt to " +
"refresh element at invalid index: " + index);
}
</code>


When the notifications reach the object that owns the TableViewer (which
is there called "_viewer"), the code is like this:

<code n="2">
_viewer.getControl().setRedraw(false);

// this must be called before _viewer.refresh():
_viewer.setItemCount(myModel.size());

_viewer.refresh();
// causes an undesired set-Selection event
// and calls updateElement()

_viewer.getControl().setRedraw(true);
</code>

When that code is executed, the updateElement() method is called for
*every* "now missing" element, with this (partial) call-stack:
TableViewer(AbstractTableViewer).getVirtualSelection() line: 494
TableViewer(AbstractTableViewer).getSelectionFromWidget() line: 465
TableViewer(StructuredViewer).getSelection() line: 972
TableViewer(StructuredViewer).preservingSelection(Runnable, boolean)
line: 1364
TableViewer(StructuredViewer).preservingSelection(Runnable) line: 1330
TableViewer(StructuredViewer).refresh(Object) line: 1431
TableViewer(ColumnViewer).refresh(Object) line: 503
TableViewer(StructuredViewer).refresh() line: 1390
(next entry is my call "_viewer.refresh()")

Furthermore, if I scroll at this point, I get a slew of null elements
passed to my LabelProvider, here:
OwnerDrawLabelProvider$2.handleEvent(Event) line: 68
EventTable.sendEvent(Event) line: 66
Table(Widget).sendEvent(Event) line: 938
Table(Widget).sendEvent(int, Event, boolean) line: 962
Table(Widget).sendEvent(int, Event) line: 947
Table.sendPaintItemEvent(TableItem, NMLVCUSTOMDRAW) line: 3444
(where the event.item.getData() is null ...)

This all has the result that the TableViewer, when showing the filtered
data, i.e., the 60 items, still scrolls through a space for 300 items --
i.e., there is a huge amount of empty space at the "bottom" of the Table
in the GUI.

Moreover, depending on the exact scroll position at the time of
filtering, and other conditions (unclear what), the visible items are
often wrong (i.e., the wrong set is shown); that I can get around by
prepending to the <code n="2"> these calls:

<code n="2-prefix">
_viewer.setItemCount(0);
final MyModel model = getInput(); // i.e., the current state
_viewer.setInput(model);
_viewer.setItemCount(model.size());
</code>

=============================

This behavior seems wrong. Is this a manifestation of something like
https://bugs.eclipse.org/bugs/show_bug.cgi?id=235983 or else
https://bugs.eclipse.org/bugs/show_bug.cgi?id=144406 ?
Or am I doing something wrong?

thanks,
Paul

(Aside: the TableViewer also has sorting, also performed in the
content-provider, and the first time the user causes a sort, this error
is logged:
!ENTRY org.eclipse.jface 2 0 2008-08-28 23:54:11.921
!MESSAGE Ignored reentrant call while viewer is busy. This is only
logged once per viewer instance, but similar calls will still be ignored.
!STACK 0
java.lang.RuntimeException
at org.eclipse.jface.viewers.ColumnViewer.isBusy(ColumnViewer.j ava:79)
at
org.eclipse.jface.viewers.AbstractTableViewer.replace(Abstra ctTableViewer.java:1035)

from the call to _viewer.replace(...) -- that is also a mystery to me,
mentioned here as it may be a clue.)
Re: ILazyContentProvider updateElement(index) gets called for non-existent elements [message #331293 is a reply to message #331291] Fri, 29 August 2008 07:20 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Could you please provide a simple Snippet to reproduce?

Tom

Paul Th. Keyser schrieb:
> R3.3; WinXP
>
> I have a virtual TableViewer (i.e., JFace, not SWT), which loads fast
> and scrolls nicely; all good.
>
> Now I add filtering, done via the content-provider and my model-class,
> i.e., GUI-events cause model-changes, which change the total number of
> items to be shown in the table, and the content-provider is asked to
> recreate the array of elements (the model produces that array quite
> rapidly, order of 10's to a few 100 msec, so no problems there).
>
> For example, the filter might reduce the number of elements from 300 to
> 60, say.
>
> My ILazyContentProvider.updateElement(int index) has code like this:
>
> <code n="1">
> if (index < _elements.length) {
> _viewer.replace(_elements[index], index);
> } else {
> System.err.println("updateElement(), attempt to " +
> "refresh element at invalid index: " + index);
> }
> </code>
>
>
> When the notifications reach the object that owns the TableViewer (which
> is there called "_viewer"), the code is like this:
>
> <code n="2">
> _viewer.getControl().setRedraw(false);
>
> // this must be called before _viewer.refresh():
> _viewer.setItemCount(myModel.size());
>
> _viewer.refresh();
> // causes an undesired set-Selection event
> // and calls updateElement()
>
> _viewer.getControl().setRedraw(true);
> </code>
>
> When that code is executed, the updateElement() method is called for
> *every* "now missing" element, with this (partial) call-stack:
> TableViewer(AbstractTableViewer).getVirtualSelection() line: 494
> TableViewer(AbstractTableViewer).getSelectionFromWidget() line: 465
> TableViewer(StructuredViewer).getSelection() line: 972
> TableViewer(StructuredViewer).preservingSelection(Runnable, boolean)
> line: 1364
> TableViewer(StructuredViewer).preservingSelection(Runnable) line: 1330
> TableViewer(StructuredViewer).refresh(Object) line: 1431
> TableViewer(ColumnViewer).refresh(Object) line: 503
> TableViewer(StructuredViewer).refresh() line: 1390
> (next entry is my call "_viewer.refresh()")
>
> Furthermore, if I scroll at this point, I get a slew of null elements
> passed to my LabelProvider, here:
> OwnerDrawLabelProvider$2.handleEvent(Event) line: 68
> EventTable.sendEvent(Event) line: 66
> Table(Widget).sendEvent(Event) line: 938
> Table(Widget).sendEvent(int, Event, boolean) line: 962
> Table(Widget).sendEvent(int, Event) line: 947
> Table.sendPaintItemEvent(TableItem, NMLVCUSTOMDRAW) line: 3444
> (where the event.item.getData() is null ...)
>
> This all has the result that the TableViewer, when showing the filtered
> data, i.e., the 60 items, still scrolls through a space for 300 items --
> i.e., there is a huge amount of empty space at the "bottom" of the Table
> in the GUI.
>
> Moreover, depending on the exact scroll position at the time of
> filtering, and other conditions (unclear what), the visible items are
> often wrong (i.e., the wrong set is shown); that I can get around by
> prepending to the <code n="2"> these calls:
>
> <code n="2-prefix">
> _viewer.setItemCount(0);
> final MyModel model = getInput(); // i.e., the current state
> _viewer.setInput(model);
> _viewer.setItemCount(model.size());
> </code>
>
> =============================
>
> This behavior seems wrong. Is this a manifestation of something like
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=235983 or else
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=144406 ?
> Or am I doing something wrong?
>
> thanks,
> Paul
>
> (Aside: the TableViewer also has sorting, also performed in the
> content-provider, and the first time the user causes a sort, this error
> is logged:
> !ENTRY org.eclipse.jface 2 0 2008-08-28 23:54:11.921
> !MESSAGE Ignored reentrant call while viewer is busy. This is only
> logged once per viewer instance, but similar calls will still be ignored.
> !STACK 0
> java.lang.RuntimeException
> at org.eclipse.jface.viewers.ColumnViewer.isBusy(ColumnViewer.j ava:79)
> at
> org.eclipse.jface.viewers.AbstractTableViewer.replace(Abstra ctTableViewer.java:1035)
>
>
> from the call to _viewer.replace(...) -- that is also a mystery to me,
> mentioned here as it may be a clue.)
>
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Previous Topic:resource still out of sync after refreshLocal
Next Topic:Making IEditorPart Read Only
Goto Forum:
  


Current Time: Sat Aug 17 09:20:36 GMT 2024

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

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

Back to the top