Exemple #1
0
  protected void upload() throws InstantiationException {
    final ResolveDependencies resolver = new ResolveDependencies(this, files, true);
    if (!resolver.resolve()) return;

    final String errors = files.checkConsistency();
    if (errors != null) {
      error(errors);
      return;
    }

    final List<String> possibleSites = new ArrayList<String>(files.getSiteNamesToUpload());
    if (possibleSites.size() == 0) {
      error("Huh? No upload site?");
      return;
    }
    String updateSiteName;
    if (possibleSites.size() == 1) updateSiteName = possibleSites.get(0);
    else {
      updateSiteName =
          SwingTools.getChoice(
              this, possibleSites, "Which site do you want to upload to?", "Update site");
      if (updateSiteName == null) return;
    }
    final FilesUploader uploader = new FilesUploader(files, updateSiteName);

    Progress progress = null;
    try {
      if (!uploader.login()) return;
      progress = getProgress("Uploading...");
      uploader.upload(progress);
      for (final FileObject file : files.toUploadOrRemove())
        if (file.getAction() == Action.UPLOAD) {
          file.markUploaded();
          file.setStatus(Status.INSTALLED);
        } else {
          file.markRemoved();
          file.setStatus(Status.OBSOLETE_UNINSTALLED);
        }
      updateFilesTable();
      canUpload = false;
      files.write();
      info("Uploaded successfully.");
      enableUploadOrNot();
      dispose();
    } catch (final Canceled e) {
      // TODO: teach uploader to remove the lock file
      error("Canceled");
      if (progress != null) progress.done();
    } catch (final Throwable e) {
      UpdaterUserInterface.get().handleException(e);
      error("Upload failed: " + e);
      if (progress != null) progress.done();
    }
  }
Exemple #2
0
  public void applyChanges() {
    final ResolveDependencies resolver = new ResolveDependencies(this, files);
    if (!resolver.resolve()) return;
    new Thread() {

      @Override
      public void run() {
        install();
      }
    }.start();
  }