예제 #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();
    }
  }
예제 #2
0
 private void quit() {
   if (files.hasChanges()) {
     if (!SwingTools.showQuestion(
         this, "Quit?", "You have specified changes. Are you sure you want to quit?")) return;
   } else
     try {
       files.write();
     } catch (final Exception e) {
       error("There was an error writing the local metadata cache: " + e);
     }
   dispose();
 }
예제 #3
0
 public void install() {
   final Installer installer = new Installer(files, getProgress("Installing..."));
   try {
     installer.start();
     updateFilesTable();
     filesChanged();
     files.write();
     info("Updated successfully.  Please restart ImageJ!");
     dispose();
   } catch (final Canceled e) {
     // TODO: remove "update/" directory
     error("Canceled");
     installer.done();
   } catch (final Exception e) {
     Log.error(e);
     // TODO: remove "update/" directory
     error("Installer failed: " + e);
     installer.done();
   }
 }