Bug 307375 - [TableViewer] Wrong selection behavior with click on the table header
Summary: [TableViewer] Wrong selection behavior with click on the table header
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: JFace (show other bugs)
Version: 1.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.3 M7   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2010-03-29 07:27 EDT by Wen Ai CLA
Modified: 2010-03-30 07:29 EDT (History)
0 users

See Also:


Attachments
new file for TableViewerTab (22.93 KB, text/plain)
2010-03-29 07:30 EDT, Wen Ai CLA
no flags Details
Proposed patch (2.44 KB, patch)
2010-03-30 05:56 EDT, Ivan Furnadjiev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wen Ai CLA 2010-03-29 07:27:51 EDT
Build Identifier: 

Reproducable with the rap controls demo.

Reproducible: Always

Steps to Reproduce:
1. change the TableViewerTab.java with the attached file and start the rap demo (take sorter away from every column)
2. click the button "Create Cell Editor" and activate the cellediting
3. click on the table header line
4. the cell in 1. column und 1. row is selected, but the table selectionIndex gives -1 back.
Comment 1 Wen Ai CLA 2010-03-29 07:30:14 EDT
Created attachment 163253 [details]
new file for TableViewerTab
Comment 2 Ivan Furnadjiev CLA 2010-03-29 10:39:42 EDT
Checked the same TableViewerTab.java in SWT - the selection index is still -1, but there is NO cell highlighting. There is a RAP specific code in FocusCellOwnerDrawHighlighter#focusCellChanged, which forces new selected cell to be marked:
if( newCell != null ) {
  markFocusedCell(null, newCell);
}
In the original SWT code there is no actual painting (foreground/background change) in that place - only table redraw. One possible solution is to remove the above code from FocusCellOwnerDrawHighlighter#focusCellChanged, but I'm not sure about the consequences on the overall FocusCellOwnerDrawHighlighter behavior.
Comment 3 Wen Ai CLA 2010-03-29 10:53:20 EDT
Hi Ivan,

you said: Checked the same TableViewerTab.java in SWT - the selection index is still -1.
Does it mean, that this bug is also reproducible in swt TableViewerTab? Or I have misunderstanding for that.

Remove some pieces of code from FocusCellOwnerDrawHighlighter#focusCellChanged would make the table selection completely confused. That's not good idea :-( I need this feature always in my apps.

Do you have any other idea to resolve this?

Many thanks.

Wen
Comment 4 Ivan Furnadjiev CLA 2010-03-29 11:17:19 EDT
In SWT, when you click on the columns header area the Table selection is not changed ( Table#getSelectionIndex() returns -1 ) and visually there is NO selected cell. In RAP, Table#getSelectionIndex() returns -1, but  cell( 0, 0 ) is visually marked as selected. The reason for this difference is the code mentioned in comment #2. Wen, did you tested your application with this code:
if( newCell != null ) {
	markFocusedCell(null, newCell);
}
removed from the FocusCellOwnerDrawHighlighter#focusCellChanged? Can you provide an example that demonstrate the confused table selection?
Comment 5 Ivan Furnadjiev CLA 2010-03-30 03:27:21 EDT
OK... without this code... the focused cell is not highlighted at least on key navigation. Need to find a proper fix.
Comment 6 Ivan Furnadjiev CLA 2010-03-30 05:56:39 EDT
Created attachment 163390 [details]
Proposed patch

In FocusCellOwnerDrawHighlighter#focusCellChanged markFocusedCell method is called only if the corresponding item is selected.
Comment 7 Wen Ai CLA 2010-03-30 06:38:57 EDT
Hi Ivan, your patch code works very well. Thanks a lot :-)
Comment 8 Ivan Furnadjiev CLA 2010-03-30 07:29:13 EDT
Applied patch to CVS HEAD.