List of usage examples for com.google.gwt.user.client.ui FileUpload setName
public void setName(String name)
From source file:org.pentaho.platform.dataaccess.datasource.ui.importing.MetadataImportDialogController.java
License:Open Source License
@Bindable public void addLocalizedBundle() { final FileUpload localizedBundleUpload = new FileUpload(); localizedBundleUpload.setName("localeFiles"); localizedBundleUpload.getElement().setId("propertyFileUpload" + FILE_UPLOAD_SUFFIX++); localizedBundleUpload.addChangeHandler(new ChangeHandler() { @Override//from w w w. j a va2s . c o m public void onChange(ChangeEvent event) { String fileName = ((FileUpload) event.getSource()).getFilename(); if (fileName == null || fileName.length() < 1) { // Trying to detect a cancel propertiesFileImportPanel.remove(localizedBundleUpload); } else { importDialogModel.addLocalizedBundle(fileName, fileName); } } }); propertiesFileImportPanel.add(localizedBundleUpload); jsClickUpload(localizedBundleUpload.getElement().getId()); }
From source file:org.pentaho.platform.dataaccess.datasource.wizard.UploadFile.java
License:Open Source License
public void onModuleLoad() { // Create a FormPanel and point it at a service. final FormPanel uploadForm = new FormPanel(); uploadForm.setAction(GWT.getModuleBaseURL() + "/UploadService"); // Because we're going to add a FileUpload widget, we'll need to set the // form to use the POST method, and multipart MIME encoding. uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); uploadForm.setMethod(FormPanel.METHOD_POST); // Create a panel to hold all of the form widgets. VerticalPanel panel = new VerticalPanel(); uploadForm.setWidget(panel);/* w w w. j a v a 2 s .c o m*/ // Create a TextBox, giving it a name so that it will be submitted. final TextBox tb = new TextBox(); tb.setName("textBoxFormElement"); panel.add(tb); // Create a FileUpload widget. FileUpload upload = new FileUpload(); upload.setName("uploadFormElement"); panel.add(upload); // Add a 'Upload' button. Button uploadSubmitButton = new Button("Upload"); panel.add(uploadSubmitButton); uploadSubmitButton.addClickListener(new ClickListener() { public void onClick(Widget sender) { uploadForm.submit(); } }); uploadForm.addFormHandler(new FormHandler() { public void onSubmit(FormSubmitEvent event) { } public void onSubmitComplete(FormSubmitCompleteEvent event) { Window.alert(event.getResults()); } }); RootPanel.get().add(uploadForm); }
From source file:org.utgenome.gwt.utgb.client.track.lib.ViewLoaderTrack.java
License:Apache License
public ViewLoaderTrack() { super("View Loader"); // load view via HTTP HorizontalPanel hp = new HorizontalPanel(); hp.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE); hp.add(new FormLabel("View Silk URL: ")); urlBox.setWidth("400px"); urlBox.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(KeyPressEvent e) { if (e.getCharCode() == KeyCodes.KEY_ENTER) { downloadView(urlBox.getText()); }//from w w w. j a v a2 s . com } }); Button loadButton = new Button("load"); loadButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { downloadView(urlBox.getText()); } }); hp.add(urlBox); hp.add(loadButton); // load view from a file final FormPanel fileUploadForm = new FormPanel(); fileUploadForm.setAction(GWT.getModuleBaseURL() + "utgb-core/loadview"); fileUploadForm.setEncoding(FormPanel.ENCODING_MULTIPART); fileUploadForm.setMethod(FormPanel.METHOD_POST); HorizontalPanel formButtonPanel = new HorizontalPanel(); FileUpload fileBox = new FileUpload(); fileBox.setName("file"); fileBox.setWidth("300px"); Button uploadButton = new Button("submit"); uploadButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { fileUploadForm.submit(); } }); formButtonPanel.add(new FormLabel("View Silk File:")); formButtonPanel.add(fileBox); formButtonPanel.add(uploadButton); fileUploadForm.add(formButtonPanel); DOM.setStyleAttribute(fileUploadForm.getElement(), "margin", "0"); fileUploadForm.addSubmitCompleteHandler(new SubmitCompleteHandler() { public void onSubmitComplete(SubmitCompleteEvent e) { getFrame().setNowLoading(); String viewXML = extractEmbeddedSilkInComment(e.getResults()); setViewSilk(viewXML); } }); // set panes panel.setStyleName("toolbox"); panel.add(hp); panel.add(fileUploadForm); }