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

Bug 346458

Summary: 3 dots null items added on a TreeViewer
Product: [RT] RAP Reporter: Arnaud MERGEY <a_mergey>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: tbuschto
Version: 1.4   
Target Milestone: 1.5 M1   
Hardware: All   
OS: All   
Whiteboard: sr141
Attachments:
Description Flags
snippet to reproduce the issue
none
Proposed patch
tbuschto: review+
Proposed patch
rsternberg: review+, tbuschto: review+
updated snippet
none
updated snippet
none
Ported fix to 1.4 Maintenance branch none

Description Arnaud MERGEY CLA 2011-05-19 10:35:12 EDT
Hello,

Since I upgraded to 1.4 RC1, I have a strange behavior I did not had with 1.4 M7.
I have a snippet allowing to reproduce the issue. With this snippet, I have the issue since RC1, M7 works perfectly.

To summarize,I have an outline view with a treeviewer having a ObservableTreeListContentProvider as content provider, so my tree content is updated when I do some actions on it. My IObservableFactory returns  a MultiList, I cannot explain why, but the issue has something to do with multi list because if I only use an Writable list without Multi list the issue is gone.

The issue is I have some "3 dots" items added in my tree, this items can be selected, but they have no elements, so the label provider is not called for them
Comment 1 Arnaud MERGEY CLA 2011-05-19 10:41:25 EDT
Created attachment 196117 [details]
snippet to reproduce the issue

- Launch snippet.tree application 
- double click on one item on the left tree
- then double click on "next" item on the right tree, you should see the "3 dots items" added
-then you can double click several times on  "previous " item, you will see that the number of "3 dots" items is equals to the number of "normal" items

If you launche the snippet against RC1 you should see the issue, against M7 it should work as expected
I saw the issue with chrome 11 and firefox 4
Comment 2 Ivan Furnadjiev CLA 2011-05-19 10:53:14 EDT
I can reproduce the issue as well.
Comment 3 Ivan Furnadjiev CLA 2011-05-20 09:25:07 EDT
Created attachment 196215 [details]
Proposed patch

itemCount was increased by TreeItem.js#_add. Fixed by removing the last item on add.
Comment 4 Tim Buschtoens CLA 2011-05-20 09:27:58 EDT
Comment on attachment 196215 [details]
Proposed patch

This patch is very much approved.
Comment 5 Ivan Furnadjiev CLA 2011-05-22 03:36:44 EDT
Applied patch to CVS HEAD and v14_Maintenance branch.
Comment 6 Ralf Sternberg CLA 2011-05-22 04:03:19 EDT
Since the patch pops off the last item from the array, it has the potential of deleting created items.
So what happens if the _children array is already filled? In this case creating a new item with an index would silently delete the last item.
This wonder if this is an acceptable client-side API.

However, if we can ensure that the server will always call Tree#setItemCount() *before* new TreeItem(), I'm ok with the fix for RC2.
Comment 7 Ivan Furnadjiev CLA 2011-05-22 04:15:43 EDT
Yes... the server always calls setItemCount before the creation of new child TreeItem(). This is how WidgetTreeVisitor works - first visit the parent (tree)/ parentItem and call setItemsCount on them and afterwards - create the new child items.
Comment 8 Ivan Furnadjiev CLA 2011-05-22 04:18:32 EDT
Just for the record - we discussed with Tim more clear implementation (to set itemCount only from the server and not modify it on the client (call push/pop)), which requires more refactorings, especially in tests. This will be done with Tree/Table client side merge.
Comment 9 Ralf Sternberg CLA 2011-05-22 04:55:27 EDT
Well yes, my thoughts went into the same direction...
Comment 10 Arnaud MERGEY CLA 2011-05-31 16:32:16 EDT
Hello,

This bug does not seems to be totally fixed and some issues are still reproducible.
With my previous snippet, you can try following:

- Launch snippet.tree application 
- double click on one item on the left tree
- then double click on one element on the outline tree (not next or previous)
the next node disappear, even it should not
-then you can double click several times on "previous " item, you will see the "next" item replaced by a "3 dots" item
Comment 11 Ivan Furnadjiev CLA 2011-06-01 05:13:25 EDT
Created attachment 197067 [details]
Proposed patch

With the previous patch we fixed the TreeItem.js#_add method to not change the item count on the client, but didn't fixed the TreeItem.js#_remove method. With this patch the _remove method doesn't change the item count on the client anymore.
Comment 12 Ralf Sternberg CLA 2011-06-01 05:24:29 EDT
Comment on attachment 197067 [details]
Proposed patch

The patch looks safe to me and from my understanding the issue is critical enough to include the fix into the release
Comment 13 Tim Buschtoens CLA 2011-06-01 05:25:58 EDT
Comment on attachment 197067 [details]
Proposed patch

