Search in sources :

Example 6 with ContentDiffRequest

use of com.intellij.diff.requests.ContentDiffRequest in project intellij-community by JetBrains.

the class OnesideDiffViewer method canShowRequest.

public static <T extends EditorHolder> boolean canShowRequest(@NotNull DiffContext context, @NotNull DiffRequest request, @NotNull EditorHolderFactory<T> factory) {
    if (!(request instanceof ContentDiffRequest))
        return false;
    List<DiffContent> contents = ((ContentDiffRequest) request).getContents();
    if (contents.size() != 2)
        return false;
    DiffContent content1 = contents.get(0);
    DiffContent content2 = contents.get(1);
    if (content1 instanceof EmptyContent) {
        return factory.canShowContent(content2, context) && factory.wantShowContent(content2, context);
    }
    if (content2 instanceof EmptyContent) {
        return factory.canShowContent(content1, context) && factory.wantShowContent(content1, context);
    }
    return false;
}
Also used : ContentDiffRequest(com.intellij.diff.requests.ContentDiffRequest) DiffContent(com.intellij.diff.contents.DiffContent) EmptyContent(com.intellij.diff.contents.EmptyContent)

Example 7 with ContentDiffRequest

use of com.intellij.diff.requests.ContentDiffRequest in project intellij-community by JetBrains.

the class ThreesideDiffViewer method canShowRequest.

public static <T extends EditorHolder> boolean canShowRequest(@NotNull DiffContext context, @NotNull DiffRequest request, @NotNull EditorHolderFactory<T> factory) {
    if (!(request instanceof ContentDiffRequest))
        return false;
    List<DiffContent> contents = ((ContentDiffRequest) request).getContents();
    if (contents.size() != 3)
        return false;
    boolean canShow = true;
    boolean wantShow = false;
    for (DiffContent content : contents) {
        canShow &= factory.canShowContent(content, context);
        wantShow |= factory.wantShowContent(content, context);
    }
    return canShow && wantShow;
}
Also used : ContentDiffRequest(com.intellij.diff.requests.ContentDiffRequest) DiffContent(com.intellij.diff.contents.DiffContent)

Aggregations

DiffContent (com.intellij.diff.contents.DiffContent)7 ContentDiffRequest (com.intellij.diff.requests.ContentDiffRequest)7 Nullable (org.jetbrains.annotations.Nullable)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 DocumentContent (com.intellij.diff.contents.DocumentContent)1 EmptyContent (com.intellij.diff.contents.EmptyContent)1 DiffRequest (com.intellij.diff.requests.DiffRequest)1 SimpleDiffRequest (com.intellij.diff.requests.SimpleDiffRequest)1 Editor (com.intellij.openapi.editor.Editor)1 FileType (com.intellij.openapi.fileTypes.FileType)1 UnknownFileType (com.intellij.openapi.fileTypes.UnknownFileType)1 Project (com.intellij.openapi.project.Project)1