public static void uiDataSnapshot(@NotNull DataSink sink, @Nullable Project project, @NotNull JTree tree) {
    sink.set(CommonDataKeys.PROJECT, project);

    Change[] changes = mapToChange(selected(tree)).toArray(Change.EMPTY_CHANGE_ARRAY);
    sink.set(VcsDataKeys.CHANGES,
             changes.length != 0 ? changes : mapToChange(all(tree)).toArray(Change.EMPTY_CHANGE_ARRAY));
    sink.set(VcsDataKeys.SELECTED_CHANGES, changes);
    sink.set(VcsDataKeys.SELECTED_CHANGES_IN_DETAILS, changes);
    sink.set(VcsDataKeys.CHANGES_SELECTION,
             getListSelectionOrAll(tree).map(entry -> ObjectUtils.tryCast(entry, Change.class)));
    sink.set(VcsDataKeys.CHANGE_LEAD_SELECTION,
             mapToChange(exactlySelected(tree)).toArray(Change.EMPTY_CHANGE_ARRAY));
    sink.set(VcsDataKeys.FILE_PATHS, mapToFilePath(selected(tree)));

    VcsTreeModelData treeSelection = selected(tree);
    VcsTreeModelData exactSelection = exactlySelected(tree);
    sink.lazy(SelectInContext.DATA_KEY, () -> {
      if (project == null) return null;
      VirtualFile file = mapObjectToVirtualFile(exactSelection.iterateRawUserObjects()).first();
      if (file == null) return null;
      return new FileSelectInContext(project, file, null);
    });
    sink.lazy(VcsDataKeys.VIRTUAL_FILES, () -> {
      return mapToVirtualFile(treeSelection);
    });
    sink.lazy(CommonDataKeys.VIRTUAL_FILE_ARRAY, () -> {
      return mapToVirtualFile(treeSelection).toArray(VirtualFile.EMPTY_ARRAY);
    });
    if (project != null) {
      sink.lazy(CommonDataKeys.NAVIGATABLE_ARRAY, () -> {
        return ChangesUtil.getNavigatableArray(project, mapToNavigatableFile(treeSelection));
      });
    }
  }
public static void uiDataSnapshot(@NotNull DataSink sink, @Nullable Project project, @NotNull JTree tree)