We worked on it together.
Comment 14 Tim Buschtoens CLA 2011-06-01 06:03:35 EDT
Ported and committed the second patch to the "v14_Tree_Table_Merge" branch.
Comment 15 Ivan Furnadjiev CLA 2011-06-01 06:14:22 EDT
Applied second patch to CVS HEAD.
Comment 16 Ralf Sternberg CLA 2011-06-01 09:59:48 EDT
Applied second patch to 1.4 Maintenance branch. the fix will be available with RC3.
Comment 17 Arnaud MERGEY CLA 2011-06-03 03:58:15 EDT
Sorry to reopen it again, but by testing RC3, I found another issue
It can be reproduced with my snippet, but in order to reproduce it faster, the code of my snippet can be changed like this
on top of snippet.tree.outline.MyContentOutlinePage class replace "private final static int SIZE = 20"; by "private final static int SIZE = 2;"

- Launch snippet.tree application 
- double click on one item on the left tree
- then double click on "previous" item on the tree of the outline view

-> previous item is displayed twice

If you do not change the code of my snippet, to reproduce the issue you have to click on "previous" item, until there is only one element in the tree
Comment 18 Ivan Furnadjiev CLA 2011-06-03 04:16:45 EDT
Hi Arnaud, but I think that this is completely different bug... nothing related to "..." :-). Is this working with M7?
Comment 19 Arnaud MERGEY CLA 2011-06-03 04:32:45 EDT
Hi Ivan, 
I have just tested this bug is also reproducible with M7

As the way this issue occurs, I (probably wrongly) thought that this issue was related to the "..." ones.
Do you want I create another bug ?
Comment 20 Ivan Furnadjiev CLA 2011-06-03 04:39:08 EDT
Arnaud, I think that there is a problem in your code. Look at MyContentOutlinePage double click listener. Removing the:
if(size==1){
	lists[0].add(PREVIOUS);
}
fixes the problem, but introduce a new one - clicking on "next" item on empty tree does not add "previouse" item. Could you check your code first (test against RCP if needed)? If you still think that this is a bug please open another bugzilla. I will close this bug as fixed.
Comment 21 Arnaud MERGEY CLA 2011-06-03 05:08:22 EDT
No you are right, the issue was in my code, I am really sorry, I should have been more carreful
Comment 22 Arnaud MERGEY CLA 2011-06-06 14:05:45 EDT
Created attachment 197436 [details]
updated snippet
Comment 23 Arnaud MERGEY CLA 2011-06-06 14:06:04 EDT
I found another "..." issue. I am quite sure it is not related to my code this time, as the issue occurs with 1.4  RC3, I have tested with M7, and there is no "..." issue.

In order to reproduce the issue, with the updated snippet,

- Launch snippet.tree application 
- double click on one item on the left tree
- on outline view expand some items until vertical scrollbar appears
- then scroll down 
- then click on the action item on the oultine view (displayed with ISharedImages.IMG_ELCL_SYNCED icon)

-> you should see almost all items of the tree replaced with "..." items
then there also seems to be some refresh issue, by scrolling in this state.

The action allowing to reproduce the issue, set input on the outline treeviewer and try to restore old expansion state and selection.
It seems to be related to this, as this issue occurs everytime I do this kind of code:

				TreePath[] oldTreePaths = getTreeViewer().getExpandedTreePaths();
				ISelection oldSelection = getTreeViewer().getSelection();
				myLists=new MyLists();
				getTreeViewer().setInput(myLists.list);
				getTreeViewer().setExpandedTreePaths(oldTreePaths);
				getTreeViewer().setSelection(oldSelection);
Comment 24 Arnaud MERGEY CLA 2011-06-06 15:55:30 EDT
Created attachment 197455 [details]
updated snippet
Comment 25 Ivan Furnadjiev CLA 2011-06-07 08:05:04 EDT
Arnaud, we can reproduce the issue and are working on a fix. It's too late to be fixed in 1.4. Will be fixed in HEAD.
Comment 26 Tim Buschtoens CLA 2011-06-08 08:04:23 EDT
I fixed the issue in the v14_Tree_Table_Merge branch. The fixed can not be easily ported to HEAD or 1.4, but will be solved when the branch in merged with HEAD soon.
Comment 27 Ivan Furnadjiev CLA 2011-06-08 10:10:39 EDT
Created attachment 197601 [details]
Ported fix to 1.4 Maintenance branch
Comment 28 Tim Buschtoens CLA 2011-06-09 12:38:06 EDT
Merged v14_Tree_Table_Merge" branch into CVS HEAD (See Bug 332524), which fixes this bug.
Comment 29 Ivan Furnadjiev CLA 2011-08-22 08:32:32 EDT
(In reply to comment #27)
> Created attachment 197601 [details]
> Ported fix to 1.4 Maintenance branch
Applied patch to v14_Maintenance branch.