1196 |
gduche |
1 |
package org.tela_botanica.del.client.vues.identiplante.resultats.observationdeterminations;
|
|
|
2 |
|
|
|
3 |
import java.util.Collections;
|
|
|
4 |
import java.util.List;
|
|
|
5 |
|
|
|
6 |
import org.tela_botanica.del.client.composants.fenetreoverlay.FenetreOverlaySimplePresenteur;
|
|
|
7 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
|
|
8 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
|
|
9 |
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
|
|
|
10 |
import org.tela_botanica.del.client.navigation.evenement.voteDetermination.EvenementVoteDetermination;
|
|
|
11 |
import org.tela_botanica.del.client.navigation.evenement.voteDetermination.GestionnaireEvenementVoteDetermination;
|
|
|
12 |
import org.tela_botanica.del.client.utils.ComparateurPropositionDetermination;
|
|
|
13 |
import org.tela_botanica.del.client.vues.identiplante.resultats.votes.DetailVoteObservationPresenteur;
|
|
|
14 |
import org.tela_botanica.del.client.vues.identiplante.resultats.votes.DetailVoteObservationVue;
|
|
|
15 |
|
1927 |
mathias |
16 |
import com.google.gwt.user.client.Window;
|
1196 |
gduche |
17 |
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
|
18 |
import com.google.gwt.user.client.ui.HasWidgets;
|
|
|
19 |
import com.google.gwt.user.client.ui.IsWidget;
|
1209 |
gduche |
20 |
|
1196 |
gduche |
21 |
public class ObservationDeterminationPresenteur {
|
|
|
22 |
public abstract interface Vue extends IsWidget {
|
|
|
23 |
public void viderTableau();
|
|
|
24 |
|
|
|
25 |
public HasWidgets getTableauPropositions();
|
|
|
26 |
|
|
|
27 |
void setNbVotes(int index, int nbVotes);
|
|
|
28 |
|
|
|
29 |
void setNbCommentaires(int index, int nbCommentaires);
|
|
|
30 |
|
|
|
31 |
int getIndexLigneProposition(LignePropositionVue lignePropositionVue);
|
|
|
32 |
|
|
|
33 |
public void masquerPropositions();
|
|
|
34 |
}
|
|
|
35 |
private Vue vue;
|
|
|
36 |
private List<PropositionDetermination> propositions;
|
|
|
37 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur;
|
|
|
38 |
|
|
|
39 |
public ObservationDeterminationPresenteur(Vue vue, List<PropositionDetermination> propositions) {
|
|
|
40 |
this.propositions = propositions;
|
|
|
41 |
this.vue = vue;
|
1927 |
mathias |
42 |
|
|
|
43 |
BusEvenementiel.getInstance().addHandler(EvenementVoteDetermination.TYPE, new GestionnaireEvenementVoteDetermination() {
|
|
|
44 |
@Override
|
|
|
45 |
public void onVoteDetermination(VoteDetermination event) {
|
|
|
46 |
surVoteDetermination(event);
|
|
|
47 |
}
|
|
|
48 |
});
|
1196 |
gduche |
49 |
}
|
1209 |
gduche |
50 |
|
1833 |
aurelien |
51 |
public void classerPropositions(List<PropositionDetermination> propositions) {
|
1196 |
gduche |
52 |
Collections.sort(propositions, new ComparateurPropositionDetermination());
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
public void chargerPropositions() {
|
|
|
56 |
vue.viderTableau();
|
|
|
57 |
int nbPropositions = 0;
|
|
|
58 |
classerPropositions(propositions);
|
1833 |
aurelien |
59 |
for (PropositionDetermination proposition : propositions) {
|
|
|
60 |
nbPropositions++;
|
|
|
61 |
HTMLPanel panneau = new HTMLPanel("");
|
|
|
62 |
DetailVoteObservationPresenteur presenteurVote = new DetailVoteObservationPresenteur(new DetailVoteObservationVue(), proposition);
|
|
|
63 |
presenteurVote.go(panneau);
|
|
|
64 |
LignePropositionVue lignePropositionVue = new LignePropositionVue(panneau);
|
|
|
65 |
LignePropositionPresenteur lignePropositionPresenteur = new LignePropositionPresenteur(lignePropositionVue, proposition);
|
|
|
66 |
lignePropositionPresenteur.go(vue.getTableauPropositions());
|
1196 |
gduche |
67 |
}
|
1209 |
gduche |
68 |
|
1833 |
aurelien |
69 |
if (nbPropositions <= 0) {
|
1196 |
gduche |
70 |
vue.masquerPropositions();
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
public void setPropositions(List<PropositionDetermination> propositions) {
|
|
|
75 |
this.propositions = propositions;
|
|
|
76 |
chargerPropositions();
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
public void go(HasWidgets composite) {
|
|
|
80 |
composite.add(vue.asWidget());
|
|
|
81 |
chargerPropositions();
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
public void surVoteDetermination(VoteDetermination voteDetermination) {
|
|
|
85 |
int indexProposition = propositions.indexOf(voteDetermination.getPropositionDetermination());
|
|
|
86 |
if (indexProposition != -1) {
|
1833 |
aurelien |
87 |
chargerPropositions();
|
1196 |
gduche |
88 |
}
|
|
|
89 |
}
|
|
|
90 |
}
|