Bug 146799 - Blank last table item on virtual table
Summary: Blank last table item on virtual table
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 509006
  Show dependency tree
 
Reported: 2006-06-13 06:40 EDT by Roland Tepp CLA
Modified: 2022-08-29 03:18 EDT (History)
10 users (show)

See Also:


Attachments
Test case demonstrating the problem (1.70 KB, application/octet-stream)
2006-06-13 06:47 EDT, Roland Tepp CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Tepp CLA 2006-06-13 06:40:51 EDT
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.
Comment 1 Roland Tepp CLA 2006-06-13 06:47:05 EDT
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).
Comment 2 Thomas Schindl CLA 2006-06-13 07:15:24 EDT
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?
Comment 3 Grant Gayed CLA 2006-06-30 12:06:36 EDT
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();
}
Comment 4 Steve Northover CLA 2006-06-30 13:43:51 EDT
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.
Comment 5 Steve Northover CLA 2006-06-30 13:45:41 EDT
Should read "Why on earth does JFace do this?".
Comment 6 Boris Bokowski CLA 2006-06-30 13:55:06 EDT
(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.
Comment 7 Roland Tepp CLA 2006-07-03 00:48:13 EDT
(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.
Comment 8 Boris Bokowski CLA 2006-07-05 06:51:11 EDT
(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.
Comment 9 Roland Tepp CLA 2006-10-05 04:39:29 EDT
Has there been any progress made on this bug?

Alternatively - does there exist a work-around for this?
Comment 10 John Sanda CLA 2006-12-18 21:04:31 EST
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.
Comment 11 Boris Bokowski CLA 2006-12-18 23:20:07 EST
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.
Comment 12 Fabian Zeindl CLA 2007-10-27 04:46:50 EDT
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?
Comment 13 Boris Bokowski CLA 2009-02-11 11:54:54 EST
(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.
Comment 14 Marco Schulze CLA 2012-03-29 13:19:37 EDT
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).
Comment 15 Marco Schulze CLA 2012-03-29 13:23:47 EDT
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).
Comment 16 Missing name Mising name CLA 2014-05-20 03:28:46 EDT
This bug is also present on the Mac. I encountered this bug using Eclipse 3.7.2 on MacOS X 10.9.
Comment 17 Marco Descher CLA 2022-08-29 03:18:39 EDT
Still happens on 2022-06