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

Bug 309291

Summary: [Table] getSelectionIndex() returns -1 after checking/unchecking a checkbox
Product: [RT] RAP Reporter: Manuel Penker <m.penker>
Component: JFaceAssignee: Project Inbox <rap-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

Description Manuel Penker CLA 2010-04-15 07:14:38 EDT
Build Identifier: 20090920-1017

Table table = new Table(parent, SWT.BORDER | SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.CHECK);

table.addListener(SWT.Selection, new Listener()
      {
         /** {@inheritDoc} */
         public void handleEvent(final Event event)
         {
            if (event.detail == SWT.CHECK)
            {
               int index = table.getSelectionIndex();
            }
          }
      });

The table.getSelectionIndex() returns -1.

If you test the same example in RCP, the getSelectionIndex() works fine!!

Reproducible: Always

Steps to Reproduce:
1. check/uncheck a checkbox within a table directly (Don't click on the table row - here the selection index still works)
2. The checkbox will be checked/unchecked, the table row isn't selected
3. The table listener event will be called and the selection index = -1
Comment 1 Ivan Furnadjiev CLA 2010-04-15 07:42:53 EDT
Are you sure that this works in SWT? I've just check it with SWT Controls Demo ( SWT 3.6M6 ) and the checkbox checked/unchecked does not change the selected item - selectionIndex = -1, visually item is not selected. The only difference with your example is that the Table in SWT Controls Demo is not VIRTUAL.
Comment 2 Manuel Penker CLA 2010-04-15 09:55:38 EDT
(In reply to comment #1)
> Are you sure that this works in SWT? I've just check it with SWT Controls Demo
> ( SWT 3.6M6 ) and the checkbox checked/unchecked does not change the selected
> item - selectionIndex = -1, visually item is not selected. The only difference
> with your example is that the Table in SWT Controls Demo is not VIRTUAL.

The table is assigned to a TableViewer like:
TableViewer tableViewer = new TableViewer(table);

Perhaps the tableViewer has the propblem to deal with the table.

Behaviour in RCP:
If I check a checkbox in RCP the whole tablerow will be selected - so, I will get the selection index

Behaviour in RAP:
If I check a checkbox in RAP no tablerow will be selected - so, the selection index = -1
Comment 3 Ivan Furnadjiev CLA 2010-04-19 03:40:59 EDT
I can't reproduce the described RCP behavior with/without TableViewer on Windows. BTW, are you using Linux? Can you provide a complete snippet to reproduce it?
Comment 4 Manuel Penker CLA 2010-04-19 07:35:23 EDT
(In reply to comment #3)
> I can't reproduce the described RCP behavior with/without TableViewer on
> Windows. BTW, are you using Linux? Can you provide a complete snippet to
> reproduce it?

You're right. Under Windows I will have the same problem in our RCP application. If I start our RCP application under Ubuntu Linux the selection works as described.
Comment 5 Ivan Furnadjiev CLA 2010-04-19 09:15:42 EDT
I will close it as WONTFIX as RAP generally respects the Windows SWT behavior.