922 |
benjamin |
1 |
package org.tela_botanica.del.client.composants.commentaires;
|
|
|
2 |
|
|
|
3 |
import java.util.HashMap;
|
|
|
4 |
|
|
|
5 |
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
|
|
|
6 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
|
|
7 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
|
|
8 |
import org.tela_botanica.del.client.services.rest.VoteDeterminationServiceConcret;
|
|
|
9 |
import org.tela_botanica.del.client.services.rest.async.VoteDeterminationCallback;
|
|
|
10 |
import org.tela_botanica.del.client.utils.UtilitairesServiceResultat;
|
|
|
11 |
|
|
|
12 |
import com.google.gwt.user.client.Window;
|
|
|
13 |
import com.google.gwt.user.client.ui.HasWidgets;
|
|
|
14 |
import com.google.gwt.user.client.ui.IsWidget;
|
|
|
15 |
|
|
|
16 |
public class DetailCommentairePresenteur extends Presenteur {
|
|
|
17 |
|
|
|
18 |
public interface Vue extends IsWidget {
|
|
|
19 |
public void afficherCommentairesProposition(PropositionDetermination propositionDetermination);
|
|
|
20 |
|
|
|
21 |
void stopChargement();
|
|
|
22 |
|
|
|
23 |
void startChargement();
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
private Vue vue;
|
|
|
27 |
|
|
|
28 |
private PropositionDetermination propositionDetermination;
|
|
|
29 |
|
|
|
30 |
public DetailCommentairePresenteur(Vue vue, PropositionDetermination propositionDetermination) {
|
|
|
31 |
this.vue = vue;
|
|
|
32 |
this.propositionDetermination = propositionDetermination;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
public void go(HasWidgets container) {
|
|
|
36 |
container.add(vue.asWidget());
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
public void afficherCommentaires() {
|
|
|
40 |
vue.startChargement();
|
|
|
41 |
VoteDeterminationServiceConcret voteService = new VoteDeterminationServiceConcret();
|
|
|
42 |
voteService.consulterVotesPourPropositionDetermination(propositionDetermination, new VoteDeterminationCallback() {
|
|
|
43 |
@Override
|
|
|
44 |
public void surRetour(String messageRetour) {
|
|
|
45 |
|
|
|
46 |
HashMap<String, VoteDetermination> votesComplets = UtilitairesServiceResultat.parserRetourListeVotesDetermination(messageRetour, propositionDetermination);
|
|
|
47 |
if (votesComplets != null) {
|
|
|
48 |
propositionDetermination.setVotesDeterminations(UtilitairesServiceResultat.parserRetourListeVotesDetermination(messageRetour, propositionDetermination));
|
|
|
49 |
vue.afficherCommentairesProposition(propositionDetermination);
|
|
|
50 |
vue.stopChargement();
|
|
|
51 |
} else {
|
|
|
52 |
vue.stopChargement();
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
@Override
|
|
|
58 |
public void surErreur(String messageErreur) {
|
|
|
59 |
Window.alert(messageErreur);
|
|
|
60 |
vue.stopChargement();
|
|
|
61 |
}
|
|
|
62 |
});
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
@Override
|
|
|
66 |
protected void gererEvenements() {
|
|
|
67 |
// TODO Auto-generated method stub
|
|
|
68 |
}
|
|
|
69 |
}
|