示例#1
0
        public void onSubmit(SubmitEvent event) {

          if (!finished && uploading) {
            uploading = false;
            statusWidget.setStatus(IUploadStatus.Status.CANCELED);
            return;
          }

          if (!autoSubmit && fileQueue.size() > 0) {
            statusWidget.setError(i18nStrs.uploaderActiveUpload());
            event.cancel();
            return;
          }

          if (anyFileIsRepeated(true)) {
            statusWidget.setStatus(IUploadStatus.Status.REPEATED);
            successful = true;
            event.cancel();
            uploadFinished();
            return;
          }

          if (getFileName().isEmpty() || !validateAll(basenames)) {
            event.cancel();
            return;
          }

          if (session == null) {
            event.cancel();
            // Sends a request to the server in order to get the session
            // When the response with the session comes, it re-submits the form.
            session = Session.createSession(servletPath, onSessionReceivedCallback);
            return;
          }

          if (blobstore && !receivedBlobPath) {
            event.cancel();
            // Sends a request to the server in order to get the blobstore path.
            // When the response with the blobstore path comes, it re-submits the form.
            session.sendRequest(
                "blobstore", onBlobstoreReceivedCallback, PARAM_BLOBSTORE + "=true");
            return;
          }
          receivedBlobPath = false;

          addToQueue();
          uploading = true;
          finished = false;
          serverRawResponse = null;
          serverMessage = new ServerMessage();

          statusWidget.setVisible(true);
          updateStatusTimer.squeduleStart();
          statusWidget.setStatus(IUploadStatus.Status.INPROGRESS);
          lastData = now();
        }
示例#2
0
 public void run() {
   if (autoSubmit && isTheFirstInQueue()) {
     this.cancel();
     firstTime = true;
     statusWidget.setStatus(IUploadStatus.Status.SUBMITING);
     statusWidget.setVisible(true);
     // See issue #134
     try {
       uploadForm.submit();
     } catch (Exception e) {
       cancel();
       cancelUpload(i18nStrs.uploaderInvalidPathError());
     }
   } else if (firstTime) {
     addToQueue();
     firstTime = false;
   }
 }