41 |
aurelien |
1 |
package org.tela_botanica.del.client.vues.plateformedetermination;
|
|
|
2 |
|
629 |
aurelien |
3 |
import java.util.Iterator;
|
170 |
aurelien |
4 |
import java.util.List;
|
629 |
aurelien |
5 |
import java.util.Map;
|
170 |
aurelien |
6 |
|
181 |
benjamin |
7 |
import org.tela_botanica.del.client.cache.CacheClient;
|
625 |
gduche |
8 |
import org.tela_botanica.del.client.composants.metadonnees.MetadonneesEnLigneVue;
|
447 |
gduche |
9 |
import org.tela_botanica.del.client.composants.metadonnees.MetadonneesPresenteur;
|
|
|
10 |
import org.tela_botanica.del.client.composants.metadonnees.MetadonneesVue;
|
477 |
benjamin |
11 |
import org.tela_botanica.del.client.composants.observations.ObservationImagesPresenteur;
|
|
|
12 |
import org.tela_botanica.del.client.composants.observations.ObservationImagesVue;
|
262 |
aurelien |
13 |
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
|
629 |
aurelien |
14 |
import org.tela_botanica.del.client.modeles.Image;
|
552 |
benjamin |
15 |
import org.tela_botanica.del.client.modeles.ModeRecherche;
|
170 |
aurelien |
16 |
import org.tela_botanica.del.client.modeles.MoyenneVote;
|
629 |
aurelien |
17 |
import org.tela_botanica.del.client.modeles.Protocole;
|
248 |
aurelien |
18 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
629 |
aurelien |
19 |
import org.tela_botanica.del.client.modeles.VoteProtocole;
|
248 |
aurelien |
20 |
import org.tela_botanica.del.client.navigation.evenement.BusEvenementiel;
|
|
|
21 |
import org.tela_botanica.del.client.navigation.evenement.ajoutdetermination.EvenementAjoutDetermination;
|
|
|
22 |
import org.tela_botanica.del.client.navigation.evenement.ajoutdetermination.GestionnaireEvenementAjoutDetermination;
|
|
|
23 |
import org.tela_botanica.del.client.navigation.evenement.voteDetermination.EvenementVoteDetermination;
|
|
|
24 |
import org.tela_botanica.del.client.navigation.evenement.voteDetermination.GestionnaireEvenementVoteDetermination;
|
170 |
aurelien |
25 |
import org.tela_botanica.del.client.services.CalculVoteDeterminationService;
|
629 |
aurelien |
26 |
import org.tela_botanica.del.client.services.rest.ProtocoleService;
|
610 |
gduche |
27 |
import org.tela_botanica.del.client.composants.fenetreoverlay.FenetreOverlayDefilanteVue;
|
|
|
28 |
import org.tela_botanica.del.client.composants.fenetreoverlay.FenetreOverlaySimplePresenteur;
|
602 |
aurelien |
29 |
import org.tela_botanica.del.client.composants.formulaires.formulaireproposition.FormulairePropositionPresenteur;
|
|
|
30 |
import org.tela_botanica.del.client.composants.formulaires.formulaireproposition.FormulairePropositionVue;
|
629 |
aurelien |
31 |
import org.tela_botanica.del.client.utils.MockDatasource;
|
72 |
aurelien |
32 |
import org.tela_botanica.del.client.vues.plateformedetermination.formulairerechercheeflore.FormulaireRechercheEflorePresenteur;
|
46 |
aurelien |
33 |
import org.tela_botanica.del.client.vues.plateformedetermination.forum.ForumPresenteur;
|
303 |
aurelien |
34 |
import org.tela_botanica.del.client.vues.plateformedetermination.forum.ForumVue;
|
103 |
benjamin |
35 |
import org.tela_botanica.del.client.vues.plateformedetermination.vote.EnsembleVotesPresenteur;
|
303 |
aurelien |
36 |
import org.tela_botanica.del.client.vues.plateformedetermination.vote.EnsembleVotesVue;
|
140 |
aurelien |
37 |
import org.tela_botanica.del.client.vues.plateformedetermination.vote.barrerepartition.BarreRepartitionVotePresenteur;
|
276 |
aurelien |
38 |
import org.tela_botanica.del.client.vues.plateformedetermination.vote.barrerepartition.BarreRepartitionVoteVue;
|
629 |
aurelien |
39 |
import org.tela_botanica.del.client.vues.plateformedetermination.vote.protocole.moyenne.MoyenneVoteProtocolePresenteur;
|
|
|
40 |
import org.tela_botanica.del.client.vues.rechercheimages.resultats.votes.MoyenneVotePresenteur;
|
|
|
41 |
import org.tela_botanica.del.client.vues.rechercheimages.resultats.votes.MoyenneVoteVue;
|
41 |
aurelien |
42 |
|
262 |
aurelien |
43 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
44 |
import com.google.gwt.event.dom.client.ClickHandler;
|
629 |
aurelien |
45 |
import com.google.gwt.user.client.Window;
|
303 |
aurelien |
46 |
import com.google.gwt.user.client.ui.Button;
|
41 |
aurelien |
47 |
import com.google.gwt.user.client.ui.HasWidgets;
|
303 |
aurelien |
48 |
import com.google.gwt.user.client.ui.IsWidget;
|
625 |
gduche |
49 |
import com.google.gwt.user.client.ui.Panel;
|
303 |
aurelien |
50 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
41 |
aurelien |
51 |
|
262 |
aurelien |
52 |
public class DeterminationPresenteur extends Presenteur {
|
135 |
gduche |
53 |
|
602 |
aurelien |
54 |
public interface Vue extends IsWidget {
|
625 |
gduche |
55 |
public Panel getForum();
|
|
|
56 |
public Panel getDetailImageObservation();
|
|
|
57 |
public Panel getFormulaireRechercheEflore();
|
|
|
58 |
public Panel getVoteProtocole();
|
|
|
59 |
public Panel getBarreRepartition();
|
303 |
aurelien |
60 |
public Button getBoutonAjoutProposition();
|
447 |
gduche |
61 |
public HasWidgets getMetadonnees();
|
629 |
aurelien |
62 |
public void ajouterLigneVoteProtocole(String nom, IsWidget vue);
|
303 |
aurelien |
63 |
}
|
436 |
benjamin |
64 |
|
303 |
aurelien |
65 |
private Vue vue;
|
436 |
benjamin |
66 |
|
170 |
aurelien |
67 |
BarreRepartitionVotePresenteur barreRepartitionVotePresenteur;
|
602 |
aurelien |
68 |
FenetreOverlaySimplePresenteur fenetreOverlaySimplePresenteur;
|
629 |
aurelien |
69 |
|
|
|
70 |
private ProtocoleService protocoleService = MockDatasource.getInstance();
|
183 |
gduche |
71 |
|
303 |
aurelien |
72 |
public DeterminationPresenteur(Vue vue) {
|
|
|
73 |
this.vue = vue;
|
41 |
aurelien |
74 |
}
|
135 |
gduche |
75 |
|
41 |
aurelien |
76 |
public void go(HasWidgets composite) {
|
436 |
benjamin |
77 |
|
332 |
gduche |
78 |
if (CacheClient.getInstance().getImageCourante() != null) {
|
625 |
gduche |
79 |
new MetadonneesPresenteur(new MetadonneesEnLigneVue(), CacheClient.getInstance().getObservationCourante(), ModeRecherche.MODE_OBSERVATION).go(vue.getMetadonnees());
|
436 |
benjamin |
80 |
new ObservationImagesPresenteur(new ObservationImagesVue(), CacheClient.getInstance().getObservationCourante()).go(vue.getDetailImageObservation());
|
629 |
aurelien |
81 |
|
|
|
82 |
ajouterLignesVotesProtocole();
|
332 |
gduche |
83 |
}
|
303 |
aurelien |
84 |
new ForumPresenteur(new ForumVue()).go(vue.getForum());
|
|
|
85 |
new FormulaireRechercheEflorePresenteur().go(vue.getFormulaireRechercheEflore());
|
183 |
gduche |
86 |
|
276 |
aurelien |
87 |
barreRepartitionVotePresenteur = new BarreRepartitionVotePresenteur(new BarreRepartitionVoteVue());
|
303 |
aurelien |
88 |
barreRepartitionVotePresenteur.go(vue.getBarreRepartition());
|
170 |
aurelien |
89 |
calculerEtAfficherVoteDeterminationPlusPopulaire();
|
183 |
gduche |
90 |
|
303 |
aurelien |
91 |
composite.add(vue.asWidget());
|
436 |
benjamin |
92 |
|
248 |
aurelien |
93 |
gererEvenements();
|
41 |
aurelien |
94 |
}
|
629 |
aurelien |
95 |
|
|
|
96 |
private void ajouterLignesVotesProtocole() {
|
|
|
97 |
List<Protocole> tousLesProtocoles = protocoleService.getProtocoles();
|
|
|
98 |
Image imageCourante = CacheClient.getInstance().getImageCourante();
|
|
|
99 |
for (Iterator<Protocole> iterator = tousLesProtocoles.iterator(); iterator.hasNext();) {
|
|
|
100 |
Protocole protocole = (Protocole) iterator.next();
|
|
|
101 |
MoyenneVotePresenteur presenteurCeProtocole = new MoyenneVotePresenteur(imageCourante, protocole, new MoyenneVoteVue());
|
|
|
102 |
presenteurCeProtocole.go(vue.getVoteProtocole());
|
|
|
103 |
vue.ajouterLigneVoteProtocole(protocole.getNom(), presenteurCeProtocole.getVue());
|
|
|
104 |
}
|
|
|
105 |
}
|
183 |
gduche |
106 |
|
170 |
aurelien |
107 |
private void calculerEtAfficherVoteDeterminationPlusPopulaire() {
|
183 |
gduche |
108 |
|
234 |
gduche |
109 |
List<MoyenneVote> votesOrdonnes = CalculVoteDeterminationService.calculerVoteDeterminationPlusPopulaire(CacheClient.getInstance().getObservationCourante().getPropositionsDetermination());
|
183 |
gduche |
110 |
if (votesOrdonnes.size() > 0) {
|
188 |
aurelien |
111 |
barreRepartitionVotePresenteur.afficherVotes(votesOrdonnes.get(0));
|
170 |
aurelien |
112 |
}
|
|
|
113 |
}
|
436 |
benjamin |
114 |
|
248 |
aurelien |
115 |
public void gererEvenements() {
|
|
|
116 |
BusEvenementiel.getInstance().addHandler(EvenementVoteDetermination.TYPE, new GestionnaireEvenementVoteDetermination() {
|
|
|
117 |
@Override
|
|
|
118 |
public void onVoteDetermination(VoteDetermination event) {
|
|
|
119 |
calculerEtAfficherVoteDeterminationPlusPopulaire();
|
|
|
120 |
}
|
|
|
121 |
});
|
436 |
benjamin |
122 |
|
|
|
123 |
vue.getBoutonAjoutProposition().addClickHandler(new ClickHandler() {
|
262 |
aurelien |
124 |
@Override
|
|
|
125 |
public void onClick(ClickEvent event) {
|
602 |
aurelien |
126 |
fenetreOverlaySimplePresenteur = new FenetreOverlaySimplePresenteur(new FenetreOverlayDefilanteVue());
|
|
|
127 |
fenetreOverlaySimplePresenteur.ouvrirFenetreModale(new FormulairePropositionPresenteur(new FormulairePropositionVue()));
|
262 |
aurelien |
128 |
}
|
|
|
129 |
});
|
436 |
benjamin |
130 |
|
262 |
aurelien |
131 |
BusEvenementiel.getInstance().addHandler(EvenementAjoutDetermination.TYPE, new GestionnaireEvenementAjoutDetermination() {
|
|
|
132 |
@Override
|
|
|
133 |
public void onAjoutDetermination(EvenementAjoutDetermination event) {
|
602 |
aurelien |
134 |
if (fenetreOverlaySimplePresenteur != null && fenetreOverlaySimplePresenteur.fenetreModaleEstOuverte()) {
|
|
|
135 |
fenetreOverlaySimplePresenteur.fermerFenetreModale();
|
262 |
aurelien |
136 |
}
|
|
|
137 |
}
|
|
|
138 |
});
|
248 |
aurelien |
139 |
}
|
41 |
aurelien |
140 |
}
|