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

Bug 343778

Summary: single-click select in multiple selection in tree fails to update selection for StructuredViewer
Product: [Eclipse Project] Platform Reporter: Andrew Bachmann <AndrewBachmann>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: remy.suen
Version: 3.6.2   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Andrew Bachmann CLA 2011-04-25 18:03:01 EDT
Build Identifier: 20110218-0911

If you select multiple items in a tree widget, and then click on one of the selected items, the others visually deselect but there is no selection event generated.

Looking at StructuredViewer.handleSelect, the result of "getSelection()" when this code is reached is the selection of multiple items, not the new selection of a single item.

This behavior apparently started in Eclipse 3.6.1  (Eclipse 3.6.0 works properly)

As a workaround, we overrode StructuredViewer.handleSelect(SelectionEvent event) with the following:
if (event.stateMask == 0) {
   Widget item = event.item;
   setSelection(Collections.singletonList(item));
}
super.handleSelect(event);

Reproducible: Always

Steps to Reproduce:
1. Open the properties view in Eclipse
2. select a package in the Package Explorer
3. Note the properties view shows the details for the selection
4. Use shift-select to select multiple packages
5. Note the properties view shows no details for a multi-selection
6. Single click on one of the selected packages
7. Note the properties view still shows no details

Clicking off the package and back on reveals details.
Comment 1 Andrew Bachmann CLA 2011-04-25 18:28:51 EDT
This behavior does not happen on Linux.
Comment 2 Andrew Bachmann CLA 2011-05-06 17:24:51 EDT
The (In reply to comment #0)

> As a workaround, we overrode StructuredViewer.handleSelect(SelectionEvent
> event) with the following:
> if (event.stateMask == 0) {
>    Widget item = event.item;
>    setSelection(Collections.singletonList(item));
> }
> super.handleSelect(event);

The above patch is not a satisfactory workaround because it messes up dragging a multi-selection.
Comment 3 Lakshmi P Shanmugam CLA 2012-08-07 05:15:09 EDT
.

*** This bug has been marked as a duplicate of bug 355200 ***