Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 320237 - [TreeViewer] post selection changes are not handled as expected (as in RCP)
Summary: [TreeViewer] post selection changes are not handled as expected (as in RCP)
Status: NEW
Alias: None
Product: RAP
Classification: RT
Component: JFace (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 320597
  Show dependency tree
 
Reported: 2010-07-19 05:52 EDT by Bogdan B. CLA
Modified: 2010-09-20 04:56 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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)?