| 922 | benjamin | 1 | package org.tela_botanica.del.client.composants.commentaires;
 | 
        
           |  |  | 2 |   | 
        
           |  |  | 3 | import java.util.List;
 | 
        
           |  |  | 4 |   | 
        
           |  |  | 5 | import org.tela_botanica.del.client.i18n.I18n;
 | 
        
           |  |  | 6 | import org.tela_botanica.del.client.modeles.Commentaire;
 | 
        
           |  |  | 7 | import org.tela_botanica.del.client.modeles.PropositionDetermination;
 | 
        
           |  |  | 8 |   | 
        
           |  |  | 9 | import com.google.gwt.core.client.GWT;
 | 
        
           | 965 | aurelien | 10 | import com.google.gwt.i18n.client.DateTimeFormat;
 | 
        
           | 922 | benjamin | 11 | import com.google.gwt.uibinder.client.UiBinder;
 | 
        
           |  |  | 12 | import com.google.gwt.uibinder.client.UiField;
 | 
        
           | 1075 | gduche | 13 | import com.google.gwt.user.client.ui.Button;
 | 
        
           | 922 | benjamin | 14 | import com.google.gwt.user.client.ui.Composite;
 | 
        
           |  |  | 15 | import com.google.gwt.user.client.ui.FlexTable;
 | 
        
           | 973 | aurelien | 16 | import com.google.gwt.user.client.ui.HTML;
 | 
        
           | 922 | benjamin | 17 | import com.google.gwt.user.client.ui.HTMLPanel;
 | 
        
           |  |  | 18 | import com.google.gwt.user.client.ui.Panel;
 | 
        
           |  |  | 19 | import com.google.gwt.user.client.ui.Widget;
 | 
        
           |  |  | 20 |   | 
        
           | 939 | benjamin | 21 | /**
 | 
        
           |  |  | 22 |  * Cette classe permet d'afficher une popup avec la liste des commentaires
 | 
        
           |  |  | 23 |  * associées à une proposition de determination
 | 
        
           |  |  | 24 |  *
 | 
        
           |  |  | 25 |  * @author LIENS
 | 
        
           |  |  | 26 |  *
 | 
        
           |  |  | 27 |  */
 | 
        
           | 922 | benjamin | 28 | public class DetailCommentaireVue extends Composite implements DetailCommentairePresenteur.Vue {
 | 
        
           |  |  | 29 |   | 
        
           |  |  | 30 | 	private static DetailListeVotesDeterminationVueUIiBinder uiBinder = GWT.create(DetailListeVotesDeterminationVueUIiBinder.class);
 | 
        
           |  |  | 31 |   | 
        
           |  |  | 32 | 	interface DetailListeVotesDeterminationVueUIiBinder extends UiBinder<Widget, DetailCommentaireVue> {
 | 
        
           |  |  | 33 | 	};
 | 
        
           |  |  | 34 |   | 
        
           |  |  | 35 | 	@UiField
 | 
        
           | 973 | aurelien | 36 | 	HTMLPanel titre, auteur, aucuneDonnees;
 | 
        
           | 922 | benjamin | 37 |   | 
        
           |  |  | 38 | 	@UiField
 | 
        
           |  |  | 39 | 	Panel panneauChargement;
 | 
        
           |  |  | 40 |   | 
        
           |  |  | 41 | 	@UiField
 | 
        
           |  |  | 42 | 	FlexTable htmlTableau;
 | 
        
           |  |  | 43 |   | 
        
           | 1075 | gduche | 44 | 	@UiField
 | 
        
           |  |  | 45 | 	Button boutonAjoutCommentaire;
 | 
        
           |  |  | 46 |   | 
        
           |  |  | 47 | 	@Override
 | 
        
           |  |  | 48 | 	public Button getBoutonAjoutCommentaire() {
 | 
        
           |  |  | 49 | 		return boutonAjoutCommentaire;
 | 
        
           |  |  | 50 | 	}
 | 
        
           |  |  | 51 |   | 
        
           | 922 | benjamin | 52 | 	public DetailCommentaireVue() {
 | 
        
           |  |  | 53 | 		initWidget(uiBinder.createAndBindUi(this));
 | 
        
           |  |  | 54 | 	}
 | 
        
           |  |  | 55 |   | 
        
           | 939 | benjamin | 56 | 	/**
 | 
        
           |  |  | 57 | 	 * Affiche les commentaires associées à une proposition de determination
 | 
        
           |  |  | 58 | 	 */
 | 
        
           | 922 | benjamin | 59 | 	@Override
 | 
        
           |  |  | 60 | 	public void afficherCommentairesProposition(PropositionDetermination propositionDetermination) {
 | 
        
           | 973 | aurelien | 61 |   | 
        
           |  |  | 62 | 		HTML htmlTitre = new HTML(propositionDetermination.getEspece());
 | 
        
           |  |  | 63 | 		titre.add(htmlTitre);
 | 
        
           |  |  | 64 |   | 
        
           |  |  | 65 | 		HTML htmlAuteur = new HTML(I18n.getVocabulary().proposePar()+propositionDetermination.getAuteur());
 | 
        
           |  |  | 66 | 		auteur.add(htmlAuteur);
 | 
        
           | 922 | benjamin | 67 |   | 
        
           |  |  | 68 | 		htmlTableau.clear();
 | 
        
           |  |  | 69 | 		creerEntetes();
 | 
        
           |  |  | 70 |   | 
        
           |  |  | 71 | 		if (propositionDetermination.getCommentaire() != null && propositionDetermination.getCommentaire() != "") {
 | 
        
           |  |  | 72 | 			htmlTableau.setHTML(2, 1, propositionDetermination.getAuteur());
 | 
        
           |  |  | 73 | 			htmlTableau.setHTML(2, 2, propositionDetermination.getCommentaire());
 | 
        
           | 965 | aurelien | 74 | 			htmlTableau.setHTML(2, 3, DateTimeFormat.getFormat("dd/MM/yyyy").format(propositionDetermination.getDate()));
 | 
        
           | 922 | benjamin | 75 | 		}
 | 
        
           |  |  | 76 |   | 
        
           |  |  | 77 | 		creerListeCommentaireRecursive(propositionDetermination.getListeCommentaires());
 | 
        
           |  |  | 78 | 	}
 | 
        
           |  |  | 79 |   | 
        
           | 939 | benjamin | 80 | 	/**
 | 
        
           |  |  | 81 | 	 * Affiche une liste de commentaires recursivement
 | 
        
           |  |  | 82 | 	 * @param commentaires
 | 
        
           |  |  | 83 | 	 */
 | 
        
           | 922 | benjamin | 84 | 	private void creerListeCommentaireRecursive(List<Commentaire> commentaires) {
 | 
        
           |  |  | 85 |   | 
        
           |  |  | 86 | 		for (Commentaire commentaire : commentaires) {
 | 
        
           |  |  | 87 | 			chargerCommentaire(commentaire);
 | 
        
           |  |  | 88 | 			if (commentaire.getListeCommentaires().size() > 0) {
 | 
        
           |  |  | 89 | 				creerListeCommentaireRecursive(commentaire.getListeCommentaires());
 | 
        
           |  |  | 90 | 			}
 | 
        
           |  |  | 91 | 		}
 | 
        
           |  |  | 92 | 	}
 | 
        
           |  |  | 93 |   | 
        
           | 939 | benjamin | 94 | 	/**
 | 
        
           |  |  | 95 | 	 * Affiche un commentaire
 | 
        
           |  |  | 96 | 	 * @param commentaire
 | 
        
           |  |  | 97 | 	 */
 | 
        
           | 922 | benjamin | 98 | 	private void chargerCommentaire(Commentaire commentaire) {
 | 
        
           |  |  | 99 | 		int ligne = htmlTableau.getRowCount() + 1;
 | 
        
           |  |  | 100 | 		htmlTableau.setHTML(ligne, 1, commentaire.getAuteur());
 | 
        
           |  |  | 101 | 		htmlTableau.setHTML(ligne, 2, commentaire.getCommentaire());
 | 
        
           | 965 | aurelien | 102 | 		htmlTableau.setHTML(ligne, 3, DateTimeFormat.getFormat("dd/MM/yyyy").format(commentaire.getDate()));
 | 
        
           | 922 | benjamin | 103 | 	}
 | 
        
           |  |  | 104 |   | 
        
           | 939 | benjamin | 105 | 	/**
 | 
        
           |  |  | 106 | 	 * Affiche les en-têtes du tableau de commentaires
 | 
        
           |  |  | 107 | 	 */
 | 
        
           | 922 | benjamin | 108 | 	private void creerEntetes() {
 | 
        
           |  |  | 109 | 		htmlTableau.setHTML(1, 1, I18n.getVocabulary().contributeur());
 | 
        
           |  |  | 110 | 		htmlTableau.setHTML(1, 2, I18n.getVocabulary().commentaire());
 | 
        
           |  |  | 111 | 		htmlTableau.setHTML(1, 3, I18n.getVocabulary().date());
 | 
        
           |  |  | 112 | 	}
 | 
        
           |  |  | 113 |   | 
        
           | 939 | benjamin | 114 | 	/**
 | 
        
           |  |  | 115 | 	 * Affiche un icone de début de chargement
 | 
        
           |  |  | 116 | 	 */
 | 
        
           | 922 | benjamin | 117 | 	@Override
 | 
        
           |  |  | 118 | 	public void startChargement() {
 | 
        
           |  |  | 119 | 		panneauChargement.setHeight((this.getOffsetHeight() / 2) + "px");
 | 
        
           |  |  | 120 | 		panneauChargement.setWidth((this.getOffsetWidth() / 2) + "px");
 | 
        
           |  |  | 121 | 		panneauChargement.setVisible(true);
 | 
        
           |  |  | 122 | 	}
 | 
        
           |  |  | 123 |   | 
        
           | 939 | benjamin | 124 | 	/**
 | 
        
           |  |  | 125 | 	 * Cache l'icone de début de chargement
 | 
        
           |  |  | 126 | 	 */
 | 
        
           | 922 | benjamin | 127 | 	@Override
 | 
        
           |  |  | 128 | 	public void stopChargement() {
 | 
        
           |  |  | 129 | 		panneauChargement.setVisible(false);
 | 
        
           |  |  | 130 | 	}
 | 
        
           | 939 | benjamin | 131 |   | 
        
           |  |  | 132 | 	/**
 | 
        
           |  |  | 133 | 	 * Affiche un message indiquant qu'il n'y a aucun commentaire à présenter
 | 
        
           |  |  | 134 | 	 */
 | 
        
           | 926 | benjamin | 135 | 	@Override
 | 
        
           |  |  | 136 | 	public void afficherAucuneDonnees() {
 | 
        
           |  |  | 137 | 		aucuneDonnees.setVisible(true);
 | 
        
           |  |  | 138 | 	}
 | 
        
           | 922 | benjamin | 139 |   | 
        
           |  |  | 140 | }
 |