Subversion Repositories eFlore/Applications.coel

Rev

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

Rev Author Line No. Line
1860 aurelien 1
package org.tela_botanica.client.vues.publication;
2
 
3
import org.tela_botanica.client.Mediateur;
4
import org.tela_botanica.client.RegistreId;
5
import org.tela_botanica.client.modeles.publication.Publication;
6
import org.tela_botanica.client.modeles.publication.PublicationAsyncDao;
7
 
8
import com.extjs.gxt.ui.client.Registry;
9
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
10
import com.extjs.gxt.ui.client.widget.ContentPanel;
11
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
12
import com.extjs.gxt.ui.client.widget.Html;
13
import com.extjs.gxt.ui.client.widget.LayoutContainer;
14
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
15
import com.google.gwt.event.dom.client.ClickEvent;
16
import com.google.gwt.event.dom.client.ClickHandler;
17
import com.google.gwt.user.client.ui.Button;
18
import com.google.gwt.user.client.ui.FileUpload;
19
import com.google.gwt.user.client.ui.FormPanel;
20
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
21
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
22
import com.google.gwt.user.client.ui.Hidden;
23
import com.google.gwt.user.client.ui.VerticalPanel;
24
 
25
public abstract class PublicationImportForm extends LayoutContainer {
26
 
27
	private Mediateur mediateurCourant = null;
28
 
29
	public PublicationImportForm(Mediateur mediateurCourant) {
30
		this.mediateurCourant= mediateurCourant;
31
 
32
	    final FormPanel form = new FormPanel();
33
	    form.setAction(PublicationAsyncDao.getUrlImport());
34
 
35
	    form.setEncoding(FormPanel.ENCODING_MULTIPART);
36
	    form.setMethod(FormPanel.METHOD_POST);
37
 
38
	    VerticalPanel panel = new VerticalPanel();
39
	    form.setWidget(panel);
40
 
41
	    FileUpload upload = new FileUpload();
42
	    upload.setName("import_publication");
43
	    panel.add(upload);
44
 
45
	    Hidden typeUpload = new Hidden("type", "publication");
46
	    Hidden utilisateur = new Hidden("ce_utilisateur", ((Mediateur) Registry.get(RegistreId.MEDIATEUR)).getUtilisateurId());
47
 
48
	    panel.add(typeUpload);
49
	    panel.add(utilisateur);
50
 
51
	    HorizontalPanel boutonsPanel = new HorizontalPanel();
52
 
53
	    boutonsPanel.add(new Button(Mediateur.i18nC.importer(), new ClickHandler() {
54
	      public void onClick(ClickEvent event) {
55
	        form.submit();
56
	      }
57
	    }));
58
 
59
	    boutonsPanel.add(new Button(Mediateur.i18nC.annuler(), new ClickHandler() {
60
	      public void onClick(ClickEvent event) {
61
	    	  surClicAnnuler();
62
	      }
63
	    }));
64
 
65
	    form.addSubmitHandler(new FormPanel.SubmitHandler() {
66
			@Override
67
			public void onSubmit(SubmitEvent event) {
68
				surSoumissionFormulaire(event);
69
			}
70
	    });
71
 
72
	    form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
73
			@Override
74
			public void onSubmitComplete(SubmitCompleteEvent event) {
75
				surFormulaireEnvoye(event);
76
			}
77
	    });
78
 
79
	    Html indicationImportForm = new Html("<div id=\"indication_import_csv\"><a target=\"_blank\" href=\"documents/import_publications.csv\">"+Mediateur.i18nC.telechargerModeleImportPubli()+"</a><br />");
80
 
81
	    add(indicationImportForm);
82
	    add(form);
83
	    add(boutonsPanel);
84
	}
85
 
86
	public abstract void surSoumissionFormulaire(SubmitEvent event);
87
	public abstract void surFormulaireEnvoye(SubmitCompleteEvent event);
88
	public abstract void surClicAnnuler();
89
}