Esempio n. 1
0
  public synchronized void stop() {
    if (myOriginal.isRunning()) {
      myOriginal.stop();
    } else {
      myStartupAlarm.cancelAllRequests();
    }

    // needed only for correct assertion of !progress.isRunning() in
    // ApplicationImpl.runProcessWithProgressSynchroniously
    final Semaphore semaphore = new Semaphore();
    semaphore.down();

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            semaphore.waitFor();
            if (myDialog != null) {
              // System.out.println("myDialog.destroyProcess()");
              myDialog.close(DialogWrapper.OK_EXIT_CODE);
              myDialog = null;
            }
          }
        });

    super.stop(); // should be last to not leaveModal before closing the dialog
    semaphore.up();
  }
  private void removeCommitFromQueue(@NotNull Document document) {
    synchronized (documentsToCommit) {
      ProgressIndicator indicator = document.getUserData(COMMIT_PROGRESS);

      if (indicator != null && indicator.isRunning()) {
        indicator.stop(); // mark document as removed

        log("Removed from queue", document, false);
      }
      // let our thread know that queue must be polled again
      wakeUpQueue();
    }
  }
    @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.
    }
Esempio n. 4
0
  @Override
  public void run(@NotNull final ProgressIndicator indicator) {
    myIndicator = indicator;

    final ProjectManager projectManager = ProjectManager.getInstance();
    projectManager.addProjectManagerListener(myProject, myCloseListener = new CloseListener());

    final Semaphore semaphore =
        ((CompilerManagerImpl) CompilerManager.getInstance(myProject)).getCompilationSemaphore();
    boolean acquired = false;
    try {

      try {
        while (!acquired) {
          acquired = semaphore.tryAcquire(300, TimeUnit.MILLISECONDS);
          if (!acquired && !myWaitForPreviousSession) {
            return;
          }
          if (indicator.isCanceled()) {
            // give up obtaining the semaphore,
            // let compile work begin in order to stop gracefuly on cancel event
            break;
          }
        }
      } catch (InterruptedException ignored) {
      }

      if (!isHeadless()) {
        addIndicatorDelegate();
      }
      myCompileWork.run();
    } finally {
      try {
        indicator.stop();
        projectManager.removeProjectManagerListener(myProject, myCloseListener);
      } finally {
        if (acquired) {
          semaphore.release();
        }
      }
    }
  }
  @Override
  public synchronized void stop() {
    if (myOriginal.isRunning()) {
      myOriginal.stop();
    } else {
      myStartupAlarm.cancelAllRequests();

      if (!myOriginalStarted && myOriginal instanceof Disposable) {
        // dispose original because start & stop were not called so original progress might not have
        // released its resources
        Disposer.dispose(((Disposable) myOriginal));
      }
    }

    // needed only for correct assertion of !progress.isRunning() in
    // ApplicationImpl.runProcessWithProgressSynchroniously
    final Semaphore semaphore = new Semaphore();
    semaphore.down();

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            semaphore.waitFor();
            if (myDialog != null) {
              // System.out.println("myDialog.destroyProcess()");
              myDialog.close(DialogWrapper.OK_EXIT_CODE);
              myDialog = null;
            }
          }
        });

    try {
      super.stop(); // should be last to not leaveModal before closing the dialog
    } finally {
      semaphore.up();
    }
  }
 @Override
 @NotNull
 public Collection<? extends AbstractTreeNode> getChildren() {
   ProgressIndicator current = ProgressManager.getInstance().getProgressIndicator();
   ProgressIndicator indicator = current == null ? new ProgressIndicatorBase() : current;
   if (current == null) {
     indicator.start();
   }
   final Collection[] nodes = new Collection[1];
   ProgressManager.getInstance()
       .executeProcessUnderProgress(
           new Runnable() {
             @Override
             public void run() {
               nodes[0] =
                   getChildrenUnderProgress(ProgressManager.getInstance().getProgressIndicator());
             }
           },
           indicator);
   if (current == null) {
     indicator.stop();
   }
   return nodes[0];
 }
 @CalledInAwt
 private static void finish(@NotNull Runnable result, @NotNull ProgressIndicator indicator) {
   if (indicator.isCanceled()) return;
   result.run();
   indicator.stop();
 }
 @Override
 public void stop() {
   myIndicator.stop();
 }