/**
  * Implemented as specified by the {@link Importer} interface.
  *
  * @see Importer#cancelImport()
  */
 public void cancelImport() {
   if (model.getState() != DISCARDED) {
     ImporterUIElement element = view.getSelectedPane();
     if (element != null && !element.isDone() && !element.isLastImport()) {
       MessageBox box = new MessageBox(view, CANCEL_TITLE, CANCEL_SELECTED_TEXT);
       if (box.centerMsgBox() == MessageBox.NO_OPTION) return;
       element.cancelLoading();
       model.cancel(element.getID());
     }
   }
 }
 /**
  * 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);
 }
 /**
  * Implemented as specified by the {@link Importer} interface.
  *
  * @see Importer#cancelAllImports()
  */
 public void cancelAllImports() {
   if (model.getState() != DISCARDED) {
     Collection<ImporterUIElement> list = view.getImportElements();
     List<ImporterUIElement> toImport = new ArrayList<ImporterUIElement>();
     if (list == null || list.size() == 0) return;
     Iterator<ImporterUIElement> i = list.iterator();
     ImporterUIElement element;
     while (i.hasNext()) {
       element = i.next();
       if (!element.isDone() && !element.isLastImport()) toImport.add(element);
     }
     if (toImport.size() > 0) {
       MessageBox box = new MessageBox(view, CANCEL_TITLE, CANCEL_TEXT);
       if (box.centerMsgBox() == MessageBox.NO_OPTION) return;
       i = toImport.iterator();
       while (i.hasNext()) {
         element = i.next();
         element.cancelLoading();
         // if (!element.hasStarted())
         model.cancel(element.getID());
       }
     }
   }
 }
Exemplo n.º 4
0
 /**
  * Brings up on screen the dialog asking a <code>Yes/No</code>.
  *
  * @param index One of the constants defined by this class.
  */
 void setSelection(int index) {
   MessageBox dialog = new MessageBox(this, "Save Image", MESSAGE);
   dialog.pack();
   Dimension d = dialog.getPreferredSize();
   dialog.setSize(d.width, d.height + 30);
   if (dialog.centerMsgBox() == MessageBox.YES_OPTION) {
     dialog.setVisible(false);
     switch (index) {
       case DIRECT:
         saveImage(true);
         break;
       case PREVIEW:
         previewImage();
     }
     dialog.dispose();
   }
 }