private boolean checkLastImage() {
    File file = new File(DesignerApplicationManager.APP_DIR, LAST_PREVIEW_IMAGE_FILE_NAME);
    if (!file.exists()) {
      return false;
    }

    try {
      final VirtualFile virtualFile = toolWindowForm.getFile();
      BufferedImage image =
          IOUtil.readImage(
              file,
              new Processor<DataInputStream>() {
                @Override
                public boolean process(DataInputStream in) {
                  try {
                    return in.readLong() == virtualFile.getTimeStamp()
                        && in.readUTF().equals(virtualFile.getUrl());
                  } catch (IOException e) {
                    throw new RuntimeException(e);
                  }
                }
              });
      if (image != null) {
        toolWindowForm.getPreviewPanel().setImage(image);
        return true;
      }
    } catch (IOException e) {
      LogMessageUtil.LOG.warn("Can't read image for last document", e);
    }

    return false;
  }
 private void saveLastImage(final VirtualFile file) {
   BufferedImage image = toolWindowForm.getPreviewPanel().getImage();
   if (image != null) {
     try {
       IOUtil.saveImage(
           toolWindowForm.getPreviewPanel().getImage(),
           new File(DesignerApplicationManager.APP_DIR, LAST_PREVIEW_IMAGE_FILE_NAME),
           new Consumer<DataOutputStream>() {
             @Override
             public void consume(DataOutputStream out) {
               try {
                 out.writeLong(file.getTimeStamp());
                 out.writeUTF(file.getUrl());
               } catch (IOException e) {
                 throw new RuntimeException(e);
               }
             }
           });
     } catch (Throwable e) {
       LogMessageUtil.LOG.warn("Can't save image for last document", e);
     }
   }
 }