public Status getStatus() {
    synchronized (builds) {
      if (builds.isEmpty()) {
        return Status.SUCCESSFUL;
      }

      //			Status status = Status.SUCCESSFUL;

      int slide = monitor.settings.getStatusWindow();
      List<BuildFragment> window;
      if (slide == 0 || builds.size() <= slide) {
        window = builds;
      } else {
        window = builds.subList(builds.size() - slide, builds.size());
      }

      for (BuildFragment build : window) {
        if (build.getStatus() == Status.FAILED || build.getStatus() == Status.CANCELLED) {
          return Status.FAILED;
        }
      }

      return Status.SUCCESSFUL;
    }
  }
  public void save(File dir) {
    Element root = DocumentHelper.createElement("builds");
    root.addAttribute("version", VERSION);

    Document doc = DocumentHelper.createDocument(root);

    synchronized (builds) {
      for (BuildFragment build : builds) {
        root.add(build.toXML());
      }
    }

    File file = new File(dir, OUTPUT_NAME);
    try {
      XMLHelper.writeXML(doc, file);
    } catch (MonitorException e) {
      logger.error("Write document " + file + " failed!", e);
    }
  }
  @SuppressWarnings("unchecked")
  public void load(File dir) {
    File file = new File(dir, OUTPUT_NAME);
    if (!file.exists()) {
      return;
    }

    try {
      Document doc = XMLHelper.readXML(file);
      List<Element> elements = doc.getRootElement().elements();

      synchronized (builds) {
        for (Element node : elements) {
          BuildFragment build = new BuildFragment();
          build.fromXML(node);
          builds.add(build);
        }
      }
    } catch (MonitorException e) {
      logger.error("Read document " + file + " failed!", e);
    }
  }