Ejemplo n.º 1
0
  /**
   * Parse the repository.
   *
   * @param parser
   * @throws Exception
   */
  private void parseRepository(XmlPullParser parser) throws Exception {
    try {
      parser.require(XmlPullParser.START_DOCUMENT, null, null);
      parser.nextTag();
      if (parser.getName().equals("bundles")) parseOscar(parser);
      else {
        parser.require(XmlPullParser.START_TAG, null, "repository");
        date = parser.getAttributeValue(null, "lastmodified");
        name = parser.getAttributeValue(null, "name");
        if (name == null) name = "Untitled";

        while (parser.nextTag() == XmlPullParser.START_TAG) {
          if (parser.getName().equals("resource")) {
            ResourceImpl resource = new ResourceImpl(this, parser);
            resources.add(resource);
          } else if (parser.getName().equals("referral")) referral(parser);
          else
            throw new IllegalArgumentException(
                "Invalid tag in repository: " + url + " " + parser.getName());
        }
        parser.require(XmlPullParser.END_TAG, null, "repository");
      }
    } catch (XmlPullParserException e) {
      e.printStackTrace();
      throw new IllegalArgumentException(
          "XML unregognized around: " + e.getLineNumber() + " " + e.getMessage());
    }
  }
Ejemplo n.º 2
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