Making some changes
table.setSelcetionMode:

cell listener code broken down into methods
Final version

Consider this as a final working version.