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

Bug 235583

Summary: [table] Selecting multiple items sometimes doesn't work
Product: [RT] RAP Reporter: Stefan Röck <stefan.roeck>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2    
Version: 1.0   
Target Milestone: 1.2 RC1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
snippet to reproduce the bug
none
Preliminary bug fix
none
Enhanced snippet to illustrate selection problem with table more clearly none

Description Stefan Röck CLA 2008-06-04 09:10:37 EDT
The attached snippet fills a virtual TableViewer and preselects the first row. If the user wants to mark the first ten records, and he clicks on the tenth row holding the SHIFT-key down
- at the first click, nothing happens
- at the second click the first AND the tenth record are selected, instead of all records between 1-10.
Comment 1 Stefan Röck CLA 2008-06-04 09:12:28 EDT
Created attachment 103542 [details]
snippet to reproduce the bug
Comment 2 Rüdiger Herrmann CLA 2008-06-04 13:03:35 EDT
Thanks for the snippet.
Alternatively, the bug can be reproduced with the ControlsDemo:
- Select "Table" tab
- Select "MULTI"
- add some items
now follow the steps from the description
Comment 3 Rüdiger Herrmann CLA 2008-09-04 02:58:04 EDT
Created attachment 111652 [details]
Preliminary bug fix

This patch synchronizes the server-side focusIndex  with the client-side.
On the client-side, the focusIndex indirectly conrols the start-item of a multi-select (i.e. shift-click). 
Calling one of the setSelection() methods sets the focusIndex to the first item. This is now propagated to the client-side and solves the problem.
Note that calling one of the select() methods does not change the focusIndex.
Comment 4 Stefan Röck CLA 2008-09-05 03:03:59 EDT
Comment on attachment 103542 [details]
snippet to reproduce the bug

obsolte, use new snippet
Comment 5 Stefan Röck CLA 2008-09-05 03:05:58 EDT
Created attachment 111773 [details]
Enhanced snippet to illustrate selection problem with table more clearly
Comment 6 Stefan Röck CLA 2008-09-05 03:11:31 EDT
The problem persists. I modified the test snippet to better reproduce the problem:
- After clicking on one of the buttons "Load new list" or "Delete selected rows", the first record is selected on the table programmatically
- The shell's caption always shows the current selection indices.

The bug ocurrs after
- Clicking on "Load new List" and then Shift-Click on one of the rows below, e.g. 15. (in about 2 of 3 attempts) or
- Selecting several rows, e.g. 0-15, and then click on "Delete selected items". Now, sometimes NO item selection is shown although the selection was set programmatically.
Comment 7 Ralf Sternberg CLA 2009-05-14 06:17:51 EDT
This bug appears to be fixed together with bug 276051. The above patch has been applied to CVS.
Please feel free to reopen if you can still reproduce any of the problems described.
Comment 8 Stefan Röck CLA 2009-05-14 06:37:29 EDT
Thanks for the fix, Ralf. Is it possible to provide a patch so that I can apply this fix to RAP 1.1.2, too? Or could you name all modified files? Thanks.
Comment 9 Ralf Sternberg CLA 2009-05-14 15:35:45 EDT
(In reply to comment #8)
> Thanks for the fix, Ralf. Is it possible to provide a patch so that I can apply
> this fix to RAP 1.1.2, too? Or could you name all modified files? Thanks.
The fix is a semantically equivalent version of the patch above (2nd attachment) with one addition in Table.js. The affected files are the same as affected by the patch. You could try to apply the patch directly to your version and add the following change to Table.js:
In _multiSelectRowClicked, after
  var selectionStart
    = this._selectionStart !== - 1
    ? this._selectionStart
    : this._focusIndex;
  if( selectionStart !== -1 ) {
    var start = Math.min( selectionStart, itemIndex );
    var end = Math.max( selectionStart, itemIndex );
    for( var i = start; i <= end; i++ ) {
      if( !this._isItemSelected( i ) ) {
        this._selectItem( i );
      }
    }
  }
Add this else branch:
  else {
    if( !this._isItemSelected( itemIndex ) ) {
      this._selectItem( itemIndex );
    }
  }