@Override
 public void windowStateChanged(final WindowEvent e) {
   if (e.getNewState() == Frame.ICONIFIED) {
     Logger.debug("Window Iconified");
     windowIconifiedEvent();
   } else if (e.getNewState() != Frame.ICONIFIED) {
     Logger.debug("Window Deiconified");
     windowDeiconifiedEvent();
   }
 }
 /** Called to update covers */
 private void update() {
   try {
     SwingUtilities.invokeAndWait(
         new Runnable() {
           @Override
           public void run() {
             GetCoversProcessListener.this.controller.updateCovers();
           }
         });
   } catch (InvocationTargetException e) {
     Logger.error(e);
   } catch (InterruptedException e) {
     Logger.error(e);
   }
 }
 /**
  * Creates and starts a new repository transaction
  *
  * @param repository
  * @param listeners
  */
 public RepositoryTransaction(
     final IRepository repository, final Collection<IRepositoryListener> listeners) {
   this.repository = repository;
   this.listeners = listeners;
   this.pending = true;
   Logger.debug("Creating new repository transaction: ", new DateTime().toString());
 }
 /** Starts auto refresh */
 public void start() {
   stop();
   if (stateRepository.getAutoRepositoryRefreshTime() > 0) {
     Logger.info(
         "Repository will refresh automatically every ",
         stateRepository.getAutoRepositoryRefreshTime(),
         " minutes");
     task =
         taskService.submitPeriodically(
             "RepositoryAutoRefresher",
             30,
             stateRepository.getAutoRepositoryRefreshTime() * 60L,
             this);
   } else {
     Logger.info("Repository will not refresh automatically");
   }
 }
 @Override
 public void run() {
   if (!repositoryHandler.isLoaderWorking()) {
     Logger.info(
         StringUtils.getString(
             "Automatically refreshing repository... (", new DateTime().toString(), ')'));
     repositoryHandler.refreshRepository();
   }
 }
 /** Called when transaction is finished */
 @Override
 public void finishTransaction() {
   if (this.listeners != null) {
     for (IRepositoryListener listener : this.listeners) {
       listener.repositoryChanged(this.repository);
     }
   }
   this.pending = false;
   Logger.debug("Finished repository transaction: ", new DateTime().toString());
 }
 /** Stops auto refresh */
 public void stop() {
   if (task != null) {
     Logger.info("Cancelling previous pending task for automatically refresh repository");
     task.cancel(true);
   }
 }