/**
  * Implemented as specified by the {@link Importer} interface.
  *
  * @see Importer#close()
  */
 public void close() {
   if (model.isMaster()) {
     EventBus bus = ImporterAgent.getRegistry().getEventBus();
     bus.post(new ExitApplication());
     return;
   }
   Collection<ImporterUIElement> list = view.getImportElements();
   List<ImporterUIElement> toImport = new ArrayList<ImporterUIElement>();
   if (list == null || list.size() == 0) {
     view.setVisible(false);
     return;
   }
   Iterator<ImporterUIElement> i = list.iterator();
   ImporterUIElement element;
   ImporterUIElement started = null;
   while (i.hasNext()) {
     element = i.next();
     if (element.hasStarted()) started = element;
     if (!element.isDone()) toImport.add(element);
   }
   if (toImport.size() > 0) {
     MessageBox box =
         new MessageBox(
             view,
             CANCEL_TITLE,
             CANCEL_TEXT
                 + "\n"
                 + "If Yes, the window will close when the on-going "
                 + "import is completed.");
     if (box.centerMsgBox() == MessageBox.NO_OPTION) return;
     markToclose = true;
     i = toImport.iterator();
     while (i.hasNext()) {
       element = i.next();
       element.cancelLoading();
       // if (!element.hasStarted())
       model.cancel(element.getID());
     }
     if (started != null && started.isDone()) {
       markToclose = false;
     }
   } else markToclose = false;
   if (!markToclose) view.setVisible(false);
 }