Java Code Examples for com.google.gwt.user.client.ui.FileUpload#setName()
The following examples show how to use
com.google.gwt.user.client.ui.FileUpload#setName() .
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: UploadStep.java From core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected Widget asWidget(final Context context) { final FlowPanel panel = new FlowPanel(); HTML description = new HTML(Console.CONSTANTS.common_label_chooseFile()); description.getElement().setAttribute("style", "padding-bottom:15px;"); panel.add(description); form = new FormPanel(); // create a panel to hold all of the form widgets. VerticalPanel formPanel = new VerticalPanel(); form.setWidget(formPanel); // create a FileUpload widgets. fileUpload = new FileUpload(); fileUpload.setName("uploadFormElement"); IdHelper.setId(fileUpload, id(), "file"); formPanel.add(fileUpload); panel.add(form); return panel; }
Example 2
Source File: KeystoreUploadWizard.java From appinventor-extensions with Apache License 2.0 | 4 votes |
/** * Creates a new keystore upload wizard. */ public KeystoreUploadWizard(final Command callbackAfterUpload) { super(MESSAGES.keystoreUploadWizardCaption(), true, false); // Initialize UI final FileUpload upload = new FileUpload(); upload.setName(ServerLayout.UPLOAD_USERFILE_FORM_ELEMENT); upload.getElement().setAttribute("accept", KEYSTORE_EXTENSION); setStylePrimaryName("ode-DialogBox"); VerticalPanel panel = new VerticalPanel(); panel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); panel.add(upload); addPage(panel); // Create finish command (upload a keystore) initFinishCommand(new Command() { @Override public void execute() { String filename = upload.getFilename(); if (filename.endsWith(KEYSTORE_EXTENSION)) { String uploadUrl = GWT.getModuleBaseURL() + ServerLayout.UPLOAD_SERVLET + "/" + ServerLayout.UPLOAD_USERFILE + "/" + StorageUtil.ANDROID_KEYSTORE_FILENAME; Uploader.getInstance().upload(upload, uploadUrl, new OdeAsyncCallback<UploadResponse>( // failure message MESSAGES.keystoreUploadError()) { @Override public void onSuccess(UploadResponse uploadResponse) { switch (uploadResponse.getStatus()) { case SUCCESS: if (callbackAfterUpload != null) { callbackAfterUpload.execute(); } break; default: ErrorReporter.reportError(MESSAGES.keystoreUploadError()); break; } } }); } else { Window.alert(MESSAGES.notKeystoreError()); center(); } } }); }
Example 3
Source File: ProjectUploadWizard.java From appinventor-extensions with Apache License 2.0 | 4 votes |
/** * Creates a new project upload wizard. */ public ProjectUploadWizard() { super(MESSAGES.projectUploadWizardCaption(), true, false); // Initialize UI final FileUpload upload = new FileUpload(); upload.setName(ServerLayout.UPLOAD_PROJECT_ARCHIVE_FORM_ELEMENT); upload.getElement().setAttribute("accept", PROJECT_ARCHIVE_EXTENSION); setStylePrimaryName("ode-DialogBox"); VerticalPanel panel = new VerticalPanel(); panel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); panel.add(upload); addPage(panel); // Create finish command (upload a project archive) initFinishCommand(new Command() { @Override public void execute() { String filename = upload.getFilename(); if (filename.endsWith(PROJECT_ARCHIVE_EXTENSION)) { // Strip extension and leading path off filename. We need to support both Unix ('/') and // Windows ('\\') path separators. File.pathSeparator is not available in GWT. filename = filename.substring(0, filename.length() - PROJECT_ARCHIVE_EXTENSION.length()). substring(Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\')) + 1); // Make sure the project name is legal and unique. if (!TextValidators.checkNewProjectName(filename)) { return; } String uploadUrl = GWT.getModuleBaseURL() + ServerLayout.UPLOAD_SERVLET + "/" + ServerLayout.UPLOAD_PROJECT + "/" + filename; Uploader.getInstance().upload(upload, uploadUrl, new OdeAsyncCallback<UploadResponse>( // failure message MESSAGES.projectUploadError()) { @Override public void onSuccess(UploadResponse uploadResponse) { switch (uploadResponse.getStatus()) { case SUCCESS: String info = uploadResponse.getInfo(); UserProject userProject = UserProject.valueOf(info); Ode ode = Ode.getInstance(); Project uploadedProject = ode.getProjectManager().addProject(userProject); ode.openYoungAndroidProjectInDesigner(uploadedProject); break; case NOT_PROJECT_ARCHIVE: // This may be a "severe" error; but in the // interest of reducing the number of red errors, the // line has been changed to report info not an error. // This error is triggered when the user attempts to // upload a zip file that is not a project. ErrorReporter.reportInfo(MESSAGES.notProjectArchiveError()); break; default: ErrorReporter.reportError(MESSAGES.projectUploadError()); break; } } }); } else { Window.alert(MESSAGES.notProjectArchiveError()); center(); } } }); }
Example 4
Source File: ComponentImportWizard.java From appinventor-extensions with Apache License 2.0 | 4 votes |
private FileUpload createFileUpload() { FileUpload upload = new FileUpload(); upload.setName(ServerLayout.UPLOAD_COMPONENT_ARCHIVE_FORM_ELEMENT); upload.getElement().setAttribute("accept", COMPONENT_ARCHIVE_EXTENSION); return upload; }
Example 5
Source File: ComponentUploadWizard.java From appinventor-extensions with Apache License 2.0 | 4 votes |
public ComponentUploadWizard() { super(MESSAGES.componentUploadWizardCaption(), true, false); final FileUpload uploadWiget = new FileUpload(); uploadWiget.getElement().setAttribute("accept", COMPONENT_ARCHIVE_EXTENSION); uploadWiget.setName(ServerLayout.UPLOAD_COMPONENT_ARCHIVE_FORM_ELEMENT); VerticalPanel panel = new VerticalPanel(); panel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE); panel.add(uploadWiget); addPage(panel); setStylePrimaryName("ode-DialogBox"); initFinishCommand(new Command() { @Override public void execute() { if (!uploadWiget.getFilename().endsWith(COMPONENT_ARCHIVE_EXTENSION)) { Window.alert(MESSAGES.notComponentArchiveError()); return; } String url = GWT.getModuleBaseURL() + ServerLayout.UPLOAD_SERVLET + "/" + ServerLayout.UPLOAD_COMPONENT + "/" + trimLeadingPath(uploadWiget.getFilename()); Uploader.getInstance().upload(uploadWiget, url, new OdeAsyncCallback<UploadResponse>() { @Override public void onSuccess(UploadResponse uploadResponse) { Component component = Component.valueOf(uploadResponse.getInfo()); ErrorReporter.reportInfo("Uploaded successfully"); } }); } private String trimLeadingPath(String filename) { // Strip leading path off filename. // We need to support both Unix ('/') and Windows ('\\') separators. return filename.substring(Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\')) + 1); } }); }