A multi-select KTable perform Shift-selection differently with windows. Shift-click selects every row between the anchor row (first-selected row) and the current row. However, KTable "adds" any row between the anchor row and the current row to the selection without removing any rows previously included.
Try this case:
1. Click at row 10
2. Shift-click at row 12. Now row 10-12 are selected
3. Shift-click at row 8. Now row 8-12 are all selected.
Expected result:
Select 8-10 and remove selection for row11,12.
I have made some change in the KTable.onMouseDown() and KTable.focusCell(int, int, int), which make the shift-selection similar to windows. (This fix is for row-selection mode only, similar fix should be applied to single cell selection mode.
---onMouseDown()-----------------------
if(e.button ==2) {
m_AnchorCol=-1;
m_AnchorRow=-1;
}
Point cell = calcNonSpanColumnNum(e.x, e.y);
if(e.button==1 && (e.stateMask & SWT.CTRL) ==0 && (e.stateMask & SWT.SHIFT) ==0) {
m_AnchorCol= cell.x;
m_AnchorRow = cell.y;
}
----focusCell(int, int, int)-----------------
if (isRowSelectMode()) {
//------------------------Added by me
Iterator rowIt = m_Selection.values().iterator();
int min=0, max=0;
if (rowIt.hasNext()) {
min = ((Integer)rowIt.next()).intValue();
max = min;
}
while (rowIt.hasNext()) {
int r = ((Integer)rowIt.next()).intValue();
if (r<min) min=r;
if (r>max) max=r;
}
clearSelectionWithoutRedraw();
if(row > m_AnchorRow) {
for (int i = m_AnchorRow; i <= row; i++) {
addToSelectionWithoutRedraw(m_FocusCol, i);
}
redraw(0, min, m_Model.getColumnCount(), Math.max(max, row));
}
else {
for (int i = row; i <= m_AnchorRow; i++) {
addToSelectionWithoutRedraw(m_FocusCol, i);
}
redraw(0, Math.min(min, row), m_Model.getColumnCount(), max);
}
fireCellSelection(orig.x, orig.y, stateMask);