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