166 |
gduche |
1 |
package org.tela_botanica.del.client.vues.rechercheobservations;
|
|
|
2 |
|
|
|
3 |
import java.util.Iterator;
|
|
|
4 |
import java.util.List;
|
|
|
5 |
|
|
|
6 |
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
|
|
|
7 |
import org.tela_botanica.del.client.modeles.Observation;
|
183 |
gduche |
8 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
166 |
gduche |
9 |
|
200 |
gduche |
10 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
11 |
import com.google.gwt.event.dom.client.ClickHandler;
|
166 |
gduche |
12 |
import com.google.gwt.user.client.ui.HasWidgets;
|
200 |
gduche |
13 |
import com.google.gwt.user.client.ui.Image;
|
166 |
gduche |
14 |
|
|
|
15 |
public class ObservationPresenteur extends Presenteur {
|
|
|
16 |
|
|
|
17 |
private Observation observation;
|
|
|
18 |
|
|
|
19 |
public ObservationPresenteur(Observation observation) {
|
|
|
20 |
super(new ObservationVue());
|
|
|
21 |
this.observation = observation;
|
|
|
22 |
chargerObservation();
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
public void chargerObservation() {
|
|
|
26 |
ObservationVue vue = (ObservationVue) this.getVue();
|
|
|
27 |
vue.auteur.setText(observation.getAuteur());
|
|
|
28 |
vue.date.setText(observation.getDate());
|
|
|
29 |
vue.famille.setText(observation.getFamille());
|
|
|
30 |
vue.localite.setText(observation.getLocalite());
|
|
|
31 |
|
|
|
32 |
List<String> motsCles = observation.getMotsClefs();
|
|
|
33 |
Iterator<String> itMotsCles = motsCles.iterator();
|
|
|
34 |
String motsClesChaine = "";
|
|
|
35 |
while (itMotsCles.hasNext()) {
|
|
|
36 |
String motCle = itMotsCles.next();
|
|
|
37 |
motsClesChaine += motCle;
|
|
|
38 |
if (itMotsCles.hasNext()) {
|
|
|
39 |
motsClesChaine += ", ";
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
vue.motsClefs.setText(motsClesChaine);
|
|
|
43 |
vue.nomRetenu.setText(observation.getNomRetenu());
|
|
|
44 |
vue.numNomenclatural.setText(observation.getNumNomenclatural());
|
|
|
45 |
|
200 |
gduche |
46 |
List<org.tela_botanica.del.client.modeles.Image> images = observation.getImages();
|
183 |
gduche |
47 |
|
243 |
gduche |
48 |
if (images != null && images.size() > 0) {
|
|
|
49 |
org.tela_botanica.del.client.modeles.Image imagePrincipale = images.get(0);
|
|
|
50 |
vue.photoPrincipale.setUrl(imagePrincipale.getUrl());
|
|
|
51 |
vue.photoPrincipale.setTitle(imagePrincipale.getUrlFormat("L"));
|
|
|
52 |
vue.photoPrincipale.setAltText(observation.getAuteur() + " - " + observation.getNomRetenu());
|
|
|
53 |
images.remove(0);
|
|
|
54 |
}
|
200 |
gduche |
55 |
|
|
|
56 |
int nbImagesAffichees = 0;
|
|
|
57 |
for (org.tela_botanica.del.client.modeles.Image imageCourante : images) {
|
|
|
58 |
nbImagesAffichees++;
|
|
|
59 |
if (nbImagesAffichees < 5) {
|
|
|
60 |
Image photo = new Image();
|
|
|
61 |
photo.setUrl(imageCourante.getUrlFormat("CRX2S"));
|
|
|
62 |
photo.setTitle(imageCourante.getUrlFormat("L"));
|
|
|
63 |
photo.setAltText(observation.getAuteur() + " - " + observation.getNomRetenu());
|
|
|
64 |
photo.addClickHandler(new ClickHandler() {
|
|
|
65 |
|
|
|
66 |
public void onClick(ClickEvent event) {
|
|
|
67 |
Image photo = (Image) event.getSource();
|
|
|
68 |
ouvrirFenetreModale(new DetailImagePresenteur(photo.getTitle(), photo.getAltText()));
|
|
|
69 |
}
|
|
|
70 |
});
|
|
|
71 |
vue.photos.add(photo);
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
|
183 |
gduche |
75 |
List<PropositionDetermination> propositions = observation.getPropositionsDetermination();
|
|
|
76 |
|
|
|
77 |
vue.tableauPropositions.setText(0, 0, "Certitude");
|
|
|
78 |
vue.tableauPropositions.setText(0, 1, "Commentaires");
|
|
|
79 |
vue.tableauPropositions.setText(0, 2, "Nom");
|
|
|
80 |
vue.tableauPropositions.setText(0, 3, "Votez");
|
|
|
81 |
|
|
|
82 |
int i = 0;
|
|
|
83 |
for (PropositionDetermination proposition : propositions) {
|
|
|
84 |
i++;
|
|
|
85 |
vue.tableauPropositions.setText(i, 0, String.valueOf(proposition.getVotesDeterminations().size()));
|
200 |
gduche |
86 |
/*
|
|
|
87 |
* List<VoteDetermination> votes =
|
|
|
88 |
* proposition.getVotesDeterminations(); for (VoteDetermination vote
|
|
|
89 |
* : votes) { vote.getVote(); }
|
|
|
90 |
*/
|
195 |
gduche |
91 |
vue.tableauPropositions.setText(i, 1, String.valueOf(proposition.getCommentaires().size()));
|
183 |
gduche |
92 |
vue.tableauPropositions.setText(i, 2, proposition.getEspece());
|
|
|
93 |
}
|
|
|
94 |
|
220 |
gduche |
95 |
gererEvenements();
|
183 |
gduche |
96 |
// vue.propositions.setText(ch);
|
166 |
gduche |
97 |
}
|
|
|
98 |
|
|
|
99 |
public void go(HasWidgets composite) {
|
|
|
100 |
composite.add(this.getVue());
|
|
|
101 |
}
|
|
|
102 |
|
220 |
gduche |
103 |
protected void gererEvenements() {
|
200 |
gduche |
104 |
ObservationVue vue = (ObservationVue) this.getVue();
|
|
|
105 |
vue.photoPrincipale.addClickHandler(new ClickHandler() {
|
166 |
gduche |
106 |
|
200 |
gduche |
107 |
public void onClick(ClickEvent event) {
|
|
|
108 |
Image photoPrincipale = (Image) event.getSource();
|
|
|
109 |
ouvrirFenetreModale(new DetailImagePresenteur(photoPrincipale.getTitle(), photoPrincipale.getAltText()));
|
|
|
110 |
}
|
|
|
111 |
});
|
|
|
112 |
|
166 |
gduche |
113 |
}
|
|
|
114 |
}
|