/*! * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software * Foundation. * * You should have received a copy of the GNU Lesser General Public License along with this * program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html * or from the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * Copyright (c) 2002-2013 Pentaho Corporation.. All rights reserved. */ package org.pentaho.platform.dataaccess.datasource.wizard; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.ClickListener; import com.google.gwt.user.client.ui.FileUpload; import com.google.gwt.user.client.ui.FormHandler; import com.google.gwt.user.client.ui.FormPanel; import com.google.gwt.user.client.ui.FormSubmitCompleteEvent; import com.google.gwt.user.client.ui.FormSubmitEvent; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; public class UploadFileEntryPoint implements EntryPoint { 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 ); // 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 ); } }