Search in sources :

Example 1 with DiffContent

use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.

the class FileWithBranchComparer method showResult.

@Override
protected void showResult() {
    if (!success.isNull()) {
        String title = SvnBundle.message("compare.with.branch.diff.title");
        String title1 = remoteTitleBuilder.toString();
        String title2 = myVirtualFile.getPresentableUrl();
        try {
            DiffContent content1 = DiffContentFactory.getInstance().createFromBytes(myProject, content.get(), myVirtualFile);
            DiffContent content2 = DiffContentFactory.getInstance().create(myProject, myVirtualFile);
            DiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2);
            DiffManager.getInstance().showDiff(myProject, request);
        } catch (IOException e) {
            reportGeneralException(e);
        }
    }
}
Also used : SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) DiffRequest(com.intellij.diff.requests.DiffRequest) IOException(java.io.IOException) DiffContent(com.intellij.diff.contents.DiffContent)

Example 2 with DiffContent

use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.

the class TestDiffRequestProcessor method loadRequest.

@NotNull
private DiffRequest loadRequest() {
    if (myIndex < 0 || myIndex >= myRequests.size())
        return NoDiffRequest.INSTANCE;
    DiffHyperlink hyperlink = myRequests.get(myIndex);
    try {
        String windowTitle = hyperlink.getDiffTitle();
        String text1 = hyperlink.getLeft();
        String text2 = hyperlink.getRight();
        VirtualFile file1 = findFile(hyperlink.getFilePath());
        VirtualFile file2 = findFile(hyperlink.getActualFilePath());
        DiffContent content1 = createContentWithTitle(getProject(), text1, file1, file2);
        DiffContent content2 = createContentWithTitle(getProject(), text2, file2, file1);
        String title1 = getContentTitle("diff.content.expected.title", file1);
        String title2 = getContentTitle("diff.content.actual.title", file2);
        return new SimpleDiffRequest(windowTitle, content1, content2, title1, title2);
    } catch (Exception e) {
        return new ErrorDiffRequest(e);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) ErrorDiffRequest(com.intellij.diff.requests.ErrorDiffRequest) DiffHyperlink(com.intellij.execution.testframework.stacktrace.DiffHyperlink) DiffContent(com.intellij.diff.contents.DiffContent) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with DiffContent

use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.

the class FileHistoryDialogTest method assertDiffContents.

private void assertDiffContents(String leftContent, String rightContent, FileHistoryDialogModel m) throws IOException {
    DiffContent left = getLeftDiffContent(m);
    DiffContent right = getRightDiffContent(m);
    assertContent(leftContent, left);
    assertContent(rightContent, right);
}
Also used : DiffContent(com.intellij.diff.contents.DiffContent)

Example 4 with DiffContent

use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.

the class AnnotateDiffViewerAction method createTwosideAnnotationsLoader.

@Nullable
private static FileAnnotationLoader createTwosideAnnotationsLoader(@NotNull Project project, @NotNull DiffRequest request, @NotNull Side side) {
    Change change = request.getUserData(ChangeDiffRequestProducer.CHANGE_KEY);
    if (change != null) {
        ContentRevision revision = side.select(change.getBeforeRevision(), change.getAfterRevision());
        if (revision != null) {
            AbstractVcs vcs = ChangesUtil.getVcsForChange(change, project);
            if (revision instanceof CurrentContentRevision) {
                VirtualFile file = ((CurrentContentRevision) revision).getVirtualFile();
                FileAnnotationLoader loader = doCreateAnnotationsLoader(project, vcs, file);
                if (loader != null)
                    return loader;
            } else {
                FileAnnotationLoader loader = doCreateAnnotationsLoader(vcs, revision.getFile(), revision.getRevisionNumber());
                if (loader != null)
                    return loader;
            }
        }
    }
    if (request instanceof ContentDiffRequest) {
        ContentDiffRequest requestEx = (ContentDiffRequest) request;
        if (requestEx.getContents().size() == 2) {
            DiffContent content = side.select(requestEx.getContents());
            return createAnnotationsLoader(project, content);
        }
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContentDiffRequest(com.intellij.diff.requests.ContentDiffRequest) DiffContent(com.intellij.diff.contents.DiffContent) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with DiffContent

use of com.intellij.diff.contents.DiffContent in project intellij-community by JetBrains.

the class VcsSelectionHistoryDialog method updateDiff.

private void updateDiff() {
    if (myIsDisposed || myIsDuringUpdate)
        return;
    if (myList.getSelectedRowCount() == 0) {
        myDiffPanel.setRequest(NoDiffRequest.INSTANCE);
        return;
    }
    int count = myRevisions.size();
    IntPair range = getSelectedRevisionsRange();
    int revIndex1 = range.val2;
    int revIndex2 = range.val1;
    if (revIndex1 == count && revIndex2 == count) {
        myDiffPanel.setRequest(NoDiffRequest.INSTANCE);
        return;
    }
    BlockData blockData = myBlockLoader.getLoadedData();
    DiffContent content1 = createDiffContent(revIndex1, blockData);
    DiffContent content2 = createDiffContent(revIndex2, blockData);
    String title1 = createDiffContentTitle(revIndex1);
    String title2 = createDiffContentTitle(revIndex2);
    if (content1 != null && content2 != null) {
        myDiffPanel.setRequest(new SimpleDiffRequest(null, content1, content2, title1, title2), new IntPair(revIndex1, revIndex2));
        return;
    }
    if (blockData.isLoading()) {
        myDiffPanel.setRequest(new LoadingDiffRequest());
    } else {
        myDiffPanel.setRequest(new MessageDiffRequest(canNoLoadMessage(blockData.getException())));
    }
}
Also used : SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) MessageDiffRequest(com.intellij.diff.requests.MessageDiffRequest) IntPair(com.intellij.diff.util.IntPair) DiffContent(com.intellij.diff.contents.DiffContent) LoadingDiffRequest(com.intellij.diff.requests.LoadingDiffRequest)

Aggregations

DiffContent (com.intellij.diff.contents.DiffContent)37 SimpleDiffRequest (com.intellij.diff.requests.SimpleDiffRequest)14 NotNull (org.jetbrains.annotations.NotNull)12 Nullable (org.jetbrains.annotations.Nullable)10 ContentDiffRequest (com.intellij.diff.requests.ContentDiffRequest)7 ArrayList (java.util.ArrayList)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 IOException (java.io.IOException)6 DiffRequest (com.intellij.diff.requests.DiffRequest)5 DocumentContent (com.intellij.diff.contents.DocumentContent)3 FileContent (com.intellij.diff.contents.FileContent)3 Project (com.intellij.openapi.project.Project)3 FilePath (com.intellij.openapi.vcs.FilePath)3 DiffIgnoredRangeProvider (com.intellij.diff.lang.DiffIgnoredRangeProvider)2 BinaryMergeRequestImpl (com.intellij.diff.requests.BinaryMergeRequestImpl)2 NullRevisionsProgress (com.intellij.history.integration.ui.models.NullRevisionsProgress)2 Editor (com.intellij.openapi.editor.Editor)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 Ref (com.intellij.openapi.util.Ref)2 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)2