private MergeRequestImpl(
      @NotNull DiffContent left,
      @NotNull DiffContent base,
      @NotNull DiffContent right,
      @Nullable Project project,
      @Nullable final ActionButtonPresentation okButtonPresentation,
      @Nullable final ActionButtonPresentation cancelButtonPresentation) {
    super(project);
    myOkButtonPresentation = okButtonPresentation;
    myCancelButtonPresentation = cancelButtonPresentation;
    myDiffContents[0] = left;
    myDiffContents[1] = base;
    myDiffContents[2] = right;

    if (MergeTool.LOG.isDebugEnabled()) {
      VirtualFile file = base.getFile();
      MergeTool.LOG.debug(
          new Throwable(
              base.getClass()
                  + " - writable: "
                  + base.getDocument().isWritable()
                  + ", contentType: "
                  + base.getContentType()
                  + ", file: "
                  + (file != null ? "valid - " + file.isValid() : "null")
                  + ", presentation: "
                  + myOkButtonPresentation
                  + "-"
                  + myCancelButtonPresentation));
    }
  }
 public static boolean canShowDiff(DiffRequest data) {
   DiffContent[] contents = data.getContents();
   if (contents.length != 2) return false;
   for (DiffContent content : contents) {
     if (content.isBinary()) return false;
     VirtualFile file = content.getFile();
     if (file != null && file.isDirectory()) return false;
   }
   return true;
 }
 public static FileType[] chooseContentTypes(DiffContent[] contents) {
   FileType commonType = FileTypes.PLAIN_TEXT;
   for (DiffContent content : contents) {
     FileType contentType = content.getContentType();
     if (DiffContentUtil.isTextType(contentType)) commonType = contentType;
   }
   FileType[] result = new FileType[contents.length];
   for (int i = 0; i < contents.length; i++) {
     FileType contentType = contents[i].getContentType();
     result[i] = DiffContentUtil.isTextType(contentType) ? contentType : commonType;
   }
   return result;
 }
 private void setSplitterProportion(DiffContent content1, DiffContent content2) {
   if (content1.isEmpty()) {
     mySplitter.setProportion(0f);
     mySplitter.setResizeEnabled(false);
     return;
   }
   if (content2.isEmpty()) {
     mySplitter.setProportion(1.0f);
     mySplitter.setResizeEnabled(false);
     return;
   }
   mySplitter.setProportion(0.5f);
   mySplitter.setResizeEnabled(true);
 }
 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 static boolean isWritable(DiffContent content) {
   Document document = content.getDocument();
   return document != null && document.isWritable();
 }