@Override
  public void setDiffRequest(DiffRequest request) {
    final Map<String, DiffRequest> requestMap = myRequest.discloseRequest(request);
    final HashMap<String, DiffViewer> copy = new HashMap<String, DiffViewer>(myMap);

    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 DiffViewer viewer = copy.remove(key);
      if (viewer != null && viewer.acceptsType(diffRequest.getType())) {
        viewer.setDiffRequest(diffRequest);
      } else {
        if (viewer != null) {
          removeTab(myUi.getContentManager().getContents(), key);
        }
        final DiffViewer newViewer =
            myRequest.viewerForRequest(myWindow, myParentDisposable, key, diffRequest);
        if (newViewer == null) continue;
        myMap.put(key, newViewer);
        final Content content =
            myUi.createContent(
                key, newViewer.getComponent(), key, null, newViewer.getPreferredFocusedComponent());
        content.setCloseable(false);
        content.setPinned(true);
        Disposer.register(
            myParentDisposable,
            new Disposable() {
              @Override
              public void dispose() {
                myMap.remove(key);
                myUi.removeContent(content, true);
              }
            });
        myUi.addContent(content);
      }
    }
    final Content[] contents = myUi.getContentManager().getContents();
    for (String s : copy.keySet()) {
      removeTab(contents, s);
    }

    if (myMap.isEmpty()) {
      final EmptyDiffViewer emptyDiffViewer = new EmptyDiffViewer();
      myMap.put(FICTIVE_KEY, emptyDiffViewer);
      final Content content =
          myUi.createContent(
              FICTIVE_KEY,
              emptyDiffViewer.getComponent(),
              FICTIVE_KEY,
              null,
              emptyDiffViewer.getPreferredFocusedComponent());
      content.setCloseable(false);
      content.setPinned(true);
      content.setDisposer(myParentDisposable);
      myUi.addContent(content);
    }
  }
  @Override
  public void setSelected(AnActionEvent e, boolean state) {
    DataContext context = e.getDataContext();
    VirtualFile file = getFile(context);
    if (file != null) {
      // 1. Check editor
      EditorWindow editorWindow = getEditorWindow(context);
      if (editorWindow != null) {
        if (!editorWindow.isFileOpen(file)) {
          file = editorWindow.getSelectedFile();
          if (file == null) return;
        }

        editorWindow.setFilePinned(file, state);
        return;
      }
    }
    Content content = getContent(context); // at this point content cannot be null
    assert content != null : context;
    content.setPinned(state);
  }