@Override
 public void onItemSelected(ContactDetails contactDetails) {
   if (selectionModel.isSelected(contactDetails)) {
     selectionModel.removeSelection(contactDetails);
   } else {
     selectionModel.addSelection(contactDetails);
   }
 }
  private void deleteSelectedContacts() {
    List<ContactDetails> selectedContacts = selectionModel.getSelectedItems();
    ArrayList<String> ids = new ArrayList<String>();

    for (int i = 0; i < selectedContacts.size(); ++i) {
      ids.add(selectedContacts.get(i).getId());
    }

    rpcService.deleteContacts(
        ids,
        new AsyncCallback<ArrayList<ContactDetails>>() {
          @Override
          public void onSuccess(ArrayList<ContactDetails> result) {
            contactDetails = result;
            sortContactDetails();
            view.setRowData(contactDetails);
          }

          @Override
          public void onFailure(Throwable caught) {
            System.out.println("Error deleting selected contacts");
          }
        });
  }