protected void updateEnablement() {
   try {
     List<JID> contacts =
         SelectionRetrieverFactory.getSelectionRetriever(JID.class).getSelection();
     this.setEnabled(connectionService.isConnected() && contacts.size() == 1);
   } catch (NullPointerException e) {
     this.setEnabled(false);
   } catch (Exception e) {
     if (!PlatformUI.getWorkbench().isClosing())
       LOG.error("Unexpected error while updating enablement", e); // $NON-NLS-1$
   }
 }
  public void runDeleteAction() {
    RosterEntry rosterEntry = null;
    List<RosterEntry> selectedRosterEntries =
        SelectionRetrieverFactory.getSelectionRetriever(RosterEntry.class).getSelection();
    if (selectedRosterEntries.size() == 1) {
      rosterEntry = selectedRosterEntries.get(0);
    }

    if (rosterEntry == null) {
      LOG.error("RosterEntry should not be null at this point!"); // $NON-NLS-1$
      return;
    }

    if (sessionManager != null) {
      // Is the chosen user currently in the session?
      ISarosSession sarosSession = sessionManager.getSarosSession();
      String entryJid = rosterEntry.getUser();

      if (sarosSession != null) {
        for (User p : sarosSession.getUsers()) {
          String pJid = p.getJID().getBase();

          // If so, stop the deletion from completing
          if (entryJid.equals(pJid)) {
            MessageDialog.openError(
                null, Messages.DeleteContactAction_error_title, DELETE_ERROR_IN_SESSION);
            return;
          }
        }
      }
    }

    if (MessageDialog.openQuestion(
        null,
        Messages.DeleteContactAction_confirm_title,
        MessageFormat.format(
            Messages.DeleteContactAction_confirm_message, toString(rosterEntry)))) {

      try {
        XMPPUtils.removeFromRoster(connectionService.getConnection(), rosterEntry);
      } catch (XMPPException e) {
        LOG.error(
            "could not delete contact "
                + toString(rosterEntry) // $NON-NLS-1$
                + ":",
            e); //$NON-NLS-1$
      }
    }
  }