1183 |
gduche |
1 |
package org.tela_botanica.del.client.composants.partageurl;
|
|
|
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 PartageUrlPresenteur {
|
|
|
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 PartageUrlPresenteur(Vue vue) {
|
|
|
29 |
this.vue = vue;
|
|
|
30 |
vue.masquerFormulaire();
|
|
|
31 |
|
|
|
32 |
gererEvenements();
|
|
|
33 |
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
public void gererEvenements() {
|
|
|
37 |
vue.getFermer().addClickHandler(new ClickHandler() {
|
|
|
38 |
|
|
|
39 |
@Override
|
|
|
40 |
public void onClick(ClickEvent event) {
|
|
|
41 |
vue.masquerFormulaire();
|
|
|
42 |
}
|
|
|
43 |
});
|
|
|
44 |
|
|
|
45 |
vue.getBoutonPartage().addClickHandler(new ClickHandler() {
|
|
|
46 |
@Override
|
|
|
47 |
public void onClick(ClickEvent event) {
|
|
|
48 |
String url = genererUrl();
|
|
|
49 |
vue.setUrl(url);
|
|
|
50 |
vue.afficherFormulaire();
|
|
|
51 |
}
|
|
|
52 |
});
|
|
|
53 |
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
public String genererUrl() {
|
|
|
57 |
String url = Window.Location.getHref();
|
|
|
58 |
CacheClient cache = CacheClient.getInstance();
|
|
|
59 |
|
|
|
60 |
String arguments = "";
|
|
|
61 |
if (cache.getPageCourante() == ConstantesNavigation.PAGE_RECHERCHE_IMAGES) {
|
|
|
62 |
InformationsRecherche infoRecherche;
|
|
|
63 |
infoRecherche = cache.getInformationsRechercheImage();
|
|
|
64 |
arguments = infoRecherche.versChaineRequete() + "#" + ConstantesNavigation.PAGE_RECHERCHE_IMAGES;
|
|
|
65 |
url = new Config().getUrl("del") + "?" + arguments;
|
|
|
66 |
} else if (cache.getPageCourante() == ConstantesNavigation.PAGE_RECHERCHE_OBSERVATIONS) {
|
|
|
67 |
InformationsRecherche infoRecherche;
|
|
|
68 |
infoRecherche = cache.getInformationsRechercheObservation();
|
|
|
69 |
arguments = infoRecherche.versChaineRequete() + "#" + ConstantesNavigation.PAGE_RECHERCHE_OBSERVATIONS;
|
|
|
70 |
url = new Config().getUrl("del") + "?" + arguments;
|
|
|
71 |
} else {
|
|
|
72 |
url = Window.Location.getHref();
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
return url;
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
public void go(HasWidgets composite) {
|
|
|
79 |
vue.ajouterVue(composite);
|
|
|
80 |
|
|
|
81 |
}
|
|
|
82 |
}
|