Rev 1292 | 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.objets.Configuration;
import org.tela_botanica.client.modeles.objets.Utilisateur;
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.HTML;
import com.google.gwt.user.client.ui.HasAlignment;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Hidden;
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;
private Window nPan = null;
private Hidden identifiant = null;
public FormulaireImportObservationVue(ObservationMediateur om) {
this.oMediateur = om;
nPan = new Window("Import d'observations");
identifiant = new Hidden();
identifiant.setName("utilisateur");
identifiant.setValue(Utilisateur.getInstance().getIdentifiantUtilisateurConsulte());
final FormPanel form = new FormPanel();
final Button boutonValidation = new Button("envoyer");
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
form.setWidth("275px");
nPan.setWidth("275px");
VerticalPanel holder = new VerticalPanel();
FileUpload upload = new FileUpload();
upload.setName("upload");
holder.add(upload);
holder.add(boutonValidation);
holder.add(identifiant);
HTML lienVersDocumentModele = new HTML("<a href=\"modele_import.xls\">Télécharger le modèle de document </a>");
holder.add(lienVersDocumentModele);
holder.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
boutonValidation.addListener(new ButtonListenerAdapter() {
@Override
public void onClick(Button button, EventObject e) {
form.submit();
}
});
form.add(holder);
nPan.add(form);
form.setAction(Configuration.getServiceBaseUrl() + "/InventoryImportExcel");
form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
@Override
public void onSubmitComplete(SubmitCompleteEvent event) {
nPan.close();
com.google.gwt.user.client.Window.alert(""+event.getResults()+" observations créees");
oMediateur.obtenirDernierePageObservation();
}
});
}
public void afficher() {
nPan.show();
}
}