Java 类com.intellij.util.net.IOExceptionDialog 实例源码

项目:intellij-ce-playground    文件:FileDownloaderImpl.java   
@Nullable
private List<Pair<VirtualFile,DownloadableFileDescription>> downloadWithProcess(final File targetDir,
                                                                                Project project,
                                                                                JComponent parentComponent) {
  final Ref<List<Pair<File, DownloadableFileDescription>>> localFiles = Ref.create(null);
  final Ref<IOException> exceptionRef = Ref.create(null);

  boolean completed = ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      try {
        localFiles.set(download(targetDir));
      }
      catch (IOException e) {
        exceptionRef.set(e);
      }
    }
  }, myDialogTitle, true, project, parentComponent);
  if (!completed) {
    return null;
  }

  @SuppressWarnings("ThrowableResultOfMethodCallIgnored") Exception exception = exceptionRef.get();
  if (exception != null) {
    final boolean tryAgain = IOExceptionDialog.showErrorDialog(myDialogTitle, exception.getMessage());
    if (tryAgain) {
      return downloadWithProcess(targetDir, project, parentComponent);
    }
    return null;
  }

  return findVirtualFiles(localFiles.get());
}
项目:intellij-ce-playground    文件:DownloadResourceFix.java   
@Override
public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
  boolean tryAgain = true;

  final DownloadManager.DownloadException[] ex = new DownloadManager.DownloadException[1];
  final Runnable runnable = new Runnable() {
    public void run() {
      final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
      final DownloadManager downloadManager = new MyDownloadManager(project, progress);

      try {
        downloadManager.fetch(myLocation);
      }
      catch (DownloadManager.DownloadException e) {
        ex[0] = e;
      }
    }
  };

  while (tryAgain) {
    tryAgain = false;
    if (ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, "Downloading Resource", true, project)) {
      if (ex[0] != null) {
        tryAgain = IOExceptionDialog.showErrorDialog("Error during Download", "Error downloading " + ex[0].getLocation());
        ex[0] = null;
      }
      else {
        break;
      }
    }
  }
}
项目:tools-idea    文件:DownloadResourceFix.java   
@Override
public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
  boolean tryAgain = true;

  final DownloadManager.DownloadException[] ex = new DownloadManager.DownloadException[1];
  final Runnable runnable = new Runnable() {
    public void run() {
      final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
      final DownloadManager downloadManager = new MyDownloadManager(project, progress);

      try {
        downloadManager.fetch(myLocation);
      }
      catch (DownloadManager.DownloadException e) {
        ex[0] = e;
      }
    }
  };

  while (tryAgain) {
    tryAgain = false;
    if (ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, "Downloading Resource", true, project)) {
      if (ex[0] != null) {
        tryAgain = IOExceptionDialog.showErrorDialog("Error during Download", "Error downloading " + ex[0].getLocation());
        ex[0] = null;
      }
      else {
        break;
      }
    }
  }
}
项目:intellij-ce-playground    文件:GithubDownloadUtil.java   
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public static void downloadContentToFileWithProgressSynchronously(
  @Nullable Project project,
  @NotNull final String url,
  @NotNull String progressTitle,
  @NotNull final File outputFile,
  @NotNull final String userName,
  @NotNull final String repositoryName,
  final boolean retryOnError) throws GeneratorException
{
  Outcome<File> outcome = DownloadUtil.provideDataWithProgressSynchronously(
    project,
    progressTitle,
    "Downloading zip archive" + DownloadUtil.CONTENT_LENGTH_TEMPLATE + " ...",
    new Callable<File>() {
      @Override
      public File call() throws Exception {
        ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
        downloadAtomically(progress, url, outputFile, userName, repositoryName);
        return outputFile;
      }
    }, new Producer<Boolean>() {
      @Override
      public Boolean produce() {
        if (!retryOnError) {
          return false;
        }
        return IOExceptionDialog.showErrorDialog("Download Error", "Can not download '" + url + "'");
      }
    }
  );
  File out = outcome.get();
  if (out != null) {
    return;
  }
  Exception e = outcome.getException();
  if (e != null) {
    throw new GeneratorException("Can not fetch content from " + url, e);
  }
  throw new GeneratorException("Download was cancelled");
}
项目:tools-idea    文件:GithubDownloadUtil.java   
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public static void downloadContentToFileWithProgressSynchronously(
  @Nullable Project project,
  @NotNull final String url,
  @NotNull String progressTitle,
  @NotNull final File outputFile,
  @NotNull final String userName,
  @NotNull final String repositoryName,
  final boolean retryOnError) throws GeneratorException
{
  Outcome<File> outcome = DownloadUtil.provideDataWithProgressSynchronously(
    project,
    progressTitle,
    "Downloading zip archive" + DownloadUtil.CONTENT_LENGTH_TEMPLATE + " ...",
    new Callable<File>() {
      @Override
      public File call() throws Exception {
        ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
        downloadAtomically(progress, url, outputFile, userName, repositoryName);
        return outputFile;
      }
    }, new Producer<Boolean>() {
      @Override
      public Boolean produce() {
        if (!retryOnError) {
          return false;
        }
        return IOExceptionDialog.showErrorDialog("Download Error", "Can not download '" + url + "'");
      }
    }
  );
  File out = outcome.get();
  if (out != null) {
    return;
  }
  Exception e = outcome.getException();
  if (e != null) {
    throw new GeneratorException("Can not fetch content from " + url);
  }
  throw new GeneratorException("Download was cancelled");
}
项目:consulo-xslt    文件:DownloadResourceFix.java   
@Override
public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor)
{
    boolean tryAgain = true;

    final DownloadManager.DownloadException[] ex = new DownloadManager.DownloadException[1];
    final Runnable runnable = new Runnable()
    {
        public void run()
        {
            final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
            final DownloadManager downloadManager = new MyDownloadManager(project, progress);

            try
            {
                downloadManager.fetch(myLocation);
            }
            catch(DownloadManager.DownloadException e)
            {
                ex[0] = e;
            }
        }
    };

    while(tryAgain)
    {
        tryAgain = false;
        if(ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, "Downloading Resource", true, project))
        {
            if(ex[0] != null)
            {
                tryAgain = IOExceptionDialog.showErrorDialog("Error during Download", "Error downloading " + ex[0].getLocation());
                ex[0] = null;
            }
            else
            {
                break;
            }
        }
    }
}