protected void init() {
    add(myViewerScrollPane, BorderLayout.CENTER);

    myHeaderPanel.add(createToolbar(), BorderLayout.CENTER);
    add(myHeaderPanel, BorderLayout.NORTH);

    myBottomPanel = new JPanel(new BorderLayout());
    add(myBottomPanel, BorderLayout.SOUTH);

    myViewer.installPopupHandler(myToolBarGroup);
    myViewer.setDoubleClickHandler(getDoubleClickHandler());
  }
 @NotNull
 protected Stream<VirtualFile> getSelectedFiles() {
   return Stream.concat(
           getAfterRevisionsFiles(getSelectedChanges().stream()),
           getVirtualFiles(myViewer.getSelectionPaths(), null))
       .distinct();
 }
 public void calcData(DataKey key, DataSink sink) {
   if (key == VcsDataKeys.CHANGES) {
     List<Change> list = getSelectedChanges();
     if (list.isEmpty()) list = getAllChanges();
     sink.put(VcsDataKeys.CHANGES, list.toArray(new Change[list.size()]));
   } else if (key == VcsDataKeys.CHANGES_SELECTION) {
     sink.put(VcsDataKeys.CHANGES_SELECTION, getChangesSelection());
   } else if (key == VcsDataKeys.CHANGE_LISTS) {
     sink.put(VcsDataKeys.CHANGE_LISTS, getSelectedChangeLists());
   } else if (key == VcsDataKeys.CHANGE_LEAD_SELECTION) {
     final Change highestSelection =
         ObjectUtils.tryCast(myViewer.getHighestLeadSelection(), Change.class);
     sink.put(
         VcsDataKeys.CHANGE_LEAD_SELECTION,
         (highestSelection == null) ? new Change[] {} : new Change[] {highestSelection});
   } else if (key == CommonDataKeys.VIRTUAL_FILE_ARRAY) {
     sink.put(CommonDataKeys.VIRTUAL_FILE_ARRAY, getSelectedFiles().toArray(VirtualFile[]::new));
   } else if (key == CommonDataKeys.NAVIGATABLE_ARRAY) {
     sink.put(
         CommonDataKeys.NAVIGATABLE_ARRAY, getNavigatableArray(myProject, getSelectedFiles()));
   } else if (VcsDataKeys.IO_FILE_ARRAY.equals(key)) {
     sink.put(VcsDataKeys.IO_FILE_ARRAY, getSelectedIoFiles());
   } else if (key == DATA_KEY) {
     sink.put(DATA_KEY, this);
   } else if (VcsDataKeys.SELECTED_CHANGES_IN_DETAILS.equals(key)) {
     final List<Change> selectedChanges = getSelectedChanges();
     sink.put(
         VcsDataKeys.SELECTED_CHANGES_IN_DETAILS,
         selectedChanges.toArray(new Change[selectedChanges.size()]));
   } else if (UNVERSIONED_FILES_DATA_KEY.equals(key)) {
     sink.put(
         UNVERSIONED_FILES_DATA_KEY,
         getVirtualFiles(myViewer.getSelectionPaths(), UNVERSIONED_FILES_TAG));
   } else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.equals(key)) {
     sink.put(PlatformDataKeys.DELETE_ELEMENT_PROVIDER, myDeleteProvider);
   }
 }
  @NotNull
  protected JComponent createToolbar() {
    DefaultActionGroup toolbarGroups = new DefaultActionGroup();
    myToolBarGroup = new DefaultActionGroup();
    toolbarGroups.add(myToolBarGroup);
    buildToolBar(myToolBarGroup);

    toolbarGroups.addSeparator();
    DefaultActionGroup treeActionsGroup = new DefaultActionGroup();
    toolbarGroups.add(treeActionsGroup);
    for (AnAction action : myViewer.getTreeActions()) {
      treeActionsGroup.add(action);
    }

    ActionToolbar toolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.TOOLBAR, toolbarGroups, true);
    toolbar.setTargetComponent(this);
    return toolbar.getComponent();
  }
  @NotNull
  protected ChangesSelection getChangesSelection() {
    final Change leadSelection = ObjectUtils.tryCast(myViewer.getLeadSelection(), Change.class);
    List<Change> changes = getSelectedChanges();

    if (changes.size() < 2) {
      List<Change> allChanges = getAllChanges();
      if (allChanges.size() > 1 || changes.isEmpty()) {
        changes = allChanges;
      }
    }

    if (leadSelection != null) {
      int indexInSelection = changes.indexOf(leadSelection);
      if (indexInSelection == -1) {
        return new ChangesSelection(Collections.singletonList(leadSelection), 0);
      } else {
        return new ChangesSelection(changes, indexInSelection);
      }
    } else {
      return new ChangesSelection(changes, 0);
    }
  }
 public void setDecorator(final ChangeNodeDecorator decorator) {
   myViewer.setChangeDecorator(decorator);
 }
 public void setChangesToDisplay(final List<T> changes) {
   myChangesToDisplay = changes;
   myViewer.setChangesToDisplay(changes);
 }
 public void setSelectionMode(@JdkConstants.TreeSelectionMode int mode) {
   myViewer.setSelectionMode(mode);
 }
 public JComponent getPreferredFocusedComponent() {
   return myViewer.getPreferredFocusedComponent();
 }
 public void setAlwayExpandList(final boolean value) {
   myViewer.setAlwaysExpandList(value);
 }
 public void rebuildList() {
   myViewer.setChangesToDisplay(getCurrentDisplayedObjects(), myToSelect);
 }
 public void select(List<T> changes) {
   myViewer.select(changes);
 }