@Override
  public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
    if (myProgress.isCanceled()) {
      return Printable.NO_SUCH_PAGE;
    }
    while (myFileIndex < myFilesList.size()) {
      if (myTextPainter == null) {
        PsiFile psiFile = myFilesList.get(myFileIndex);
        myTextPainter = TextPrintHandler.initTextPainter(psiFile);
      }
      if (myTextPainter != null) {
        myTextPainter.setProgress(myProgress);

        int ret = 0;
        try {
          ret = myTextPainter.print(g, pageFormat, pageIndex - myStartPageIndex);
        }
        catch (ProcessCanceledException ignored) { }

        if (myProgress.isCanceled()) {
          return Printable.NO_SUCH_PAGE;
        }
        if (ret == Printable.PAGE_EXISTS) {
          myLargestPrintedPage = pageIndex;
          return Printable.PAGE_EXISTS;
        }
        if (myEvenNumberOfPagesPerFile && pageIndex == (myLargestPrintedPage + 1) && (pageIndex % 2) == 1 &&
            myFileIndex < (myFilesList.size() - 1)) {
          return PAGE_EXISTS;
        }
        myTextPainter.dispose();
        myTextPainter = null;
        myStartPageIndex = pageIndex;
      }
      myFileIndex++;
      myLargestPrintedPage = -1;
    }
    return Printable.NO_SUCH_PAGE;
  }
@Override
  public int print(Graphics g, PageFormat pageFormat, int pageIndex)