New file |
0,0 → 1,82 |
package org.tela_botanica.del.client.composants.partageurl; |
|
import org.tela_botanica.del.client.cache.CacheClient; |
import org.tela_botanica.del.client.config.Config; |
import org.tela_botanica.del.client.gestionhistorique.ConstantesNavigation; |
import org.tela_botanica.del.client.modeles.InformationsRecherche; |
|
import com.google.gwt.event.dom.client.ClickEvent; |
import com.google.gwt.event.dom.client.ClickHandler; |
import com.google.gwt.event.dom.client.HasClickHandlers; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.ui.HasWidgets; |
import com.google.gwt.user.client.ui.IsWidget; |
|
public class PartageUrlPresenteur { |
|
public abstract interface Vue extends IsWidget { |
public void ajouterVue(HasWidgets composite); |
public void masquerFormulaire(); |
public void afficherFormulaire(); |
public HasClickHandlers getBoutonPartage(); |
public HasClickHandlers getFermer(); |
public void setUrl(String url); |
} |
|
private Vue vue; |
|
public PartageUrlPresenteur(Vue vue) { |
this.vue = vue; |
vue.masquerFormulaire(); |
|
gererEvenements(); |
|
} |
|
public void gererEvenements() { |
vue.getFermer().addClickHandler(new ClickHandler() { |
|
@Override |
public void onClick(ClickEvent event) { |
vue.masquerFormulaire(); |
} |
}); |
|
vue.getBoutonPartage().addClickHandler(new ClickHandler() { |
@Override |
public void onClick(ClickEvent event) { |
String url = genererUrl(); |
vue.setUrl(url); |
vue.afficherFormulaire(); |
} |
}); |
|
} |
|
public String genererUrl() { |
String url = Window.Location.getHref(); |
CacheClient cache = CacheClient.getInstance(); |
|
String arguments = ""; |
if (cache.getPageCourante() == ConstantesNavigation.PAGE_RECHERCHE_IMAGES) { |
InformationsRecherche infoRecherche; |
infoRecherche = cache.getInformationsRechercheImage(); |
arguments = infoRecherche.versChaineRequete() + "#" + ConstantesNavigation.PAGE_RECHERCHE_IMAGES; |
url = new Config().getUrl("del") + "?" + arguments; |
} else if (cache.getPageCourante() == ConstantesNavigation.PAGE_RECHERCHE_OBSERVATIONS) { |
InformationsRecherche infoRecherche; |
infoRecherche = cache.getInformationsRechercheObservation(); |
arguments = infoRecherche.versChaineRequete() + "#" + ConstantesNavigation.PAGE_RECHERCHE_OBSERVATIONS; |
url = new Config().getUrl("del") + "?" + arguments; |
} else { |
url = Window.Location.getHref(); |
} |
|
return url; |
} |
|
public void go(HasWidgets composite) { |
vue.ajouterVue(composite); |
|
} |
} |