Subversion Repositories eFlore/Applications.del

Rev

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