171 |
aurelien |
1 |
package org.tela_botanica.del.client.vues.plateformedetermination.forum;
|
|
|
2 |
|
|
|
3 |
import java.util.Date;
|
|
|
4 |
import java.util.List;
|
|
|
5 |
|
|
|
6 |
import org.tela_botanica.del.client.modeles.Commentaire;
|
|
|
7 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
|
|
8 |
|
|
|
9 |
import com.google.gwt.i18n.client.DateTimeFormat;
|
|
|
10 |
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
|
|
11 |
import com.google.gwt.user.client.ui.Composite;
|
|
|
12 |
import com.google.gwt.user.client.ui.FlexTable;
|
|
|
13 |
import com.google.gwt.user.client.ui.HTML;
|
|
|
14 |
import com.google.gwt.user.client.ui.Tree;
|
|
|
15 |
import com.google.gwt.user.client.ui.TreeItem;
|
|
|
16 |
|
|
|
17 |
public class LigneForumVue extends Composite {
|
|
|
18 |
|
|
|
19 |
FlexTable tableParente;
|
|
|
20 |
HTML barreRepartition;
|
|
|
21 |
|
|
|
22 |
public LigneForumVue(FlexTable flexTable) {
|
|
|
23 |
tableParente = flexTable;
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
public void chargerDetermination(PropositionDetermination determination, HTML barreRepartition) {
|
|
|
27 |
|
|
|
28 |
Tree arbreCommentaires = new Tree();
|
|
|
29 |
TreeItem racineArbreCommentaires = new TreeItem();
|
|
|
30 |
arbreCommentaires.addItem(racineArbreCommentaires);
|
|
|
31 |
creerListeCommentaireRecursive(racineArbreCommentaires, determination.getCommentaires());
|
|
|
32 |
|
|
|
33 |
int ligne = tableParente.getRowCount() + 1;
|
|
|
34 |
tableParente.setHTML(ligne, 1, barreRepartition.getHTML());
|
|
|
35 |
tableParente.setHTML(ligne, 2, determination.getContributeur());
|
|
|
36 |
tableParente.setHTML(ligne, 3, DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(determination.getDate()));
|
|
|
37 |
tableParente.setWidget(ligne, 4, arbreCommentaires);
|
|
|
38 |
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
private void creerListeCommentaireRecursive(TreeItem parentTreeItem, List<Commentaire> commentaires) {
|
|
|
42 |
|
|
|
43 |
for (Commentaire commentaire : commentaires) {
|
|
|
44 |
String commentaireHTML = commentaire.getCommentaire() +" "+ commentaire.getAuteur() + "-"+formaterDatePourForum(commentaire.getDate());
|
|
|
45 |
parentTreeItem.setHTML(commentaireHTML);
|
|
|
46 |
if (commentaire.getListeCommentaires().size() != 0) {
|
|
|
47 |
TreeItem childTreeItem = new TreeItem();
|
|
|
48 |
parentTreeItem.addItem(childTreeItem);
|
|
|
49 |
creerListeCommentaireRecursive(childTreeItem, commentaire.getListeCommentaires());
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
parentTreeItem.setState(true);
|
|
|
53 |
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
private String formaterDatePourForum(Date date) {
|
|
|
57 |
return DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(date);
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
}
|