コード例 #1
0
 public void close() {
   setVisible(false);
   dispose();
   if (getCanvas() != null) getCanvas().getIw().close();
   XmippApplication.removeInstance(false);
 }
コード例 #2
0
  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);
    }
  }