Package net.sf.mzmine.parameters.parametertypes

Examples of net.sf.mzmine.parameters.parametertypes.AdductsComponent


  @Override
  public void actionPerformed(final ActionEvent e) {

    // Parent component.
    final AdductsComponent parent = (AdductsComponent) SwingUtilities
        .getAncestorOfClass(AdductsComponent.class,
            (Component) e.getSource());

    if (parent != null) {

      // Create the chooser if necessary.
      if (chooser == null) {

        chooser = new LoadSaveFileChooser("Select Adducts File");
        chooser.addChoosableFileFilter(new FileNameExtensionFilter(
            "Comma-separated values files", FILENAME_EXTENSION));
      }

      // Choose the file.
      final File file = chooser.getSaveFile(parent, FILENAME_EXTENSION);
      if (file != null) {

        // Export the adducts.
        try {

          exportAdductsToFile(file,
              (AdductType[]) parent.getChoices());
        } catch (IOException ex) {

          final String msg = "There was a problem writing the adducts file.";
          MZmineCore.getDesktop().displayErrorMessage("I/O Error",
              msg + "\n(" + ex.getMessage() + ')');
View Full Code Here


  @Override
  public void actionPerformed(final ActionEvent e) {

    // Parent component.
    final AdductsComponent parent = (AdductsComponent) SwingUtilities
        .getAncestorOfClass(AdductsComponent.class,
            (Component) e.getSource());

    if (parent != null) {

      // Create the chooser if necessary.
      if (chooser == null) {

        chooser = new LoadSaveFileChooser("Select Adducts File");
        chooser.addChoosableFileFilter(new FileNameExtensionFilter(
            "Comma-separated values files", FILENAME_EXTENSION));
      }

      // Select a file.
      final File file = chooser.getLoadFile(parent);
      if (file != null) {

        // Read the CSV file into a string array.
        String[][] csvLines = null;
        try {

          csvLines = CSVParser.parse(new FileReader(file));
        } catch (IOException ex) {

          final String msg = "There was a problem reading the adducts file.";
          MZmineCore.getDesktop().displayErrorMessage("I/O Error",
              msg + "\n(" + ex.getMessage() + ')');
          LOG.log(Level.SEVERE, msg, ex);
        }

        // Read the adducts data.
        if (csvLines != null) {

          // Load adducts from CSV data into parent choices.
          parent.setChoices(loadAdductsIntoChoices(csvLines,
              (AdductType[]) parent.getChoices()));
        }
      }
    }
  }
View Full Code Here

  @Override
  public void actionPerformed(final ActionEvent e) {

    // Parent component.
    final AdductsComponent parent = (AdductsComponent) SwingUtilities
        .getAncestorOfClass(AdductsComponent.class,
            (Component) e.getSource());

    if (parent != null) {

      // Show dialog.
      final ParameterSet parameters = new AddAdductParameters();
      if (parameters.showSetupDialog() == ExitCode.OK) {

        // Create new adduct.
        final AdductType adduct = new AdductType(parameters
            .getParameter(AddAdductParameters.NAME).getValue(),
            parameters.getParameter(
                AddAdductParameters.MASS_DIFFERENCE).getValue());

        // Add to list of choices (if not already present).
        final Collection<AdductType> choices = new ArrayList<AdductType>(
            Arrays.asList((AdductType[]) parent.getChoices()));
        if (!choices.contains(adduct)) {

          choices.add(adduct);
          parent.setChoices(choices.toArray(new AdductType[choices
              .size()]));
        }
      }
    }
  }
View Full Code Here

  @Override
  public void actionPerformed(final ActionEvent e) {

    // Parent component.
    final AdductsComponent parent = (AdductsComponent) SwingUtilities
        .getAncestorOfClass(AdductsComponent.class,
            (Component) e.getSource());

    if (parent != null) {

      // Reset default choices.
      parent.setChoices(parent.getDefaultChoices());
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.mzmine.parameters.parametertypes.AdductsComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.