Subversion Repositories eFlore/Applications.del

Rev

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

Rev Author Line No. Line
1129 gduche 1
package org.tela_botanica.del.client.vues.vueinitiale;
2
 
3
import org.tela_botanica.del.client.cache.CacheClient;
4
import org.tela_botanica.del.client.config.Config;
5
import org.tela_botanica.del.client.gestionhistorique.ConstantesNavigation;
6
import org.tela_botanica.del.client.modeles.InformationsRecherche;
7
 
8
import com.google.gwt.event.dom.client.ClickEvent;
9
import com.google.gwt.event.dom.client.ClickHandler;
10
import com.google.gwt.event.dom.client.HasClickHandlers;
11
import com.google.gwt.user.client.Window;
12
import com.google.gwt.user.client.ui.HasWidgets;
13
import com.google.gwt.user.client.ui.IsWidget;
14
 
15
public class PartagerUrlPresenteur {
16
 
17
	public abstract interface Vue extends IsWidget {
18
		public void ajouterVue(HasWidgets composite);
19
		public void masquerFormulaire();
20
		public void afficherFormulaire();
21
		public HasClickHandlers getBoutonPartage();
22
		public HasClickHandlers getFermer();
23
		public void setUrl(String url);
24
	}
25
 
26
	private Vue vue;
27
 
28
	public PartagerUrlPresenteur(Vue vue) {
29
		this.vue = vue;
30
		vue.masquerFormulaire();
31
 
32
		gererEvenements();
33
	}
34
 
35
	public void gererEvenements() {
36
		vue.getFermer().addClickHandler(new ClickHandler() {
37
 
38
			@Override
39
			public void onClick(ClickEvent event) {
40
				vue.masquerFormulaire();
41
			}
42
		});
43
 
44
		vue.getBoutonPartage().addClickHandler(new ClickHandler() {
45
			@Override
46
			public void onClick(ClickEvent event) {
47
				String url = genererUrl();
48
				vue.setUrl(url);
49
				vue.afficherFormulaire();
50
			}
51
		});
52
 
53
	}
54
 
55
	public String genererUrl() {
56
		String url = Window.Location.getHref();
57
		CacheClient cache = CacheClient.getInstance();
58
 
59
		String arguments = "";
60
		if (cache.getPageCourante() == ConstantesNavigation.PAGE_RECHERCHE_IMAGES) {
61
			InformationsRecherche infoRecherche;
62
			infoRecherche = cache.getInformationsRechercheImage();
63
			arguments = infoRecherche.versChaineRequete() + "#" + ConstantesNavigation.PAGE_RECHERCHE_IMAGES;
64
			url = new Config().getUrl("del") + "?" + arguments;
65
		} else if (cache.getPageCourante() == ConstantesNavigation.PAGE_RECHERCHE_OBSERVATIONS) {
66
			InformationsRecherche infoRecherche;
67
			infoRecherche = cache.getInformationsRechercheObservation();
68
			arguments = infoRecherche.versChaineRequete() + "#" + ConstantesNavigation.PAGE_RECHERCHE_OBSERVATIONS;
69
			url = new Config().getUrl("del") + "?" + arguments;
70
		} else {
71
			url = Window.Location.getHref();
72
		}
73
 
74
		return url;
75
	}
76
 
77
	public void go(HasWidgets composite) {
78
		vue.ajouterVue(composite);
79
 
80
	}
81
}