Search in sources :

Example 1 with MessageDiffRequest

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

Example 2 with MessageDiffRequest

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

the class VcsDiffUtil method showDiffFor.

@CalledInAwt
public static void showDiffFor(@NotNull Project project, @NotNull final Collection<Change> changes, @NotNull final String revNumTitle1, @NotNull final String revNumTitle2, @NotNull final FilePath filePath) {
    if (filePath.isDirectory()) {
        showChangesDialog(project, getDialogTitle(filePath, revNumTitle1, revNumTitle2), ContainerUtil.newArrayList(changes));
    } else {
        if (changes.isEmpty()) {
            DiffManager.getInstance().showDiff(project, new MessageDiffRequest("No Changes Found"));
        } else {
            final HashMap<Key, Object> revTitlesMap = new HashMap<>(2);
            revTitlesMap.put(VCS_DIFF_LEFT_CONTENT_TITLE, revNumTitle1);
            revTitlesMap.put(VCS_DIFF_RIGHT_CONTENT_TITLE, revNumTitle2);
            ShowDiffContext showDiffContext = new ShowDiffContext() {

                @NotNull
                @Override
                public Map<Key, Object> getChangeContext(@NotNull Change change) {
                    return revTitlesMap;
                }
            };
            ShowDiffAction.showDiffForChange(project, changes, 0, showDiffContext);
        }
    }
}
Also used : MessageDiffRequest(com.intellij.diff.requests.MessageDiffRequest) HashMap(com.intellij.util.containers.hash.HashMap) ShowDiffContext(com.intellij.openapi.vcs.changes.actions.diff.ShowDiffContext) Change(com.intellij.openapi.vcs.changes.Change) NotNull(org.jetbrains.annotations.NotNull) Key(com.intellij.openapi.util.Key) CalledInAwt(org.jetbrains.annotations.CalledInAwt)

Aggregations

MessageDiffRequest (com.intellij.diff.requests.MessageDiffRequest)2 DiffContent (com.intellij.diff.contents.DiffContent)1 LoadingDiffRequest (com.intellij.diff.requests.LoadingDiffRequest)1 SimpleDiffRequest (com.intellij.diff.requests.SimpleDiffRequest)1 IntPair (com.intellij.diff.util.IntPair)1 Key (com.intellij.openapi.util.Key)1 Change (com.intellij.openapi.vcs.changes.Change)1 ShowDiffContext (com.intellij.openapi.vcs.changes.actions.diff.ShowDiffContext)1 HashMap (com.intellij.util.containers.hash.HashMap)1 CalledInAwt (org.jetbrains.annotations.CalledInAwt)1 NotNull (org.jetbrains.annotations.NotNull)1