Search in sources :

Example 1 with SimpleDiffRequest

use of com.intellij.openapi.diff.SimpleDiffRequest in project intellij-community by JetBrains.

the class OpenPartialDiffAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    DataContext dataContext = e.getDataContext();
    MergePanel2 mergePanel = MergePanel2.fromDataContext(dataContext);
    Project project = projectFromDataContext(dataContext);
    Editor leftEditor = mergePanel.getEditor(myLeftIndex);
    Editor rightEditor = mergePanel.getEditor(myRightIndex);
    FileType type = mergePanel.getContentType();
    SimpleDiffRequest diffData = new SimpleDiffRequest(project, composeName());
    diffData.setContents(new DocumentContent(project, leftEditor.getDocument(), type), new DocumentContent(project, rightEditor.getDocument(), type));
    diffData.setContentTitles(mergePanel.getVersionTitle(myLeftIndex), mergePanel.getVersionTitle(myRightIndex));
    LOG.assertTrue(DiffManagerImpl.INTERNAL_DIFF.canShow(diffData));
    DiffManagerImpl.INTERNAL_DIFF.show(diffData);
}
Also used : Project(com.intellij.openapi.project.Project) SimpleDiffRequest(com.intellij.openapi.diff.SimpleDiffRequest) FileType(com.intellij.openapi.fileTypes.FileType) DocumentContent(com.intellij.openapi.diff.DocumentContent) Editor(com.intellij.openapi.editor.Editor)

Example 2 with SimpleDiffRequest

use of com.intellij.openapi.diff.SimpleDiffRequest in project intellij-community by JetBrains.

the class CompareFiles method getDiffRequest.

@Nullable
private static DiffRequest getDiffRequest(Project project, VirtualFile[] files) {
    if (files == null || files.length != 2)
        return null;
    if (files[0].isDirectory() || files[1].isDirectory() || files[0].getFileType() instanceof ArchiveFileType || files[1].getFileType() instanceof ArchiveFileType) {
        return null;
    }
    String title = DiffBundle.message("diff.element.qualified.name.vs.element.qualified.name.dialog.title", getVirtualFileContentTitle(files[0]), getVirtualFileContentTitle(files[1]));
    SimpleDiffRequest diffRequest = DiffContentFactory.compareVirtualFiles(project, files[0], files[1], title);
    if (diffRequest == null)
        return null;
    diffRequest.setContentTitles(getVirtualFileContentTitle(files[0]), getVirtualFileContentTitle(files[1]));
    return diffRequest;
}
Also used : ArchiveFileType(com.intellij.ide.highlighter.ArchiveFileType) SimpleDiffRequest(com.intellij.openapi.diff.SimpleDiffRequest) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with SimpleDiffRequest

use of com.intellij.openapi.diff.SimpleDiffRequest in project intellij-community by JetBrains.

the class DiffContentFactory method compareVirtualFiles.

@Nullable
public static SimpleDiffRequest compareVirtualFiles(Project project, VirtualFile file1, VirtualFile file2, String title) {
    DiffContent content1 = DiffContent.fromFile(project, file1);
    DiffContent content2 = DiffContent.fromFile(project, file2);
    if (content1 == null || content2 == null)
        return null;
    SimpleDiffRequest diffRequest = new SimpleDiffRequest(project, title);
    diffRequest.setContents(content1, content2);
    return diffRequest;
}
Also used : SimpleDiffRequest(com.intellij.openapi.diff.SimpleDiffRequest) DiffContent(com.intellij.openapi.diff.DiffContent) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

SimpleDiffRequest (com.intellij.openapi.diff.SimpleDiffRequest)3 Nullable (org.jetbrains.annotations.Nullable)2 ArchiveFileType (com.intellij.ide.highlighter.ArchiveFileType)1 DiffContent (com.intellij.openapi.diff.DiffContent)1 DocumentContent (com.intellij.openapi.diff.DocumentContent)1 Editor (com.intellij.openapi.editor.Editor)1 FileType (com.intellij.openapi.fileTypes.FileType)1 Project (com.intellij.openapi.project.Project)1