private ArrayList<Change> buildChanges() throws FilesTooBigForDiffException {
   Document base = getDocument(FragmentSide.SIDE1);
   DiffString[] baseLines = DiffUtil.convertToLines(base.getText());
   Document version = getDocument(FragmentSide.SIDE2);
   DiffString[] versionLines = DiffUtil.convertToLines(version.getText());
   DiffFragment[] fragments =
       ComparisonPolicy.DEFAULT.buildDiffFragmentsFromLines(baseLines, versionLines);
   final ArrayList<Change> result = new ArrayList<>();
   new DiffFragmentsEnumerator(fragments) {
     @Override
     protected void process(DiffFragment fragment) {
       if (fragment.isEqual()) return;
       Context context = getContext();
       TextRange range1 = context.createRange(FragmentSide.SIDE1);
       TextRange range2 = context.createRange(FragmentSide.SIDE2);
       result.add(
           new SimpleChange(
               ChangeType.fromDiffFragment(context.getFragment()),
               range1,
               range2,
               ChangeList.this));
     }
   }.execute();
   return result;
 }
 public void setContents(DiffContent content1, DiffContent content2) {
   LOG.assertTrue(content1 != null && content2 != null);
   LOG.assertTrue(!myDisposed);
   myData.setContents(content1, content2);
   Project project = myData.getProject();
   FileType[] types = DiffUtil.chooseContentTypes(new DiffContent[] {content1, content2});
   VirtualFile beforeFile = content1.getFile();
   VirtualFile afterFile = content2.getFile();
   String path = myDiffRequest == null ? null : myDiffRequest.getWindowTitle();
   myLeftSide.setHighlighterFactory(
       createHighlighter(types[0], beforeFile, afterFile, path, project));
   myRightSide.setHighlighterFactory(
       createHighlighter(types[1], afterFile, beforeFile, path, project));
   setSplitterProportion(content1, content2);
   rediff();
   if (myIsRequestFocus) {
     myPanel.requestScrollEditors();
   }
 }
  public void show(DiffRequest request) {
    Collection hints = request.getHints();
    boolean shouldOpenDialog = shouldOpenDialog(hints);
    if (shouldOpenDialog) {
      final DialogBuilder builder = new DialogBuilder(request.getProject());
      DiffPanelImpl diffPanel =
          createDiffPanelIfShouldShow(request, builder.getWindow(), builder, true);
      if (diffPanel == null) {
        Disposer.dispose(builder);
        return;
      }
      if (hints.contains(DiffTool.HINT_DIFF_IS_APPROXIMATE)) {
        diffPanel.setPatchAppliedApproximately(); // todo read only and not variants
      }
      final Runnable onOkRunnable = request.getOnOkRunnable();
      if (onOkRunnable != null) {
        builder.setOkOperation(
            new Runnable() {
              @Override
              public void run() {
                builder.getDialogWrapper().close(0);
                onOkRunnable.run();
              }
            });
      } else {
        builder.removeAllActions();
      }
      builder.setCenterPanel(diffPanel.getComponent());
      builder.setPreferredFocusComponent(diffPanel.getPreferredFocusedComponent());
      builder.setTitle(request.getWindowTitle());
      builder.setDimensionServiceKey(request.getGroupKey());

      new AnAction() {
        public void actionPerformed(final AnActionEvent e) {
          builder.getDialogWrapper().close(0);
        }
      }.registerCustomShortcutSet(
          new CustomShortcutSet(
              KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")),
          diffPanel.getComponent());
      showDiffDialog(builder, hints);
    } else {
      final FrameWrapper frameWrapper =
          new FrameWrapper(request.getProject(), request.getGroupKey());
      DiffPanelImpl diffPanel =
          createDiffPanelIfShouldShow(request, frameWrapper.getFrame(), frameWrapper, true);
      if (diffPanel == null) {
        Disposer.dispose(frameWrapper);
        return;
      }
      if (hints.contains(DiffTool.HINT_DIFF_IS_APPROXIMATE)) {
        diffPanel.setPatchAppliedApproximately();
      }
      frameWrapper.setTitle(request.getWindowTitle());
      DiffUtil.initDiffFrame(
          diffPanel.getProject(), frameWrapper, diffPanel, diffPanel.getComponent());

      new AnAction() {
        public void actionPerformed(final AnActionEvent e) {
          frameWrapper.getFrame().dispose();
        }
      }.registerCustomShortcutSet(
          new CustomShortcutSet(
              KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")),
          diffPanel.getComponent());

      frameWrapper.show();
    }
  }