raccoonwao - 2009-02-22

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);