Search in sources :

Example 1 with DiffViewer

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

the class CompositeDiffPanel method setDiffRequest.

@Override
public void setDiffRequest(DiffRequest request) {
    final Map<String, DiffRequest> requestMap = myRequest.discloseRequest(request);
    HashMap<String, Pair<DiffViewer, Content>> mapCopy = new HashMap<>(myMap);
    myMap.clear();
    for (Map.Entry<String, DiffRequest> entry : requestMap.entrySet()) {
        final String key = entry.getKey();
        final DiffRequest diffRequest = entry.getValue();
        diffRequest.getGenericData().put(PlatformDataKeys.COMPOSITE_DIFF_VIEWER.getName(), this);
        final Pair<DiffViewer, Content> pair = mapCopy.get(key);
        DiffViewer viewer = pair != null ? pair.first : null;
        if (viewer != null && viewer.acceptsType(diffRequest.getType()) && viewer.canShowRequest(diffRequest)) {
            viewer.setDiffRequest(diffRequest);
            myMap.put(key, pair);
            mapCopy.remove(key);
        } else {
            final DiffViewer newViewer = myRequest.viewerForRequest(myWindow, myParentDisposable, key, diffRequest);
            if (newViewer == null)
                continue;
            final Content content = myUi.createContent(key, newViewer.getComponent(), key, null, newViewer.getPreferredFocusedComponent());
            content.setCloseable(false);
            content.setPinned(true);
            content.setDisposer(myParentDisposable);
            myUi.addContent(content);
            myMap.put(key, Pair.create(newViewer, content));
            if (pair != null)
                myUi.removeContent(pair.second, false);
        }
    }
    if (myMap.isEmpty()) {
        final ErrorDiffViewer errorDiffViewer = new ErrorDiffViewer(myWindow, request);
        final Content content = myUi.createContent(FICTIVE_KEY, errorDiffViewer.getComponent(), FICTIVE_KEY, null, errorDiffViewer.getPreferredFocusedComponent());
        content.setCloseable(false);
        content.setPinned(true);
        content.setDisposer(myParentDisposable);
        myUi.addContent(content);
        myMap.put(FICTIVE_KEY, Pair.<DiffViewer, Content>create(errorDiffViewer, content));
    }
    for (Pair<DiffViewer, Content> pair : mapCopy.values()) {
        myUi.removeContent(pair.second, false);
        if (pair.first instanceof Disposable)
            Disposer.dispose((Disposable) pair.first);
    }
}
Also used : Disposable(com.intellij.openapi.Disposable) HashMap(java.util.HashMap) DiffRequest(com.intellij.openapi.diff.DiffRequest) DiffViewer(com.intellij.openapi.diff.DiffViewer) Content(com.intellij.ui.content.Content) HashMap(java.util.HashMap) Map(java.util.Map) Pair(com.intellij.openapi.util.Pair)

Example 2 with DiffViewer

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

the class MergeTool method show.

public void show(DiffRequest data) {
    if (data instanceof MergeRequestImpl) {
        showDialog((MergeRequestImpl) data);
        return;
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug(new Throwable("MergeTool - frame"));
    }
    FrameWrapper frameWrapper = new FrameWrapper(data.getProject(), data.getGroupKey());
    DiffViewer mergePanel = createMergeComponent(data, null, frameWrapper);
    frameWrapper.setComponent(mergePanel.getComponent());
    frameWrapper.setPreferredFocusedComponent(mergePanel.getPreferredFocusedComponent());
    frameWrapper.closeOnEsc();
    frameWrapper.setTitle(data.getWindowTitle());
    frameWrapper.setProject(data.getProject());
    frameWrapper.show();
}
Also used : DiffViewer(com.intellij.openapi.diff.DiffViewer) FrameWrapper(com.intellij.openapi.ui.FrameWrapper)

Aggregations

DiffViewer (com.intellij.openapi.diff.DiffViewer)2 Disposable (com.intellij.openapi.Disposable)1 DiffRequest (com.intellij.openapi.diff.DiffRequest)1 FrameWrapper (com.intellij.openapi.ui.FrameWrapper)1 Pair (com.intellij.openapi.util.Pair)1 Content (com.intellij.ui.content.Content)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1