protected void executeScipionSaveAndExit() {
    getCanvas().setEnabled(false);
    XmippWindowUtil.blockGUI(ParticlePickerJFrame.this, "Creating set ...");
    new Thread(
            new Runnable() {

              @Override
              public void run() {

                try {
                  String cmd =
                      String.format(
                          "run function registerCoords '%s'", getParticlePicker().getOutputDir());
                  XmippWindowUtil.runCommand(cmd, getParticlePicker().getParams().port);
                  XmippWindowUtil.releaseGUI(ParticlePickerJFrame.this.getRootPane());
                  getCanvas().setEnabled(true);

                  close();

                } catch (Exception ex) {
                  ex.printStackTrace();
                  throw new IllegalArgumentException(ex.getMessage());
                }
              }
            })
        .start();
  }
    @Override
    public void actionPerformed(ActionEvent e) {
      // Set up the dialog that the button brings up.
      colorChooser = new JColorChooser();
      JDialog dialog =
          JColorChooser.createDialog(
              colorbt,
              "Pick a Color",
              true, // modal
              colorChooser,
              new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                  updateColor(colorChooser.getColor());
                  getParticlePicker().setColor(colorChooser.getColor());
                }
              }, // OK button handler
              null); // no CANCEL button handler
      XmippWindowUtil.setLocation(0.5f, 0.5f, dialog);
      dialog.setVisible(true);
    }
 protected void openHelpURl() {
   XmippWindowUtil.openURI("http://scipion.cnb.csic.es/bin/view/TWiki/Picker");
 }
  public ParticlePickerJFrame(ParticlePicker picker) {
    try {
      File file = new File(Filename.getXmippPath("resources"));
      URL[] urls = new URL[] {file.toURI().toURL()};
      ClassLoader loader = new URLClassLoader(urls);
      bundle = ResourceBundle.getBundle("Bundle", Locale.getDefault(), loader);
      XmippApplication.addInstance(false);
      setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
      addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent winEvt) {

              if (getParticlePicker().isChanged()) {
                XmippQuestionDialog qd =
                    new XmippQuestionDialog(
                        ParticlePickerJFrame.this, "Save changes before closing?");
                boolean save = qd.showDialog();
                if (save) getParticlePicker().saveData();
                else if (qd.isCanceled()) return;
              }
              close();
            }
          });

      initMenuBar(picker);

      resetbt =
          XmippWindowUtil.getTextButton(
              bundle.getString("resetmic"),
              new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                  String resetmsg = getResetMsg();
                  XmippQuestionDialog qd =
                      new XmippQuestionDialog(ParticlePickerJFrame.this, resetmsg, false);
                  if (qd.showDialog()) resetMicrograph();
                }
              });

      savebt =
          XmippWindowUtil.getTextIconButton(
              bundle.getString("save"),
              "save.gif",
              new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                  getParticlePicker().saveData();
                  setChanged(false);
                }
              });

      saveandexitbt =
          XmippWindowUtil.getTextButton(
              bundle.getString("saveandexit"),
              new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {

                  if (getParticlePicker().getMode() != Mode.ReadOnly)
                    getParticlePicker().saveData();
                  if (getParticlePicker().isScipionSave()) {
                    int count = getParticlePicker().getParticlesCount();
                    if (count == 0) {
                      XmippDialog.showInfo(
                          ParticlePickerJFrame.this, XmippMessage.getEmptyFieldMsg("coordinates"));
                      return;
                    }
                    HashMap<String, String> msgfields = new HashMap<String, String>();
                    boolean createprot = getParticlePicker().getPort() == null;
                    if (createprot) msgfields.put("Run name:", "ProtUserCoordinates");

                    String msg =
                        String.format(
                            "<html>Are you sure you want to register a new set of Coordinates with <font color=red>%s</font> %s?",
                            count, (count != 1) ? "elements" : "element");
                    InputFieldsMessageDialog dlg =
                        new InputFieldsMessageDialog(ParticlePickerJFrame.this, "Question", msg);

                    if (dlg.action == InputFieldsMessageDialog.OK_OPTION)
                      executeScipionSaveAndExit();

                  } else close();
                }
              });
      closebt =
          XmippWindowUtil.getTextIconButton(
              "Close",
              "fa-times.png",
              new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                  close();
                }
              });
      if (picker.isScipionSave()) {
        saveandexitbt.setText("Coordinates");
        Image img =
            Toolkit.getDefaultToolkit()
                .getImage(
                    Filename.getXmippPath("resources" + File.separator + "fa-plus-circle.png"));
        saveandexitbt.setIcon(new ImageIcon(img));
        saveandexitbt.setToolTipText("Create Coordinates");
        Color color = XmippWindowUtil.firebrick;
        saveandexitbt.setBackground(color);
        saveandexitbt.setForeground(Color.WHITE);
      }
      micrographstb = new JTable();
      micrographstb
          .getSelectionModel()
          .addListSelectionListener(new MicrographsSelectionListener());
      micrographstb.addMouseListener(
          new MouseListener() {

            @Override
            public void mouseReleased(MouseEvent arg0) {
              // TODO Auto-generated method stub

            }

            @Override
            public void mousePressed(MouseEvent arg0) {
              // TODO Auto-generated method stub

            }

            @Override
            public void mouseExited(MouseEvent arg0) {
              // TODO Auto-generated method stub

            }

            @Override
            public void mouseEntered(MouseEvent arg0) {
              // TODO Auto-generated method stub

            }

            @Override
            public void mouseClicked(MouseEvent arg0) {
              if (micrographstb.getSelectedRow() == -1) return;
              loadMicrograph();
            }
          });
    } catch (Exception ex) {
      Logger.getLogger(ParticlePickerJFrame.class.getName()).log(Level.SEVERE, null, ex);
      throw new IllegalArgumentException(ex);
    }
  }