1,7 → 1,6 |
package org.tela_botanica.del.client.vues.rechercheimages.resultats; |
|
import java.util.List; |
|
import org.tela_botanica.del.client.cache.CacheClient; |
import org.tela_botanica.del.client.composants.pagination.PaginationPresenteur; |
import org.tela_botanica.del.client.composants.pagination.PaginationVue; |
19,7 → 18,6 |
import org.tela_botanica.del.client.utils.MockDatasource; |
import org.tela_botanica.del.client.vues.rechercheimages.resultats.images.ImagePresenteur; |
import org.tela_botanica.del.client.vues.rechercheimages.resultats.images.ImageVue; |
|
import com.google.gwt.event.dom.client.ChangeEvent; |
import com.google.gwt.event.dom.client.ChangeHandler; |
import com.google.gwt.event.dom.client.ClickEvent; |
30,9 → 28,7 |
import com.google.gwt.user.client.ui.HasWidgets; |
import com.google.gwt.user.client.ui.IsWidget; |
import com.google.gwt.user.client.ui.ListBox; |
|
public class ResultatRechercheImagePresenteur { |
|
public interface Vue extends IsWidget { |
public void startChargement(); |
|
61,50 → 57,47 |
public void afficherElementsResultatsTrouve(); |
|
public HTMLPanel getImageTable(); |
|
|
public String getNomProtocolSelectionne(); |
|
public int getIdProtocoleSelectionne(); |
|
|
public void setListeProtocoles(ListBox listeProtocoles); |
|
|
public HasChangeHandlers getListeProtocoles(); |
|
|
public void ajouterProtocole(String protocole); |
|
public void selectionnerProtocole(int index); |
|
|
public HasClickHandlers getLabelVote(); |
|
|
public void masquerVoteAscendant(); |
|
public void masquerVoteDescendant(); |
|
|
public void afficherVoteAscendant(); |
|
|
public void afficherVoteDescendant(); |
|
|
public HasClickHandlers getLabelDate(); |
|
|
public void masquerDateAscendant(); |
|
public void masquerDateDescendant(); |
|
|
public void afficherDateAscendant(); |
|
|
public void afficherDateDescendant(); |
} |
|
private Vue vue; |
private ImageService imageService; |
|
private final ProtocoleService protocoleService = MockDatasource.getInstance(); |
private List<Protocole> protocoles; |
|
private String protocoleParDefaut = Protocole.ESTHETISME; |
private ModeTri triCourantVote = ModeTri.TRI_ASCENDANT; |
private ModeTri triCourantDate = ModeTri.TRI_ASCENDANT; |
|
|
public ResultatRechercheImagePresenteur(ImageService imageService, Vue vue) { |
this.vue = vue; |
this.imageService = imageService; |
123,9 → 116,7 |
} |
|
public void gererEvenements() { |
|
vue.getListeProtocoles().addChangeHandler(new ChangeHandler() { |
|
@Override |
public void onChange(ChangeEvent event) { |
surChangementProtocole(); |
132,60 → 123,28 |
} |
}); |
|
|
vue.getLabelVote().addClickHandler(new ClickHandler() { |
ClickHandler surClicTriVote = new ClickHandler() { |
@Override |
public void onClick(ClickEvent event) { |
|
vue.masquerDateDescendant(); |
vue.masquerDateAscendant(); |
|
if (triCourantVote == ModeTri.TRI_ASCENDANT) { |
triCourantVote = ModeTri.TRI_DESCENDANT; |
vue.masquerVoteAscendant(); |
vue.afficherVoteDescendant(); |
} else { |
triCourantVote = ModeTri.TRI_ASCENDANT; |
vue.masquerVoteDescendant(); |
vue.afficherVoteAscendant(); |
} |
|
InformationsRecherche informationsRechercheImages = CacheClient.getInstance().getInformationsRechercheImage(); |
int IdProtocole = CacheClient.getInstance().getProtocoleCourant().getId(); |
informationsRechercheImages.setTriParNbVotes(triCourantVote); |
informationsRechercheImages.setIdProtocoleSelectionne(IdProtocole + ""); |
informationsRechercheImages.setTriParDate(ModeTri.PAS_DE_TRI); |
chargerEtAfficherImagesPageEnCours(); |
|
surClicTriVote(); |
} |
}); |
}; |
|
vue.getLabelVote().addClickHandler(surClicTriVote); |
vue.getTriParNbVotesAscendant().addClickHandler(surClicTriVote); |
vue.getTriParNbVotesDescendant().addClickHandler(surClicTriVote); |
|
vue.getLabelDate().addClickHandler(new ClickHandler() { |
ClickHandler surClicTriImage = new ClickHandler() { |
@Override |
public void onClick(ClickEvent event) { |
|
vue.masquerVoteDescendant(); |
vue.masquerVoteAscendant(); |
|
if (triCourantDate == ModeTri.TRI_ASCENDANT) { |
triCourantDate = ModeTri.TRI_DESCENDANT; |
vue.masquerDateAscendant(); |
vue.afficherDateDescendant(); |
} else { |
triCourantDate = ModeTri.TRI_ASCENDANT; |
vue.masquerDateDescendant(); |
vue.afficherDateAscendant(); |
} |
|
InformationsRecherche informationsRechercheImages = CacheClient.getInstance().getInformationsRechercheImage(); |
informationsRechercheImages.setTriParDate(triCourantDate); |
informationsRechercheImages.setTriParNbVotes(ModeTri.PAS_DE_TRI); |
chargerEtAfficherImagesPageEnCours(); |
|
surClicTriImage(); |
} |
}); |
|
}; |
|
vue.getLabelDate().addClickHandler(surClicTriImage); |
vue.getTriParDateAscendant().addClickHandler(surClicTriImage); |
vue.getTriParDateDescendant().addClickHandler(surClicTriImage); |
|
BusEvenementiel.getInstance().addHandler(EvenementChangementProtocole.TYPE, new GestionnaireEvenementChangementProtocole() { |
@Override |
public void onChangementProtocole(EvenementChangementProtocole event) { |
198,6 → 157,44 |
}); |
} |
|
public void surClicTriVote() { |
vue.masquerDateDescendant(); |
vue.masquerDateAscendant(); |
if (triCourantVote == ModeTri.TRI_ASCENDANT) { |
triCourantVote = ModeTri.TRI_DESCENDANT; |
vue.masquerVoteAscendant(); |
vue.afficherVoteDescendant(); |
} else { |
triCourantVote = ModeTri.TRI_ASCENDANT; |
vue.masquerVoteDescendant(); |
vue.afficherVoteAscendant(); |
} |
InformationsRecherche informationsRechercheImages = CacheClient.getInstance().getInformationsRechercheImage(); |
int IdProtocole = CacheClient.getInstance().getProtocoleCourant().getId(); |
informationsRechercheImages.setTriParNbVotes(triCourantVote); |
informationsRechercheImages.setIdProtocoleSelectionne(IdProtocole + ""); |
informationsRechercheImages.setTriParDate(ModeTri.PAS_DE_TRI); |
chargerEtAfficherImagesPageEnCours(); |
} |
|
public void surClicTriImage() { |
vue.masquerVoteDescendant(); |
vue.masquerVoteAscendant(); |
if (triCourantDate == ModeTri.TRI_ASCENDANT) { |
triCourantDate = ModeTri.TRI_DESCENDANT; |
vue.masquerDateAscendant(); |
vue.afficherDateDescendant(); |
} else { |
triCourantDate = ModeTri.TRI_ASCENDANT; |
vue.masquerDateDescendant(); |
vue.afficherDateAscendant(); |
} |
InformationsRecherche informationsRechercheImages = CacheClient.getInstance().getInformationsRechercheImage(); |
informationsRechercheImages.setTriParDate(triCourantDate); |
informationsRechercheImages.setTriParNbVotes(ModeTri.PAS_DE_TRI); |
chargerEtAfficherImagesPageEnCours(); |
} |
|
public void surChangementProtocole() { |
Protocole protocoleCourant = null; |
for (Protocole protocole : protocoles) { |
205,12 → 202,11 |
protocoleCourant = protocole; |
} |
} |
|
CacheClient.getInstance().setProtocoleCourant(protocoleCourant); |
EvenementChangementProtocole evenement = new EvenementChangementProtocole(protocoleCourant); |
BusEvenementiel.getInstance().fireEvent(evenement); |
} |
|
|
private void chargerProtocoles() { |
protocoles = protocoleService.getProtocoles(); |
for (Protocole protocole : protocoles) { |
218,9 → 214,8 |
} |
vue.selectionnerProtocole(protocoles.indexOf(CacheClient.getInstance().getProtocoleCourant())); |
} |
|
|
public void rechercherImagesEtCreerWidgetPagination() { |
|
// appel du service d'image pour avoir le nb total d'elements pour la |
// pagination |
ImagesParTaxonCallback callback = new ImagesParTaxonCallback() { |
230,7 → 225,6 |
afficherImages(imagesRecues); |
} |
}; |
|
final int debut = (CacheClient.getInstance().getPageCouranteRechercheImage() - 1) * CacheClient.getInstance().getPasPagination(); |
final int fin = (CacheClient.getInstance().getPageCouranteRechercheImage()) * CacheClient.getInstance().getPasPagination(); |
imageService.getImagesParTaxon(CacheClient.getInstance().getInformationsRechercheImage(), debut, fin, callback); |
239,7 → 233,6 |
private void chargerEtAfficherImages(final int premier, final int dernier) { |
vue.startChargement(); |
vue.nettoyer(); |
|
ImagesParTaxonCallback callback = new ImagesParTaxonCallback() { |
@Override |
public void surImagesRecues(ImageServiceResultat imagesRecues) { |
247,18 → 240,13 |
} |
}; |
imageService.getImagesParTaxon(CacheClient.getInstance().getInformationsRechercheImage(), premier, dernier, callback); |
|
} |
|
public void afficherImages(ImageServiceResultat imageServiceResult) { |
|
List<Image> images = imageServiceResult.getImages(); |
|
if (images == null || images.size() == 0) { |
vue.afficherElementsAucunResultatTrouve(); |
} |
|
else { |
} else { |
vue.afficherElementsResultatsTrouve(); |
for (Image image : images) { |
ImagePresenteur imagePresenteur = new ImagePresenteur(image, CacheClient.getInstance().getProtocoleCourant(), new ImageVue()); |
269,7 → 257,6 |
} |
|
private void creerWidgetPagination(int nbImages) { |
|
PaginationPresenteur imagesPaginationPresenteurHaut = creerPresenteurPagination(nbImages); |
PaginationPresenteur imagesPaginationPresenteurBas = creerPresenteurPagination(nbImages); |
imagesPaginationPresenteurHaut.setGroupePagination("pagination_images"); |
279,10 → 266,10 |
} |
|
public PaginationPresenteur creerPresenteurPagination(int nbImages) { |
PaginationPresenteur imagesPaginationPresenteur = new PaginationPresenteur(new PaginationVue(), nbImages, CacheClient.getInstance().getPasPagination(), CacheClient.getInstance().getPageCouranteRechercheImage()) { |
PaginationPresenteur imagesPaginationPresenteur = new PaginationPresenteur(new PaginationVue(), nbImages, CacheClient.getInstance().getPasPagination(), CacheClient.getInstance() |
.getPageCouranteRechercheImage()) { |
@Override |
public void chargerElements(int debut, int fin) { |
|
chargerEtAfficherImages(debut, fin); |
CacheClient.getInstance().setPageCouranteRechercheImages(getPageCourante()); |
} |