/**
   * Clear the results and display notice to say an error occurred.
   *
   * @param error the error that occurred.
   */
  public void displayErrorResult(final Throwable error) {
    // match some friendly error messages.
    String errorText = null;
    if (error.getCause() != null && error.getCause() instanceof CheckstyleException) {

      for (final Pattern errorPattern : CHECKSTYLE_ERROR_PATTERNS.keySet()) {
        final Matcher errorMatcher = errorPattern.matcher(error.getCause().getMessage());
        if (errorMatcher.find()) {
          final Object[] args = new Object[errorMatcher.groupCount()];

          for (int i = 0; i < errorMatcher.groupCount(); ++i) {
            args[i] = errorMatcher.group(i + 1);
          }

          errorText = CheckStyleBundle.message(CHECKSTYLE_ERROR_PATTERNS.get(errorPattern), args);
        }
      }
    }

    if (errorText == null) {
      errorText = CheckStyleBundle.message("plugin.results.error");
    }

    treeModel.clear();
    treeModel.setRootText(errorText);

    clearProgress();
  }
 /**
  * Expand the error tree to the given level.
  *
  * @param level The level to expand to
  */
 private void expandTree(final int level) {
   expandNode(
       resultsTree,
       treeModel.getVisibleRoot(),
       new TreePath(treeModel.getPathToRoot(treeModel.getVisibleRoot())),
       level);
 }
  /**
   * Display the passed results.
   *
   * @param results the map of checked files to problem descriptors.
   */
  public void displayResults(final Map<PsiFile, List<Problem>> results) {
    treeModel.setModel(results, getDisplayedSeverities());

    invalidate();
    repaint();

    expandTree();
    clearProgress();
  }
  /** Refresh the displayed results based on the current filter settings. */
  public void filterDisplayedResults() {
    // TODO be a little nicer here, maintain display state

    treeModel.filter(getDisplayedSeverities());
  }
  public void displayWarningResult(final String messageKey) {
    clearProgress();

    treeModel.clear();
    treeModel.setRootMessage(messageKey);
  }
  /**
   * Clear the results and display a 'scan in progress' notice.
   *
   * @param size the number of files being scanned.
   */
  public void displayInProgress(final int size) {
    setProgressBarMax(size);

    treeModel.clear();
    treeModel.setRootMessage("plugin.results.in-progress");
  }