Package com.intellij.util.download

Examples of com.intellij.util.download.DownloadableFileService


    //noinspection unchecked
    return downloadFiles(asList(Pair.create(downloadUrl, fileName)), targetPath);
  }

  public static boolean downloadFiles(List<Pair<String, String>> urlAndFileNames, String targetPath) {
    final DownloadableFileService service = DownloadableFileService.getInstance();
    List<DownloadableFileDescription> descriptions = map(urlAndFileNames, new Function<Pair<String, String>, DownloadableFileDescription>() {
      @Override public DownloadableFileDescription fun(Pair<String, String> it) {
        return service.createFileDescription(it.first + it.second, it.second);
      }
    });
    VirtualFile[] files = service.createDownloader(descriptions, null, null, "").toDirectory(targetPath).download();
    return files != null && files.length == urlAndFileNames.size();
  }
View Full Code Here


  }

  private static List<Pair<VirtualFile, DownloadableFileDescription>> downloadFiles(@NotNull Project project,
                                                                                    @NotNull String libraryName,
                                                                                    String... urls) {
    DownloadableFileService service = DownloadableFileService.getInstance();
    List<DownloadableFileDescription> descriptions = ContainerUtil.newArrayList();
    for (String url : urls) {
      descriptions.add(service.createFileDescription(url, url.substring(url.lastIndexOf("/") + 1)));
    }
    return service.createDownloader(descriptions, libraryName).downloadWithProgress(null, project, null);
  }
View Full Code Here

  private void createUIComponents() {
    myLinkContainer = new JPanel(new BorderLayout());
    ActionLink link = new ActionLink("Download the latest Rebar version", new AnAction() {
      @Override
      public void actionPerformed(AnActionEvent e) {
        DownloadableFileService service = DownloadableFileService.getInstance();
        DownloadableFileDescription rebar = service.createFileDescription("https://github.com/rebar/rebar/wiki/rebar", "rebar");
        FileDownloader downloader = service.createDownloader(ContainerUtil.list(rebar), "rebar");
        List<Pair<VirtualFile, DownloadableFileDescription>> pairs = downloader.downloadWithProgress(null, getEventProject(e), myLinkContainer);
        if (pairs != null) {
          for (Pair<VirtualFile, DownloadableFileDescription> pair : pairs) {
            try {
              String path = pair.first.getCanonicalPath();
View Full Code Here

TOP

Related Classes of com.intellij.util.download.DownloadableFileService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.