@Override
    public void run(@NotNull ProgressIndicator indicator) {
      final List<Root> emptyRoots =
          loadRoots(
              myProject,
              myVcsRoots,
              myExceptions,
              false); // collect roots without fetching - just to show dialog
      if (!myExceptions.isEmpty()) {
        myExceptions.addAll(myExceptions);
        return;
      }
      myDialog = new GitPushActiveBranchesDialog(myProject, myVcsRoots, emptyRoots);
      myDialog.refreshTree(true, null, false); // start initial fetch

      indicator
          .stop(); // if indicator is not stopped, the progress would be displayed all the time the
      // dialog is displayed.
    }
  /** This is called when rebase is pressed: executes rebase in background. */
  private void rebase() {
    final List<VcsException> exceptions = new ArrayList<VcsException>();
    final RebaseInfo rebaseInfo = collectRebaseInfo();

    ProgressManager.getInstance()
        .runProcessWithProgressSynchronously(
            new Runnable() {
              public void run() {
                executeRebase(exceptions, rebaseInfo);
              }
            },
            GitBundle.getString("push.active.rebasing"),
            true,
            myProject);
    if (!exceptions.isEmpty()) {
      GitUIUtil.showOperationErrors(myProject, exceptions, "git rebase");
    }
    refreshTree(false, rebaseInfo.uncheckedCommits);
    VcsFileUtil.refreshFiles(myProject, rebaseInfo.roots);
  }
 /**
  * Executes when FETCH button is pressed. Fetches repository in background. Then updates the
  * commit tree.
  */
 private void fetch() {
   Map<VirtualFile, Set<String>> unchecked = new HashMap<VirtualFile, Set<String>>();
   for (int i = 0; i < myTreeRoot.getChildCount(); i++) {
     Set<String> uncheckedCommits = new HashSet<String>();
     CheckedTreeNode node = (CheckedTreeNode) myTreeRoot.getChildAt(i);
     Root r = (Root) node.getUserObject();
     for (int j = 0; j < node.getChildCount(); j++) {
       if (node.getChildAt(j) instanceof CheckedTreeNode) {
         CheckedTreeNode commitNode = (CheckedTreeNode) node.getChildAt(j);
         if (!commitNode.isChecked()) {
           uncheckedCommits.add(((Commit) commitNode.getUserObject()).commitId());
         }
       }
     }
     if (!uncheckedCommits.isEmpty()) {
       unchecked.put(r.root, uncheckedCommits);
     }
   }
   refreshTree(true, unchecked);
 }
  /** Pushes selected commits synchronously in foreground. */
  private void push() {
    final Collection<Root> rootsToPush = getRootsToPush();
    final AtomicReference<Collection<VcsException>> errors =
        new AtomicReference<Collection<VcsException>>();

    ProgressManager.getInstance()
        .runProcessWithProgressSynchronously(
            new Runnable() {
              public void run() {
                errors.set(executePushCommand(rootsToPush));
              }
            },
            GitBundle.getString("push.active.pushing"),
            true,
            myProject);
    if (errors.get() != null && !errors.get().isEmpty()) {
      GitUIUtil.showOperationErrors(
          myProject, errors.get(), GitBundle.getString("push.active.pushing"));
    }
    refreshTree(false, null);
  }
 private void refreshTree(boolean fetchData, Map<VirtualFile, Set<String>> unchecked) {
   refreshTree(fetchData, unchecked, true);
 }