Subversion Repositories eFlore/Applications.del

Rev

Rev 1129 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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