Subversion Repositories eFlore/Applications.cel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
437 aurelien 1
package org.tela_botanica.client.vues.observation;
2
 
989 aurelien 3
import org.tela_botanica.client.modeles.objets.Configuration;
437 aurelien 4
import org.tela_botanica.client.observation.ObservationMediateur;
5
import com.google.gwt.user.client.ui.FileUpload;
6
import com.google.gwt.user.client.ui.FormPanel;
7
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
8
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
9
import com.google.gwt.user.client.ui.HTML;
10
import com.google.gwt.user.client.ui.HasAlignment;
1292 aurelien 11
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
481 david 12
import com.google.gwt.user.client.ui.Hidden;
437 aurelien 13
import com.google.gwt.user.client.ui.VerticalPanel;
14
import com.gwtext.client.core.EventObject;
15
import com.gwtext.client.widgets.Button;
16
import com.gwtext.client.widgets.Window;
17
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
18
 
19
public class FormulaireImportObservationVue {
20
 
21
	private ObservationMediateur oMediateur = null;
481 david 22
	private  Window nPan = null;
23
	private Hidden identifiant = null;
437 aurelien 24
 
481 david 25
 
437 aurelien 26
	public FormulaireImportObservationVue(ObservationMediateur om) {
481 david 27
 
437 aurelien 28
		this.oMediateur = om;
481 david 29
 
30
		nPan = new Window("Import d'observations");
31
		identifiant = new Hidden();
32
		identifiant.setName("identifiant");
437 aurelien 33
 
34
		final FormPanel form = new FormPanel();
35
		final Button boutonValidation = new Button("envoyer");
481 david 36
 
437 aurelien 37
		form.setEncoding(FormPanel.ENCODING_MULTIPART);
38
		form.setMethod(FormPanel.METHOD_POST);
39
		form.setWidth("275px");
460 aurelien 40
		nPan.setWidth("275px");
437 aurelien 41
 
42
		VerticalPanel holder = new VerticalPanel();
43
 
44
		FileUpload upload = new FileUpload();
45
		upload.setName("upload");
46
		holder.add(upload);
47
		holder.add(boutonValidation);
481 david 48
		holder.add(identifiant);
454 aurelien 49
 
455 david 50
		HTML lienVersDocumentModele = new HTML("<a href=\"modele_import.xls\">T&eacute;l&eacute;charger le mod&egrave;le de document </a>");
454 aurelien 51
 
52
		holder.add(lienVersDocumentModele);
437 aurelien 53
 
1292 aurelien 54
		holder.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
437 aurelien 55
 
56
		boutonValidation.addListener(new ButtonListenerAdapter() {
57
 
1292 aurelien 58
			@Override
437 aurelien 59
			public void onClick(Button button, EventObject e) {
60
				form.submit();
61
			}
62
		});
63
 
64
		form.add(holder);
65
 
66
		nPan.add(form);
67
		form.setAction(Configuration.getServiceBaseUrl() + "/InventoryImportExcel");
68
 
69
		form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
70
 
1292 aurelien 71
			@Override
437 aurelien 72
			public void onSubmitComplete(SubmitCompleteEvent event) {
446 aurelien 73
 
481 david 74
 
444 david 75
				nPan.close();
481 david 76
				com.google.gwt.user.client.Window.alert(""+event.getResults()+" observations créees");
446 aurelien 77
				oMediateur.obtenirDernierePageObservation();
437 aurelien 78
			}
79
		});
80
 
481 david 81
 
82
	}
83
 
84
	public void afficher() {
437 aurelien 85
		nPan.show();
86
	}
481 david 87
 
88
	public void initialiserUtilisateur(String id) {
89
		identifiant.setValue(id);
90
	}
91
 
92
 
437 aurelien 93
 
94
}