Esempio n. 1
0
  /**
   * Called when the uploader detects that the upload process has finished: - in the case of submit
   * complete. - in the case of error talking with the server.
   */
  private void uploadFinished() {
    removeFromQueue();
    finished = true;
    uploading = false;
    updateStatusTimer.cancel();
    statusWidget.setVisible(false);

    if (successful) {
      if (avoidRepeatedFiles) {
        fileDone.addAll(fileInput.getFilenames());
        statusWidget.setStatus(IUploadStatus.Status.SUCCESS);
      } else {
        statusWidget.setStatus(IUploadStatus.Status.SUCCESS);
      }
    } else if (canceled) {
      statusWidget.setStatus(IUploadStatus.Status.CANCELED);
    } else {
      statusWidget.setStatus(IUploadStatus.Status.ERROR);
    }
    onFinishUpload();
    reatachIframe(uploadForm.getElement().getAttribute("target"));
  }
Esempio n. 2
0
  /** Cancel the current upload process. */
  public void cancel() {
    if (getStatus() == Status.UNINITIALIZED) {
      return;
    }

    if (finished && !uploading) {
      if (successful) {
        try {
          sendAjaxRequestToDeleteUploadedFile();
        } catch (Exception e) {
        }
      } else {
        statusWidget.setStatus(Status.DELETED);
      }
      return;
    }

    if (canceled || getStatus() == Status.CANCELING) {
      return;
    }

    canceled = true;
    automaticUploadTimer.cancel();
    if (uploading) {
      updateStatusTimer.cancel();
      try {
        sendAjaxRequestToCancelCurrentUpload();
      } catch (Exception e) {
        log("Exception cancelling request " + e.getMessage(), e);
      }
      statusWidget.setStatus(IUploadStatus.Status.CANCELING);
    } else {
      uploadFinished();
      reuse();
    }
  }
Esempio n. 3
0
 /** Prepare the uploader for a new upload. */
 public void reuse() {
   this.uploadForm.reset();
   updateStatusTimer.cancel();
   onSubmitComplete = uploading = canceled = finished = successful = false;
   statusWidget.setStatus(Status.UNINITIALIZED);
 }