}
if (selection == null) {
e.preventDefault();
e.stopPropagation();
GridCell cell = grid.walkCells(0, 0, 1, callback);
if (cell != null) {
selectCell(cell.getRow(), cell.getCol());
}
return;
}
int r = selection.getRow();
int c = selection.getCell();
GridCell newCell = null;
switch (e.getKeyCode()) {
case KeyCodes.KEY_HOME:
if (enableNavKeys) {
newCell = grid.walkCells(selection.getRow(), 0, 1, callback);
}
break;
case KeyCodes.KEY_END:
if (enableNavKeys) {
newCell = grid.walkCells(selection.getRow(), grid.getColumnModel().getColumnCount() - 1, -1, callback);
}
break;
case KeyCodes.KEY_PAGEUP:
if (enableNavKeys) {
newCell = grid.walkCells(0, 0, 1, callback);
}
break;
case KeyCodes.KEY_PAGEDOWN:
if (enableNavKeys) {
int idx = listStore.indexOf(listStore.get(listStore.size() - 1));
newCell = grid.walkCells(idx, 0, 1, callback);
}
break;
case KeyCodes.KEY_TAB:
if (e.getShiftKey()) {
newCell = grid.walkCells(r, c - 1, -1, callback);
} else {
newCell = grid.walkCells(r, c + 1, 1, callback);
}
break;
case KeyCodes.KEY_DOWN: {
newCell = grid.walkCells(r + 1, c, 1, callback);
break;
}
case KeyCodes.KEY_UP: {
newCell = grid.walkCells(r - 1, c, -1, callback);
break;
}
case KeyCodes.KEY_LEFT:
newCell = grid.walkCells(r, c - 1, -1, callback);
break;
case KeyCodes.KEY_RIGHT:
newCell = grid.walkCells(r, c + 1, 1, callback);
break;
}
if (newCell != null) {
selectCell(newCell.getRow(), newCell.getCol());
e.preventDefault();
e.stopPropagation();
}
}