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

Bug 320237

Summary: [TreeViewer] post selection changes are not handled as expected (as in RCP)
Product: [RT] RAP Reporter: Bogdan B. <bbarzu>
Component: JFaceAssignee: Project Inbox <rap-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: bbarzu, tbuschto
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 320597    

Description Bogdan B. CLA 2010-07-19 05:52:52 EDT
Build Identifier: rap-runtime-1.3.0-R-20100615-1704.zip

I added a post selection changed listener to my TreeViewer (single selection enabled) like this:

TreeViewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
    public void selectionChanged(final SelectionChangedEvent e) {
        System.out.println("post selection changed");
    }
});


The problem is that if I change the selection very quickly by pressing the arrow up or arrow down key, then "post selection changed" is printed out multiple times, once for each traversed (selected) element. But it should occur only once - exactly for the last selected element, isn't it?
Because the JavaDoc of IPostSelectionProvider says:
Quote:
* A post selection changed event is equivalent to selection changed event
* if the selection change was triggered by the mouse, but it has a delay
* if the selection change is triggered by keyboard navigation.

In RCP I see it only once, as expected.

Use case:
I need to open the selected objects from my Tree in corresponding editors. But if I change selection quickly with the keyboard I only need to open the object I stop on. Not to open all traversed objects. Isn't it the use of post selection anyway?

I didn't tested for a TableViewer.

Reproducible: Always
Comment 1 Bogdan B. CLA 2010-07-19 06:02:56 EDT
Wouldn't be a good opportunity to fix it together with the new version of the Tree widget, which will be released in "the next weeks" (https://bugs.eclipse.org/bugs/show_bug.cgi?id=314421#c3)?