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

Bug 108941

Summary: [Viewers] ITreeViewerListener on Tree component reports incorrect expansion state
Product: [Eclipse Project] Platform Reporter: Rajeev Sudra <rajeev>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 Keywords: helpwanted
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug
Attachments:
Description Flags
UI Test to expose the problem none

Description Rajeev Sudra CLA 2005-09-07 11:18:50 EDT
When I have a ITreeViewerListener registered with a TreeViewer, during the 
listeners invocation I expect that event to have already happened.

So by collapsing a node in the tree, during the event handling the TreeItem 
should be collapsed and AbstractTreeViewer.getExpandedState(Object) should 
return false. It returns true. However, after the handling has completed, it 
will return the correct false value.

This worked as expected for TableTreeViewer but not for TreeViewer.
Comment 1 Rajeev Sudra CLA 2005-09-07 11:25:47 EDT
Created attachment 26906 [details]
UI Test to expose the problem

The attachment is a standalone swt application that exposes the problem.

After running the program, selected "choose root folder" and choose a location
in your file system that contains more than one directory.

The Tree should render the collapsed directory structure.

Expand the top node. An ITreeViewerListener is attached which will print all
the expanded nodes followed by "-------------------" to show it has finished.
It will show no expanded nodes.

Select "invoke after expansion" which will print all expanded nodes, this time
outside of the execution of the listener above. This time the expanded node
will be printed to the console.
Comment 2 Steve Northover CLA 2005-09-08 19:44:55 EDT
I'm pretty sure this is a dup of bug 59941 but I'm moving to UI because of the 
JFace code.  Note that the operating systems update the expanded state of the 
node after the notification has been issued so this should be WONTFIX.
Comment 3 Rajeev Sudra CLA 2005-09-09 04:32:37 EDT
The contract for the interface suggests that the event has aready occured (and 
is worded as such). Either the interface should be changed to suggest that the 
event is in pre/mid transaction (so don't rely on the expanded state of the 
item) or the event is fired after the operating system updates the expanded 
state.

Given the current situation, how am I supposed to process the TreeItem's state 
after expanding or collapsing a node in an event driven fashion? During the 
execution of the listener, I walk the TreeItem's to figure out if I should 
hide or display editparts that map to child TreeItems of the collapsed or 
expanded TreeItem. This is a serious limitation in my opinion (but could be 
address by a pre and post listener for expand/collapse event handling? Or to 
honour the ITreeViewerListener contract in terms of event dispatching 
behaviour)

There is ambiguity with how it worked before (atleast with the TableTreeViewer 
and the TreeViewer is suggested as its replacement). Agree?
Comment 4 Boris Bokowski CLA 2007-06-22 10:55:56 EDT
As a workaround, I would suggest spawning an asyncExec which should see the correct expansion state.
Comment 5 Boris Bokowski CLA 2009-11-26 09:54:59 EST
Hitesh is now responsible for watching bugs in the [Viewers] component area.
Comment 6 Eclipse Genie CLA 2019-01-02 13:28:26 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Lars Vogel CLA 2019-09-02 14:54:55 EDT
This bug has been marked as stalebug a while ago without any further interaction.

If this report is still relevant for the current release, please reopen and remove the stalebug whiteboard flag.