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 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 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; }