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; }
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 FragmentContent(DiffContent original, TextRange range, Project project, FileType type) { this( original .getDocument() .createRangeMarker(range.getStartOffset(), range.getEndOffset(), true), original, type, project); }
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 FileType getContentType() { return myType != null ? myType : myOriginal.getContentType(); }
public OpenFileDescriptor getOpenFileDescriptor(int offset) { return myOriginal.getOpenFileDescriptor(offset + mySynchonizer.getStartOffset()); }
public void onAssigned(boolean isAssigned) { myOriginal.onAssigned(isAssigned); mySynchonizer.listenDocuments(isAssigned); super.onAssigned(isAssigned); }