Search in sources :

Example 1 with DiffRequest

use of com.intellij.diff.requests.DiffRequest 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 DiffRequest

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

the class OpenInEditorAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    if (!ActionPlaces.isToolbarPlace(e.getPlace())) {
        e.getPresentation().setEnabledAndVisible(true);
        return;
    }
    DiffRequest request = e.getData(DiffDataKeys.DIFF_REQUEST);
    DiffContext context = e.getData(DiffDataKeys.DIFF_CONTEXT);
    if (DiffUtil.isUserDataFlagSet(DiffUserDataKeys.GO_TO_SOURCE_DISABLE, request, context)) {
        e.getPresentation().setVisible(false);
        e.getPresentation().setEnabled(false);
    }
    if (e.getProject() == null) {
        e.getPresentation().setVisible(true);
        e.getPresentation().setEnabled(false);
        return;
    }
    Navigatable[] navigatables = e.getData(DiffDataKeys.NAVIGATABLE_ARRAY);
    if (navigatables == null || !ContainerUtil.exists(navigatables, (it) -> it.canNavigate())) {
        e.getPresentation().setVisible(true);
        e.getPresentation().setEnabled(false);
        return;
    }
    e.getPresentation().setEnabledAndVisible(true);
}
Also used : DiffContext(com.intellij.diff.DiffContext) DiffRequest(com.intellij.diff.requests.DiffRequest) Navigatable(com.intellij.pom.Navigatable)

Example 3 with DiffRequest

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

the class BaseShowDiffAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    DiffRequest request = getDiffRequest(e);
    if (request == null)
        return;
    DiffManager.getInstance().showDiff(project, request);
}
Also used : Project(com.intellij.openapi.project.Project) DiffRequest(com.intellij.diff.requests.DiffRequest)

Example 4 with DiffRequest

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

the class CompareClipboardWithSelectionAction method getEditorFileType.

@Nullable
private static FileType getEditorFileType(@NotNull AnActionEvent e) {
    DiffContent content = e.getData(DiffDataKeys.CURRENT_CONTENT);
    if (content != null && content.getContentType() != null)
        return content.getContentType();
    DiffRequest request = e.getData(DiffDataKeys.DIFF_REQUEST);
    if (request instanceof ContentDiffRequest) {
        for (DiffContent diffContent : ((ContentDiffRequest) request).getContents()) {
            FileType type = diffContent.getContentType();
            if (type != null && type != UnknownFileType.INSTANCE)
                return type;
        }
    }
    return null;
}
Also used : FileType(com.intellij.openapi.fileTypes.FileType) UnknownFileType(com.intellij.openapi.fileTypes.UnknownFileType) SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) ContentDiffRequest(com.intellij.diff.requests.ContentDiffRequest) DiffRequest(com.intellij.diff.requests.DiffRequest) ContentDiffRequest(com.intellij.diff.requests.ContentDiffRequest) DiffContent(com.intellij.diff.contents.DiffContent) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with DiffRequest

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

the class CompareFilesAction method isAvailable.

@Override
protected boolean isAvailable(@NotNull AnActionEvent e) {
    DiffRequest request = e.getData(DIFF_REQUEST);
    if (request != null) {
        return true;
    }
    VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
    if (files == null) {
        return false;
    }
    if (files.length == 1) {
        return hasContent(files[0]);
    } else if (files.length == 2) {
        return hasContent(files[0]) && hasContent(files[1]);
    } else {
        return false;
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DiffRequest(com.intellij.diff.requests.DiffRequest)

Aggregations

DiffRequest (com.intellij.diff.requests.DiffRequest)17 SimpleDiffRequest (com.intellij.diff.requests.SimpleDiffRequest)7 DiffContent (com.intellij.diff.contents.DiffContent)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 NotNull (org.jetbrains.annotations.NotNull)5 DiffRequestProducerException (com.intellij.diff.chains.DiffRequestProducerException)4 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)4 ContentDiffRequest (com.intellij.diff.requests.ContentDiffRequest)3 Project (com.intellij.openapi.project.Project)3 FilePath (com.intellij.openapi.vcs.FilePath)3 IOException (java.io.IOException)3 DocumentContent (com.intellij.diff.contents.DocumentContent)2 UnknownFileTypeDiffRequest (com.intellij.diff.requests.UnknownFileTypeDiffRequest)2 FileType (com.intellij.openapi.fileTypes.FileType)2 Task (com.intellij.openapi.progress.Task)2 Ref (com.intellij.openapi.util.Ref)2 UserDataHolder (com.intellij.openapi.util.UserDataHolder)2 Change (com.intellij.openapi.vcs.changes.Change)2 File (java.io.File)2