@Override
    public void itemStateChanged(ItemEvent e) {
      if (ListMailController.this.view.getCurrentHost() != null
          && !ListMailController.this
              .view
              .getCurrentHost()
              .equalsIgnoreCase(Configuration.getCurrentHost())) {
        if (ListMailController.this.view.getCurrentHost() != null) {
          Configuration.setCurrentHost(ListMailController.this.view.getCurrentHost());
        }

        for (MailboxNameChangeListener listener : ListMailController.this.nameChangeListeners) {
          listener.nameChanged(new NameChangeEvent(Configuration.getMyMailboxName()));
        }
        (new RefreshListWorker()).execute();
        try {
          MailboxCache.loadAllMailboxesFromServer();
        } catch (IOException
            | JavaInstallationMissingComponentsException
            | FailedCryptException
            | InvalidSignatureException
            | CommunicationFailureException e1) {
          ListMailController.this.view.setInfo(Utils.ppStackTrace(e1));
        }
      }
    }
 @Override
 protected Void doInBackground() {
   try {
     publish("Retrieving and decrypting mail list");
     String myMailboxName = Configuration.getMyMailboxName();
     if (myMailboxName != null) {
       TotalListItem[] listItems = WebServiceClient.getMailList(myMailboxName);
       for (TotalListItem item : listItems) {
         // decrypt them now, object will cache decrypted--doing it for the side effect
         item.getEncryptedListItem(Configuration.getMyPrivateKey());
       }
       ListMailController.this.model.setItems(listItems);
       publish("Mail list ready.");
       return null;
     }
     publish("No mailbox currently selected");
     ListMailController.this.model.clearItems();
     return null;
   } catch (CommunicationFailureException e) {
     publish(Utils.ppStackTrace(e));
     return null;
   } catch (FailedCryptException | JavaInstallationMissingComponentsException e) {
     publish(Utils.ppStackTrace(e));
     return null;
   } catch (RuntimeException e) {
     System.out.println(Utils.ppStackTrace(e));
     return null;
   }
 }
 @Override
 public void hostDeleted(HostDeleteEvent event) {
   ListMailController.this.view.addAllHosts(Configuration.getHosts());
   if (Configuration.getCurrentHost() != null) {
     ListMailController.this.view.setCurrentHost(Configuration.getCurrentHost());
   }
   (new RefreshListWorker()).execute();
 }
 public ListMailController(ListMailPanel view, EmailList model) {
   this.view = view;
   this.model = model;
   this.view.setModel(this.model);
   view.addAllHosts(Configuration.getHosts());
   if (Configuration.getCurrentHost() != null) {
     view.setCurrentHost(Configuration.getCurrentHost());
     (new RefreshListWorker()).execute();
   }
   view.addRefreshListener(new RefreshCalledListener());
   view.addCreateListener(new CreateMailListener());
   view.addReadListener(new ReadMailListener());
   view.addMouseListener(new DoubleClickListener());
   view.addDeleteListener(new DeleteMailListener());
   view.addHostChangeListener(new HostChangeListener());
 }