com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent Java Examples

The following examples show how to use com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FancyFileUpload.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * addSubmitCompleteHandler
 */
private FileUploadForm addSubmitCompleteHandler(final FileUploadForm uploadForm) {
	// Add an event handler to the form.
	uploadForm.addSubmitCompleteHandler(new SubmitCompleteHandler() {
		@Override
		public void onSubmitComplete(SubmitCompleteEvent event) {
			// Fire an onChange Event
			fireChange();

			// Cancel all timers to be absolutely sure nothing is going on.
			p.cancel();

			// Ensure that the form encoding is set correctly.
			uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);

			// Check the result to see if an OK message is returned from the server.
			// Return params could be <pre> or <pre style=""> with some IE and chrome
			GWTFileUploadResponse fuResponse = new GWTFileUploadResponse(event.getResults());

			if (fuResponse.getError().equals("")) {
				String docPath = fuResponse.getPath();

				// Normal case document uploaded is not a workflow
				if (actualFileToUpload.getWorkflow() == null) {
					wizard = false;
					boolean fuResponseWizard = false;
					
					// Case is not importing a zip and wizard is enabled
					if (fuResponse.isHasAutomation()) {
						// If is importing file as zip wizard should be disabled
						if (!uploadForm.isImportZip()
								&& (fuResponse.isDigitalSignature() || fuResponse.isShowWizardCategories()
								|| fuResponse.isShowWizardKeywords()
								|| fuResponse.getGroupsList().size() > 0 || fuResponse.getWorkflowList()
								.size() > 0)) {
							fuResponseWizard = true;
							wizard = true;
						} 
					} else {
						if (!uploadForm.isImportZip()
								&& action == UIFileUploadConstants.ACTION_INSERT
								&& (Main.get().workspaceUserProperties.getWorkspace().isWizardPropertyGroups()
								|| Main.get().workspaceUserProperties.getWorkspace().isWizardWorkflows()
								|| Main.get().workspaceUserProperties.getWorkspace().isWizardCategories() || Main
								.get().workspaceUserProperties.getWorkspace().isWizardKeywords())) {
							wizard = true;
						}
					}
					
					if (wizard && docPath != null) {
						if (!fuResponseWizard) {
							Main.get().wizardPopup.start(docPath, false);
						} else {
							Main.get().wizardPopup.start(docPath, fuResponse, false);
						}
					}

					// By default selected row after uploading is uploaded file
					if (docPath != null && !docPath.equals("")) {
						Main.get().mainPanel.desktop.browser.fileBrowser.mantainSelectedRowByPath(docPath);
					}

					uploadItem.setLoaded();
				} else {
					actualFileToUpload.setDocumentPath(docPath);
					repositoryService.getUUIDByPath(docPath, new AsyncCallback<String>() {
						@Override
						public void onSuccess(String result) {
							actualFileToUpload.setDocumentUUID(result);
							uploadItem.setLoaded();
						}

						@Override
						public void onFailure(Throwable caught) {
							Main.get().showError("getUUIDByPath", caught);
						}
					});
				}
			} else {
				uploadItem.setFailed(fuResponse.getError());
			}

			// Remove upload form
			uploadItem.hFileUpload.remove(uploadForm);
		}
	});

	return uploadForm;
}