Subversion Repositories eFlore/Applications.cel

Rev

Rev 443 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.client.vues.observation;

import org.tela_botanica.client.modeles.Configuration;
import org.tela_botanica.client.observation.ObservationMediateur;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitHandler;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasAlignment;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.Window;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;

public class FormulaireImportObservationVue {
        
        private ObservationMediateur oMediateur = null;
        
        public FormulaireImportObservationVue(ObservationMediateur om) {
                
                this.oMediateur = om;
                
                final Window nPan = new Window("Import d'observations");
                final FormPanel form = new FormPanel();
                final Button boutonValidation = new Button("envoyer");
                form.setEncoding(FormPanel.ENCODING_MULTIPART);
                form.setMethod(FormPanel.METHOD_POST);
                form.setWidth("275px");

                VerticalPanel holder = new VerticalPanel();

                FileUpload upload = new FileUpload();
                upload.setName("upload");
                holder.add(upload);
                holder.add(new HTML("<br />"));
                holder.add(boutonValidation);

                holder.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
                
                boutonValidation.addListener(new ButtonListenerAdapter() {
                                                
                        public void onClick(Button button, EventObject e) {
                                form.submit();
                        }
                });

                form.add(holder);
                
                nPan.add(form);
                form.setAction(Configuration.getServiceBaseUrl() + "/InventoryImportExcel");

                form.addSubmitHandler(new SubmitHandler() {

                        public void onSubmit(SubmitEvent event) {
                                
                        }               
                });
                
                form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
                        
                        public void onSubmitComplete(SubmitCompleteEvent event) {
                                oMediateur.obtenirNombreObservation();
                        }
                });
                
                nPan.show();
        }

}