46 |
aurelien |
1 |
package org.tela_botanica.del.client.vues.plateformedetermination.forum;
|
|
|
2 |
|
140 |
aurelien |
3 |
import java.util.ArrayList;
|
|
|
4 |
import java.util.Date;
|
46 |
aurelien |
5 |
import java.util.List;
|
|
|
6 |
|
70 |
aurelien |
7 |
import org.tela_botanica.del.client.i18n.I18n;
|
140 |
aurelien |
8 |
import org.tela_botanica.del.client.modeles.Commentaire;
|
|
|
9 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
46 |
aurelien |
10 |
|
|
|
11 |
import com.google.gwt.core.client.GWT;
|
140 |
aurelien |
12 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
|
|
13 |
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
46 |
aurelien |
14 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
15 |
import com.google.gwt.uibinder.client.UiField;
|
|
|
16 |
import com.google.gwt.user.client.ui.Composite;
|
|
|
17 |
import com.google.gwt.user.client.ui.HTML;
|
|
|
18 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
19 |
|
|
|
20 |
public class ForumVue extends Composite {
|
|
|
21 |
|
|
|
22 |
private static ForumUIiBinder uiBinder = GWT.create(ForumUIiBinder.class);
|
|
|
23 |
interface ForumUIiBinder extends UiBinder<Widget, ForumVue>{};
|
|
|
24 |
|
|
|
25 |
@UiField(provided = true)
|
|
|
26 |
HTML htmlTableau = new HTML();
|
|
|
27 |
|
|
|
28 |
public ForumVue() {
|
|
|
29 |
initWidget(uiBinder.createAndBindUi(this));
|
|
|
30 |
}
|
|
|
31 |
|
140 |
aurelien |
32 |
public void chargerObservations(List<PropositionDetermination> determinations) {
|
46 |
aurelien |
33 |
|
|
|
34 |
String ligne = "<table>"+
|
|
|
35 |
"<tr>"+
|
70 |
aurelien |
36 |
"<th> "+I18n.getVocabulary().nom()+" </th>"+
|
|
|
37 |
"<th> "+I18n.getVocabulary().contributeur()+" </th>"+
|
80 |
aurelien |
38 |
"<th> "+I18n.getVocabulary().fiabilite()+" </th>"+
|
|
|
39 |
"<th> "+I18n.getVocabulary().date()+" </th>"+
|
|
|
40 |
"<th> "+I18n.getVocabulary().commentaire()+" </th>"+
|
46 |
aurelien |
41 |
"</tr>";
|
|
|
42 |
|
140 |
aurelien |
43 |
for (PropositionDetermination observationDetermination : determinations) {
|
|
|
44 |
|
46 |
aurelien |
45 |
ligne += "<tr>"+
|
|
|
46 |
"<td>"+observationDetermination.getEspece()+"</td>"+
|
|
|
47 |
"<td>"+observationDetermination.getContributeur()+"</td>"+
|
128 |
aurelien |
48 |
"<td>"+observationDetermination.getPourcentageConfiance()+"</td>"+
|
140 |
aurelien |
49 |
"<td>"+formaterDatePourForum(observationDetermination.getDate())+"</td>"+
|
|
|
50 |
"<td>"+creerListeCommentaireRecursive(observationDetermination.getCommentaires())+"</td>"+
|
46 |
aurelien |
51 |
"</tr>";
|
|
|
52 |
}
|
|
|
53 |
ligne += "</table>";
|
|
|
54 |
htmlTableau.setHTML(ligne);
|
|
|
55 |
}
|
140 |
aurelien |
56 |
|
|
|
57 |
private String creerListeCommentaireRecursive(ArrayList<Commentaire> commentaires) {
|
|
|
58 |
|
|
|
59 |
String commentairesHtml = "<ul class=\"liste_commentaire\">";
|
|
|
60 |
for (Commentaire commentaire : commentaires) {
|
|
|
61 |
commentairesHtml += "<li class=\"commentaire\">";
|
|
|
62 |
commentairesHtml += "<div class=\"commentaire_texte\">"+commentaire.getCommentaire()+"</div>";
|
|
|
63 |
commentairesHtml += "<span class=\"commentaire_auteur\">"+commentaire.getAuteur()+"</span>";
|
|
|
64 |
commentairesHtml += "<span class=\"commentaire_date\">"+formaterDatePourForum(commentaire.getDate())+"</span>";
|
|
|
65 |
if(commentaire.getListeCommentaires().size() != 0) {
|
|
|
66 |
commentairesHtml += creerListeCommentaireRecursive(commentaire.getListeCommentaires());
|
|
|
67 |
}
|
|
|
68 |
commentairesHtml += "</li>";
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
return commentairesHtml;
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
private String formaterDatePourForum(Date date) {
|
|
|
75 |
return DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(date);
|
|
|
76 |
}
|
46 |
aurelien |
77 |
|
|
|
78 |
}
|