@Override public void widgetSelected(final SelectionEvent e){
  final TableItem item;
  int nextIndex;
  final int currentIndex=table.getSelectionIndex();
  final int lastIndex=table.getItemCount();
  if (table.getSelectionIndices().length == 0) {
    nextIndex=lastIndex;
    item=new TableItem(table,SWT.CENTER);
    item.setText(0,String.valueOf(nextIndex));
  }
 else {
    nextIndex=currentIndex + 1;
    item=new TableItem(table,SWT.CENTER,nextIndex);
    item.setText(0,String.valueOf(nextIndex));
  }
  item.setBackground(0,gray);
  table.deselect(currentIndex);
  table.select(nextIndex);
  refreshColumnIndex(nextIndex);
}

@ Override public void widgetSelected ( final SelectionEvent e ) { final TableItem item ; int nextIndex ; final int currentIndex = table . getSelectionIndex ( ) ; final int lastIndex = table . getItemCount ( ) ; if ( table . getSelectionIndices ( ) . length == 0 ) { nextIndex = lastIndex ; item = new TableItem ( table , SWT . CENTER ) ; item . setText ( 0 , String . valueOf ( nextIndex ) ) ; } else { nextIndex = currentIndex + 1 ; item = new TableItem ( table , SWT . CENTER , nextIndex ) ; item . setText ( 0 , String . valueOf ( nextIndex ) ) ; } item . setBackground ( 0 , gray ) ; table . deselect ( currentIndex ) ; table . select ( nextIndex ) ; refreshColumnIndex ( nextIndex ) ; }
add a row and refresh the view
