@NotNull
      @Override
      public DiffRequest process(
          @NotNull UserDataHolder context, @NotNull ProgressIndicator indicator)
          throws DiffRequestProducerException, ProcessCanceledException {
        try {
          DiffContent content1;
          DiffContent content2;

          if (FileStatus.ADDED.equals(myFileStatus)) {
            content1 = DiffContentFactory.getInstance().createEmpty();
          } else {
            byte[] bytes1 = loadContent(myFilePointer, myBefore);
            content1 =
                DiffContentFactoryImpl.getInstanceImpl()
                    .createFromBytes(myProject, myFilePath, bytes1);
          }

          if (FileStatus.DELETED.equals(myFileStatus)) {
            content2 = DiffContentFactory.getInstance().createEmpty();
          } else {
            byte[] bytes2 = loadContent(myFilePointer, myAfter);
            content2 =
                DiffContentFactoryImpl.getInstanceImpl()
                    .createFromBytes(myProject, myFilePath, bytes2);
          }

          String title = DiffRequestFactoryImpl.getContentTitle(myFilePath);
          return new SimpleDiffRequest(title, content1, content2, "Before update", "After update");
        } catch (IOException e) {
          throw new DiffRequestProducerException("Can't load content", e);
        }
      }
Exemplo n.º 2
0
    @NotNull
    @Override
    protected DiffRequest loadRequest(
        @NotNull ElementWrapper element, @NotNull ProgressIndicator indicator)
        throws ProcessCanceledException, DiffRequestProducerException {
      final Project project = myModel.getProject();
      DiffElement sourceElement = element.sourceElement;
      DiffElement targetElement = element.targetElement;

      DiffContent sourceContent =
          sourceElement != null
              ? sourceElement.createDiffContent(project, indicator)
              : DiffContentFactory.getInstance().createEmpty();
      DiffContent targetContent =
          targetElement != null
              ? targetElement.createDiffContent(project, indicator)
              : DiffContentFactory.getInstance().createEmpty();

      return new SimpleDiffRequest(null, sourceContent, targetContent, null, null);
    }