int colIndex = event.getColumnIndex();
if (rowIndex == -1) {
return;
}
XEvent e = event.getEvent().<XEvent> cast();
if (event.getEvent().getButton() == Event.BUTTON_RIGHT) {
if (selectionMode != SelectionMode.SINGLE && isSelected(listStore.get(rowIndex))) {
return;
}
grid.getView().focusCell(rowIndex, colIndex, false);
select(rowIndex, false);
} else {
M sel = listStore.get(rowIndex);
if (selectionMode == SelectionMode.SIMPLE) {
if (!isSelected(sel)) {
grid.getView().focusCell(rowIndex, colIndex, false);
select(sel, true);
}
} else if (selectionMode == SelectionMode.SINGLE) {
if (e.getCtrlOrMetaKey() && isSelected(sel)) {
deselect(sel);
} else if (!isSelected(sel)) {
grid.getView().focusCell(rowIndex, colIndex, false);
select(sel, false);
}
} else if (!e.getCtrlOrMetaKey()) {
if (event.getEvent().getShiftKey() && lastSelected != null) {
int last = listStore.indexOf(lastSelected);
int index = rowIndex;
grid.getView().focusCell(index, colIndex, false);
select(last, index, e.getCtrlOrMetaKey());
} else if (!isSelected(sel)) {
grid.getView().focusCell(rowIndex, colIndex, false);
doSelect(Collections.singletonList(sel), false, false);
}
}