Community
Participate
Working Groups
When I have virtual table with DeferredContentPovider, the last table item is often blank. This only happends when I scroll the table using scrollbar thumb or arrows. I do not remember seeing this when scrolling with mouse wheel or keyboard. When I scroll with mouse wheel or keyboard, the last item is filled with content from the model.
Created attachment 44251 [details] Test case demonstrating the problem This test case shows the problem. Writing this test case I found out that the empty element appears only when scrolling by using scrollbar arows or dragging its thumb with medium to low speed. When dragging it fast, the last item appears as needed. Also - in this test case - once you click on the blank item, it's label appears, but in my own application, the item stays blank no matter how hard or fast i click on it (this might have something to do with using a label provider though).
This seems to be a SWT-Virtual-Table problem because I cannot duplicate the behaviour on Linux with Eclipse 3.2RC6 but I can on win32 with Eclipse-3.2RC6. Maybe someone from the SWT-Team should look at this problem?
SN, the issue here is that jface is calling Table.getTopIndex() from within the SetData callback, and is not getting the expected answer. It uses this value to compute the set of currently visible items, and from this queries the model elements accordingly. Run the snippet below, and note that after pressing the scrollbar's down button once that Table.getTopIndex() still answers 0, implying that the Table has not scrolled up yet. However on win2000 this scenario answers 1, and the snippet in comment 1 works as expected. public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setBounds(10,10,200,200); final Table table = new Table(shell, SWT.VIRTUAL); table.setBounds(10,10,150,150); table.setItemCount(200); table.addListener(SWT.SetData, new Listener() { public void handleEvent(Event event) { System.out.println("Table topIndex is: " + table.getTopIndex()); ((TableItem)event.item).setText("item " + event.index); } }); shell.open(); while(!shell.isDisposed()) { if(!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Why on earth do we do this? The SWT.SetData event can happen at any time, for any index in the table, when ever the operating system decides that it needs an item, not just for visible items.
Should read "Why on earth does JFace do this?".
(In reply to comment #0) > When I have virtual table with DeferredContentPovider, the last table item is > often blank. Could you please explain how you set up your TableViewer, ideally in the form of a snippet we can run? Thanks.
(In reply to comment #6) > Could you please explain how you set up your TableViewer, ideally in the form > of a snippet we can run? Thanks. > See the attachment for comment 1 with a snippet demonstrating the problem. Basically I just create a table with JFace TableViewer, initialize it with DeferredContentProvider and then set input to initially empty concurrent model instance (basically same as SetModel), which at some later point (in another thread) will be filled with data.
(In reply to comment #7) > See the attachment for comment 1 with a snippet demonstrating the problem. I just read the notification e-mail and did not look at the whole bug. Mea culpa.
Has there been any progress made on this bug? Alternatively - does there exist a work-around for this?
This bug sounds very similar to 92763 and 92769. Both of those bugs were opened up well over a year ago, and I noticed that they were assigned to Boris as well. There has been no indication of any progress with either of them however. Are there plans to improve virtual table support in JFace? I have been looking for code samples for the classes in the org.eclipse.jface.viewers.deferred package, but I cannot fnd anything.
org.eclipse.jface.viewers.deferred is not used by the SDK and thus is not as well-tested as other parts of JFace. Given Steve's and Grant's comments about calling getTopIndex() from the SetData event, I am not even sure if it is possible to fix the bugs in DeferredContentProvider. I haven't made any progress on this because other higher-priority items prevent me from doing anything about it.
What about the snippet that Grant Gayed posted? I have this problem too without jface. Is it safe to always use event.index or table.indexOf(item) instead of table.getTopIndex?
(In reply to comment #12) > Is it safe to always use event.index or table.indexOf(item) instead of > table.getTopIndex? It would be best to ask this question on the SWT newsgroup.
This bug still exists - for already 6 years, now! Will it ever get fixed??? Fortunately I found a workaround, but it's very ugly, because it requires me to manually access my model and call TableViewer.replace(...) in a deferred event (I manually refresh things with a 300 ms delay after I got a paint-event).
Just wanted to add: It is not always the last item. When I scroll down by clicking the arrow (rather than using the mouse wheel), it may even be 5 or 6 items that stay blank. Btw. I use GNU/Linux AMD64 (more precisely a Kubuntu 11.10).
This bug is also present on the Mac. I encountered this bug using Eclipse 3.7.2 on MacOS X 10.9.
Still happens on 2022-06