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

Bug 402122

Summary: [Table][Tree] Items structure out of sync when disposing non-materialized item
Product: [RT] RAP Reporter: Ivan Furnadjiev <ivan>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: abdelilah.nizari, jboehme, mknauer, tbuschto
Version: unspecified   
Target Milestone: 2.1 M2   
Hardware: All   
OS: All   
Whiteboard: protocol
Attachments:
Description Flags
Patch against Controls Demo -> Table Tab to reproduce the issue none

Description Ivan Furnadjiev CLA 2013-03-01 07:31:54 EST
In case of virtual Table/Tree we have non-materialized items both on client and server (placeholders). The Table/Tree structure become out-of-sync if you dispose such an items - call table.getItem( 100 ).dispose() (item 100 is a non-materialized item). In this case the item is materialized and immediately disposed. The creation and disposal of this item is not rendered by the protocol, but only the changed itemCount. As a result "..." items are shown on the screen.
Comment 1 Ivan Furnadjiev CLA 2013-03-01 07:37:15 EST
Created attachment 227796 [details]
Patch against Controls Demo -> Table Tab to reproduce the issue

Steps to reproduce:
1. Patch the Controls Demo with the attached patch
2. Start Controls Demo -> Table Tab
3. Check VIRTUAL checkbox
4. Change the itemCount to 150
5. Fast scroll to the end of the table - the idea is to keep items 100, 101 and 102 non-materialized
5. Click on the button "Dispose items 100, 101, 102"
"..." items appear on the screen and the items structure on the client is different from the server.
Comment 2 Ivan Furnadjiev CLA 2013-03-01 07:43:00 EST
Currently we render the "index" property of the item only in item creation. The solution will be to render this property every time it changes. This will allow as to reorder the materialized items on the client and to keep the items structure in sync.
Comment 3 Ivan Furnadjiev CLA 2013-03-01 09:51:44 EST
Probably same happens if you call one of the Table/Tree remove by index methods on non-materialized items.
Comment 4 Markus Knauer CLA 2013-03-04 07:06:37 EST
We've found an additional case that seems to be very similar to this one.

Given a virtual table viewer with some content. Then the user scrolls down the table and additional items are shown.

Now... we set new content into the table (tableViewer.setIntput(newContent)). The expected behaviour is that the old table content is reset/removed and replaced by the new content, i.e. the table doesn't show any old entries. But the actual behaviour shows the old entries when scrolling down until they are replaced ('virtal') by the new entries.
Comment 5 Tim Buschtoens CLA 2013-03-13 11:22:22 EDT
I'd prefere to render createItem->disposeItem in one response. Otherwise we'd have to re-render the index on ALL resolved+shifted items! Plus, this solution requires no client or protocol changes.
Comment 6 Tim Buschtoens CLA 2013-03-27 06:56:05 EDT
We will solve this by rendering index again if it changes.
Comment 7 Tim Buschtoens CLA 2013-04-05 09:24:32 EDT
Implemented setIndex on GridItem.js with commit fa87eb10cbcad4c9d7929cb07ef797cfc76aa788.
Comment 8 Ivan Furnadjiev CLA 2013-04-05 09:30:15 EDT
Add Tree/Table item index preserve/render with commit df326569171998487724d52141411fc3d02522a9.
Comment 9 Ivan Furnadjiev CLA 2013-04-08 04:10:43 EDT
I found a problem with the current fix:
- item index property is not rendered if TableItem was cleared (see TableItem#renderChanges)
Comment 10 Ivan Furnadjiev CLA 2013-04-08 05:31:08 EDT
(In reply to comment #9)
> - item index property is not rendered if TableItem was cleared (see TableItem#renderChanges)
Fixed in master with commit 97a6ea18d57e03b09469572932048fc4130209fc.