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

Bug 324634

Summary: Unable to sort non-moveable columns
Product: z_Archived Reporter: Peer Törngren <mbr-eclipse>
Component: NebulaAssignee: Thomas Schindl <tom.schindl>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: apeeters, deryck, laurent.caron, tom.schindl
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Peer Törngren CLA 2010-09-07 06:15:43 EDT
Build Identifier: 20100617-1415

Due to what appears to be a bug (or at least counter-intuitive behavior) in
the Grid, the column must be moveable in order to be sortable. This appears to be because the code in 'Grid.handleColumnHeaderPush(int, int)' explicitly checks if the column is movable, and bails out to disable "column header push" behavior if it isn't. Hence, no "selection events" are sent unless the column is movable. 

This makes sense in order to disable "push" for moving, but it also disables sorting. The same (false) assumption is made elsewhere; a non-movable grid column is rendered flat to indicate that it cannot be pushed - but you may still want to push it in order to sort it.

This is the actual code in 'Grid.handleColumnHeaderPush(int, int)':

if (cellSelectionEnabled &amp;&amp; overThis.getMoveable() == false) {
    return false;
}


Reproducible: Always

Steps to Reproduce:
1. Create a default grid
2. Make the columns non-movable (setMoveable(false))
3. Add a SelectionListener to the column, have it print all events on System out
4. Run the grid and click the column - no events are printed
5. column.setMoveable(true)
6. Run the grid and click the column - events are printed
Comment 1 Thomas Schindl CLA 2010-09-18 16:27:03 EDT
You are right this makes no sense so I removed the code and released the change
Comment 2 Deryck Brown CLA 2012-03-22 10:02:01 EDT
Build Identifier 20120319-1429

It would appear that this fix has had the side-effect of breaking column selection when in cell selection mode.

With no reference to cellSelectionEnabled in Grid.handleColumnHeaderPush, this method now always consumes the mouse down, and so control never passes to the later code in Grid.onMouseDown that deals with column selection, namely:

6841: else if (cellSelectionEnabled && e.button == 1&& columnHeadersVisible && e.y <= headerHeight) ...

As per other discussions, selection events should not be fired when in cell selection mode and the cell header is clicked.
Comment 3 Thomas Schindl CLA 2012-03-22 11:25:07 EDT
looks like this introduce a regresion
Comment 4 Adriaan Peeters CLA 2012-09-14 06:23:17 EDT
I created a naive fix for the regression in https://github.com/apeeters/nebula/tree/fix_column_selection

It utilizes GridColumn.getSort() to determine whether column sorting is enabled.
Comment 5 Laurent CARON CLA 2019-09-30 11:40:13 EDT
Not reproductible today, I suppose it has been fixed