Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 319509

Summary: [Viewers] Empty rows in CheckboxTableViewer with virtual table
Product: [Eclipse Project] Platform Reporter: Ilya <ismagilov>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: RESOLVED FIXED QA Contact: Hitesh <hsoliwal>
Severity: major    
Priority: P3 CC: eclipse.felipe, hsoliwal, ismagilov
Version: 3.6   
Target Milestone: 3.7 M1   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Snippet for reproducing the bug.
none
Patch V01
none
CheckboxTableViewer patched by overriding methods none

Description Ilya CLA 2010-07-12 03:11:14 EDT
Build Identifier: 20100218-1602

If setAllChecked(true) is called on CheckboxTableViewer (based on table with SWT.VIRTUAL flag) and viewer is scrolled down, empty rows are displayed.

Reproducible: Always

Steps to Reproduce:
1. Launch attached snippet. It was taken from http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet029VirtualTableViewer.java?view=markup and modified: CheckboxTableViewer is used and button for checking all items is added.
2. Press button. All items are checked now.
3. Try to scroll down and you will see empty checked rows. If rows are not checked after snippet launch, rows are displayed as expected.
Comment 1 Ilya CLA 2010-07-12 03:12:38 EDT
Created attachment 173995 [details]
Snippet for reproducing the bug.
Comment 2 Hitesh CLA 2010-07-12 07:41:51 EDT
(In reply to comment #0)
> Build Identifier: 20100218-1602
> 
> If setAllChecked(true) is called on CheckboxTableViewer (based on table with
> SWT.VIRTUAL flag) and viewer is scrolled down, empty rows are displayed.
> 
Setting item.setChecked(boolean) before the item(s) have been materialized, will prevent SWT.SetData callback from happening. The viewer relies on this callback even if premature.

Moving to SWT for comment.
Comment 3 Felipe Heidrich CLA 2010-07-12 09:19:16 EDT
(In reply to comment #2)
> Setting item.setChecked(boolean) before the item(s) have been materialized,
> will prevent SWT.SetData callback from happening. The viewer relies on this
> callback even if premature.

If the table is virtual you should only call item.set* during the SetData event.
If you have to call item.setChecked(boolean) any other time you will need to call table.clear(table.indexOf(item)) to cause the SetData event to happen again.
Comment 4 Hitesh CLA 2010-07-12 10:36:47 EDT
(In reply to comment #3)
> 
> If you have to call item.setChecked(boolean) any other time you will need to
> call table.clear(table.indexOf(item)) to cause the SetData event to happen
> again.

I guess the checked state of the item is cleared off as well in case of a call to Table#clear(..) . It would not serve much purpose; this would need to be fixed in the viewer itself.
Comment 5 Hitesh CLA 2010-07-12 11:39:10 EDT
Created attachment 174049 [details]
Patch V01

Patch Released to CVS HEAD.
Comment 6 Hitesh CLA 2010-07-12 11:40:52 EDT
Marking as fixed.
Comment 7 Ilya CLA 2010-07-20 01:48:40 EDT
(In reply to comment #6)
> Marking as fixed.

Could you please check one more time that attached patch solves this bug?

I don`t have prepared environment for Eclipse patching so I created PatchedCheckboxTableViewer as a subclass of CheckboxTableViewer and overrode patched methods with code from patch. 

I still see unchecked rows after pressing button for selecting all rows and scrolling down. I noticed, that only those rows are displayed as checked which were displayed in visible area of table for one time. For example, if you scroll down for some rows down before pressing button, you see these rows are displayed as checked . 

Probably, this is Mac-specific bug. Or may be it is not correct to subclass CheckboxTableViewer and override its method. But I made the same with patch from bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=319600 and that bug was solved.

I am attaching PatchedCheckboxTableViewer where with code from this and bug 319600 patches.
Comment 8 Ilya CLA 2010-07-20 01:50:23 EDT
Created attachment 174697 [details]
CheckboxTableViewer patched by overriding methods
Comment 9 Hitesh CLA 2010-07-20 05:22:26 EDT
(In reply to comment #7)
> (In reply to comment #6)
> > Marking as fixed.
> 
> Could you please check one more time that attached patch solves this bug?
> 

This is the intended behaviour. Forcing an early materialization of items has a cost and simply beats the purpose of having a Virtual Table.I suggest using an ICheckStateProvider which serves this use-case very well. 

> I don`t have prepared environment for Eclipse patching so I created
> PatchedCheckboxTableViewer as a subclass of CheckboxTableViewer and overrode
> patched methods with code from patch. 
> 
> I still see unchecked rows after pressing button for selecting all rows and
> scrolling down. I noticed, that only those rows are displayed as checked which
> were displayed in visible area of table for one time. For example, if you
> scroll down for some rows down before pressing button, you see these rows are
> displayed as checked . 
> 

No, what you notice is exactly what the patch accomplishes. It does not enforce materialization of table items. So we check/uncheck only the items that have already been materialized.

> Probably, this is Mac-specific bug. Or may be it is not correct to subclass
> CheckboxTableViewer and override its method. But I made the same with patch
> from bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=319600 and that bug was
> solved.
> 
> I am attaching PatchedCheckboxTableViewer where with code from this and bug
> 319600 patches.

See Main menu: Help->Help Contents ->Plug-in Development Environment Guide > Tasks > PDE UI 

Forums are another good place for getting answers to your queries http://www.eclipse.org/forums/