Subversion Repositories eFlore/Applications.del

Rev

Rev 939 | Rev 956 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
922 benjamin 1
package org.tela_botanica.del.client.composants.commentaires;
2
 
926 benjamin 3
import java.util.List;
922 benjamin 4
 
5
import org.tela_botanica.del.client.composants.presenteur.Presenteur;
926 benjamin 6
import org.tela_botanica.del.client.modeles.Commentaire;
922 benjamin 7
import org.tela_botanica.del.client.modeles.PropositionDetermination;
939 benjamin 8
import org.tela_botanica.del.client.services.rest.CommentaireService;
926 benjamin 9
import org.tela_botanica.del.client.services.rest.CommentaireServiceConcret;
939 benjamin 10
import org.tela_botanica.del.client.services.rest.async.ListeCommentairesCallback;
922 benjamin 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
 
939 benjamin 16
/**
17
 * Cette classe permet d'afficher une popup avec la liste des commentaires
18
 * associées à une proposition de determination
19
 *
20
 * @author LIENS
21
 *
22
 */
922 benjamin 23
public class DetailCommentairePresenteur extends Presenteur {
24
 
939 benjamin 25
	/**
26
	 * Interface de la vue correspondante
27
	 *
28
	 * @author LIENS
29
	 *
30
	 */
922 benjamin 31
	public interface Vue extends IsWidget {
32
		public void afficherCommentairesProposition(PropositionDetermination propositionDetermination);
33
 
939 benjamin 34
		public void afficherAucuneDonnees();
922 benjamin 35
 
939 benjamin 36
		public void stopChargement();
926 benjamin 37
 
939 benjamin 38
		public void startChargement();
922 benjamin 39
	}
40
 
939 benjamin 41
	// La vue correspondante
922 benjamin 42
	private Vue vue;
43
 
939 benjamin 44
	// La proposition de determination
922 benjamin 45
	private PropositionDetermination propositionDetermination;
46
 
939 benjamin 47
	/**
48
	 * Constructeur
49
	 *
50
	 * @param vue
51
	 * @param propositionDetermination
52
	 */
922 benjamin 53
	public DetailCommentairePresenteur(Vue vue, PropositionDetermination propositionDetermination) {
54
		this.vue = vue;
55
		this.propositionDetermination = propositionDetermination;
56
	}
57
 
939 benjamin 58
	/**
59
	 * Declenchement du présenteur
60
	 */
922 benjamin 61
	public void go(HasWidgets container) {
62
		container.add(vue.asWidget());
63
	}
64
 
939 benjamin 65
	/**
66
	 * Affichage des commentaires
67
	 */
922 benjamin 68
	public void afficherCommentaires() {
939 benjamin 69
 
70
		// affichage de l'icone de chargement
922 benjamin 71
		vue.startChargement();
949 aurelien 72
 
73
		// si l'id de la propostion est égal est nulle alors celle ci est une proposition
74
		// crée par l'interface à partir de l'obs et n'a donc pas de commentaires
75
		if(propositionDetermination.getId() != null) {
76
			// Appel du service
77
			CommentaireService commentaireService = new CommentaireServiceConcret();
78
			commentaireService.chargerCommentaires(propositionDetermination, new ListeCommentairesCallback() {
79
 
80
				@Override
81
				public void surRetour(List<Commentaire> commentaires) {
82
 
83
					propositionDetermination.setListeCommentaires(commentaires);
84
 
85
					// s'il existe des commentaires ils sont affichés
86
					if (propositionDetermination.getTotalCommentaires() > 0) {
87
 
88
						// affichage des commentaires associés à la proposition dans
89
						// la vue
90
						vue.afficherCommentairesProposition(propositionDetermination);
91
 
92
						// supression de l'icone de chargement
93
						vue.stopChargement();
94
					} else {
95
 
96
						// affichage d'un message precisant qu'il n'y a pas de
97
						// commentaires
98
						vue.afficherAucuneDonnees();
99
 
100
						// supression de l'icone de chargement
101
						vue.stopChargement();
102
					}
103
 
104
				}
105
 
106
				@Override
107
				public void surErreur(String messageErreur) {
108
					Window.alert(messageErreur);
922 benjamin 109
					vue.stopChargement();
110
				}
949 aurelien 111
			});
112
		} else {
113
			// affichage d'un message precisant qu'il n'y a pas de
114
			// commentaires
115
			vue.afficherAucuneDonnees();
922 benjamin 116
 
949 aurelien 117
			// supression de l'icone de chargement
118
			vue.stopChargement();
119
		}
922 benjamin 120
	}
121
 
939 benjamin 122
	/**
123
	 * Gestion des evenements du presenteur
124
	 */
922 benjamin 125
	@Override
126
	protected void gererEvenements() {
127
		// TODO Auto-generated method stub
128
	}
129
}