Rev 140 | Blame | Last modification | View Log | RSS feed
package org.tela_botanica.del.client.vues.plateformedetermination.forum;
import java.util.Date;
import java.util.List;
import org.tela_botanica.del.client.i18n.I18n;
import org.tela_botanica.del.client.modeles.Commentaire;
import org.tela_botanica.del.client.modeles.PropositionDetermination;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
public class ForumVue extends Composite {
private static ForumUIiBinder uiBinder = GWT.create(ForumUIiBinder.class);
interface ForumUIiBinder extends UiBinder<Widget, ForumVue> {
};
@UiField(provided = true)
HTML htmlTableau = new HTML();
public ForumVue() {
initWidget(uiBinder.createAndBindUi(this));
}
public void chargerObservations(List<PropositionDetermination> determinations) {
String ligne = "<table>" + "<tr>" + "<th> " + I18n.getVocabulary().nom() + " </th>" + "<th> " + I18n.getVocabulary().contributeur() + " </th>" + "<th> " + I18n.getVocabulary().fiabilite() + " </th>" + "<th> " + I18n.getVocabulary().date() + " </th>" + "<th> " + I18n.getVocabulary().commentaire() + " </th>" + "</tr>";
for (PropositionDetermination observationDetermination : determinations) {
ligne += "<tr>" + "<td>" + observationDetermination.getEspece() + "</td>" + "<td>" + observationDetermination.getContributeur() + "</td>" + "<td>" + observationDetermination.getPourcentageConfiance() + "</td>" + "<td>" + formaterDatePourForum(observationDetermination.getDate()) + "</td>" + "<td>" + creerListeCommentaireRecursive(observationDetermination.getCommentaires()) + "</td>" + "</tr>";
}
ligne += "</table>";
htmlTableau.setHTML(ligne);
}
private String creerListeCommentaireRecursive(List<Commentaire> commentaires) {
String commentairesHtml = "<ul class=\"liste_commentaire\">";
for (Commentaire commentaire : commentaires) {
commentairesHtml += "<li class=\"commentaire\">";
commentairesHtml += "<div class=\"commentaire_texte\">" + commentaire.getCommentaire() + "</div>";
commentairesHtml += "<span class=\"commentaire_auteur\">" + commentaire.getAuteur() + "</span>";
commentairesHtml += "<span class=\"commentaire_date\">" + formaterDatePourForum(commentaire.getDate()) + "</span>";
if (commentaire.getListeCommentaires().size() != 0) {
commentairesHtml += creerListeCommentaireRecursive(commentaire.getListeCommentaires());
}
commentairesHtml += "</li>";
}
return commentairesHtml;
}
private String formaterDatePourForum(Date date) {
return DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(date);
}
}