void startDownloadIfNeeded(@NotNull Sdk sdkFromTable) {
      if (!myIsDownloading.compareAndSet(false, true)) return;
      if (myProgressIndicator.isCanceled()) return;

      myModalityTracker.updateModality();
      SdkType type = (SdkType)sdkFromTable.getSdkType();
      String title = ProjectBundle.message("sdk.configure.downloading", type.getPresentableName());

      //noinspection Convert2Lambda
      Progressive taskAction = new Progressive() {
        @Override
        public void run(@NotNull ProgressIndicator indicator) {
          boolean failed = false;
          try {
            new ProgressIndicatorListener() {
              @Override
              public void cancelled() {
                myProgressIndicator.cancel();
              }
            }.installToProgressIfPossible(indicator);

            ProgressIndicatorEx relayToVisibleIndicator = new RelayUiToDelegateIndicator(indicator);

            myProgressIndicator.addStateDelegate(relayToVisibleIndicator);
            try {
              myProgressIndicator.checkCanceled();
              myTask.doDownload(myProgressIndicator);
            }
            finally {
              myProgressIndicator.removeStateDelegate(relayToVisibleIndicator);
            }

            // make sure VFS has the right image of our SDK to avoid empty SDK from being created
            VfsUtil.markDirtyAndRefresh(false, true, true, new File(myTask.getPlannedHomeDir()));

            //update the pending SDKs
            onSdkDownloadCompletedSuccessfully();
          }
          catch (Throwable e) {
            failed = true;
            if (!myProgressIndicator.isCanceled() && !(e instanceof ControlFlowException)) {
              handleDownloadError(type, title, e);
            }
          }
          finally {
            // dispose our own state
            disposeNow(!failed);
          }
        }
      };

      runTask(title, taskAction);
    }
void startDownloadIfNeeded(@NotNull Sdk sdkFromTable)