diff options
Diffstat (limited to 'platform/platform-api/src/com/intellij/openapi/diff')
3 files changed, 22 insertions, 3 deletions
diff --git a/platform/platform-api/src/com/intellij/openapi/diff/DiffRequestFactory.java b/platform/platform-api/src/com/intellij/openapi/diff/DiffRequestFactory.java index 78f07a04b4a9..e2c9175ac915 100644 --- a/platform/platform-api/src/com/intellij/openapi/diff/DiffRequestFactory.java +++ b/platform/platform-api/src/com/intellij/openapi/diff/DiffRequestFactory.java @@ -16,6 +16,7 @@ package com.intellij.openapi.diff; import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; @@ -59,4 +60,12 @@ public abstract class DiffRequestFactory { Project project, @Nullable ActionButtonPresentation okButtonPresentation, @Nullable ActionButtonPresentation cancelButtonPresentation); + + public abstract MergeRequest create3WayDiffRequest(String leftText, + String rightText, + String originalContent, + @Nullable FileType type, + Project project, + @Nullable ActionButtonPresentation okButtonPresentation, + @Nullable ActionButtonPresentation cancelButtonPresentation); } diff --git a/platform/platform-api/src/com/intellij/openapi/diff/FragmentContent.java b/platform/platform-api/src/com/intellij/openapi/diff/FragmentContent.java index 26537316b4e9..d630bad790df 100644 --- a/platform/platform-api/src/com/intellij/openapi/diff/FragmentContent.java +++ b/platform/platform-api/src/com/intellij/openapi/diff/FragmentContent.java @@ -41,18 +41,28 @@ public class FragmentContent extends DiffContent { private final FileType myType; private final MyDocumentsSynchronizer mySynchonizer; public static final Key<Document> ORIGINAL_DOCUMENT = new Key<Document>("ORIGINAL_DOCUMENT"); + private final boolean myForceReadOnly; public FragmentContent(@NotNull DiffContent original, @NotNull TextRange range, Project project, VirtualFile file) { - this(original, range, project, file != null ? DiffContentUtil.getContentType(file) : null); + this(original, range, project, file, false); + } + + public FragmentContent(@NotNull DiffContent original, @NotNull TextRange range, Project project, VirtualFile file, boolean forceReadOnly) { + this(original, range, project, file != null ? DiffContentUtil.getContentType(file) : null, forceReadOnly); } public FragmentContent(@NotNull DiffContent original, @NotNull TextRange range, Project project, FileType fileType) { + this(original, range, project, fileType, false); + } + + public FragmentContent(@NotNull DiffContent original, @NotNull TextRange range, Project project, FileType fileType, boolean forceReadOnly) { RangeMarker rangeMarker = original.getDocument().createRangeMarker(range.getStartOffset(), range.getEndOffset(), true); rangeMarker.setGreedyToLeft(true); rangeMarker.setGreedyToRight(true); mySynchonizer = new MyDocumentsSynchronizer(project, rangeMarker); myOriginal = original; myType = fileType; + myForceReadOnly = forceReadOnly; } public FragmentContent(DiffContent original, TextRange range, Project project) { @@ -152,7 +162,7 @@ public class FragmentContent extends DiffContent { String textInRange = originalDocument.getCharsSequence().subSequence(myRangeMarker.getStartOffset(), myRangeMarker.getEndOffset()).toString(); final Document result = EditorFactory.getInstance().createDocument(textInRange); - result.setReadOnly(!originalDocument.isWritable()); + result.setReadOnly(myForceReadOnly || !originalDocument.isWritable()); result.putUserData(ORIGINAL_DOCUMENT, originalDocument); return result; } diff --git a/platform/platform-api/src/com/intellij/openapi/diff/MergeRequest.java b/platform/platform-api/src/com/intellij/openapi/diff/MergeRequest.java index 29243f7b9be0..ce8d56044f96 100644 --- a/platform/platform-api/src/com/intellij/openapi/diff/MergeRequest.java +++ b/platform/platform-api/src/com/intellij/openapi/diff/MergeRequest.java @@ -25,7 +25,7 @@ import org.jetbrains.annotations.Nullable; * @see DiffRequestFactory#createMergeRequest */ public abstract class MergeRequest extends DiffRequest { - protected MergeRequest(Project project) { + protected MergeRequest(@Nullable Project project) { super(project); } |