예제 #1
0
  /**
   * Opens a file chooser for importing method settings.
   *
   * @param evt
   */
  private void browseConfigButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_browseConfigButtonActionPerformed

    if (txtConfigurationFileLocation.getText().length() > 0) {
      newDialog
          .getReporterGui()
          .getLastSelectedFolder()
          .setLastSelectedFolder(txtConfigurationFileLocation.getText());
    }

    File selectedFile =
        Util.getUserSelectedFile(
            this,
            ".xml",
            "Reporter Method File (*.xml)",
            "Select Settings File",
            newDialog.getReporterGui().getLastSelectedFolder().getLastSelectedFolder(),
            null,
            true);

    if (selectedFile != null) {
      try {
        methodsFactory.importMethods(selectedFile);
        newDialog.setSelectedMethod(newDialog.getMethod(newDialog.getSelectedMethod().getName()));
        newDialog.setReagents(newDialog.getSelectedMethod().getReagentsSortedByMass());
        refresh();
        txtConfigurationFileLocation.setText(selectedFile.getAbsolutePath());
        newDialog.setMethodsFile(selectedFile);
        newDialog
            .getReporterGui()
            .getLastSelectedFolder()
            .setLastSelectedFolder(selectedFile.getPath());
      } catch (IOException e) {
        JOptionPane.showMessageDialog(
            null,
            "File " + selectedFile.getAbsolutePath() + " not found.",
            "File Not Found",
            JOptionPane.WARNING_MESSAGE);
      } catch (XmlPullParserException e) {
        JOptionPane.showMessageDialog(
            null,
            "An error occurred while parsing "
                + selectedFile.getAbsolutePath()
                + " at line "
                + e.getLineNumber()
                + ".",
            "Parsing Error",
            JOptionPane.WARNING_MESSAGE);
        e.printStackTrace();
      }
    }
  } // GEN-LAST:event_browseConfigButtonActionPerformed
예제 #2
0
  /**
   * Save the method settings.
   *
   * @param evt
   */
  private void saveConfigButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_saveConfigButtonActionPerformed

    String tempFileName = null;
    if (txtConfigurationFileLocation.getText().length() > 0) {
      newDialog
          .getReporterGui()
          .getLastSelectedFolder()
          .setLastSelectedFolder(txtConfigurationFileLocation.getText());
      tempFileName = new File(txtConfigurationFileLocation.getText()).getName();
    }

    File selectedFile =
        Util.getUserSelectedFile(
            this,
            ".xml",
            "Reporter Method File (*.xml)",
            "Save Settings File",
            newDialog.getReporterGui().getLastSelectedFolder().getLastSelectedFolder(),
            tempFileName,
            false);

    if (selectedFile != null) {
      try {
        methodsFactory.saveFile(selectedFile);
        newDialog.setMethodsFile(selectedFile);
        txtConfigurationFileLocation.setText(selectedFile.getAbsolutePath());
        valuesChanged = false;
        JOptionPane.showMessageDialog(
            null,
            "Settings saved to " + selectedFile.getAbsolutePath() + ".",
            "Settings Saved",
            JOptionPane.INFORMATION_MESSAGE);
      } catch (IOException ex) {
        JOptionPane.showMessageDialog(
            null,
            "An error occured when saving the file.",
            "File Error",
            JOptionPane.WARNING_MESSAGE);
        ex.printStackTrace();
      }
    }
  } // GEN-LAST:event_saveConfigButtonActionPerformed