| 1196 | gduche | 1 | package org.tela_botanica.del.client.composants.forum;
 | 
        
           |  |  | 2 |   | 
        
           |  |  | 3 | import java.util.ArrayList;
 | 
        
           |  |  | 4 | import java.util.Date;
 | 
        
           |  |  | 5 | import java.util.List;
 | 
        
           |  |  | 6 |   | 
        
           |  |  | 7 | import org.tela_botanica.del.client.modeles.Commentaire;
 | 
        
           |  |  | 8 | import org.tela_botanica.del.client.modeles.InterventionForum;
 | 
        
           |  |  | 9 |   | 
        
           |  |  | 10 | import com.google.gwt.i18n.client.DateTimeFormat;
 | 
        
           |  |  | 11 | import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
 | 
        
           |  |  | 12 | import com.google.gwt.user.client.ui.HTML;
 | 
        
           |  |  | 13 | import com.google.gwt.user.client.ui.Tree;
 | 
        
           |  |  | 14 | import com.google.gwt.user.client.ui.TreeItem;
 | 
        
           |  |  | 15 |   | 
        
           |  |  | 16 | public class ArbreCommentaireVue extends Tree implements ArbreCommentairePresenteur.Vue {
 | 
        
           |  |  | 17 |   | 
        
           |  |  | 18 | 	public ArbreCommentaireVue() {
 | 
        
           |  |  | 19 | 		super();
 | 
        
           |  |  | 20 | 	}
 | 
        
           |  |  | 21 |   | 
        
           |  |  | 22 | 	public void creerArbreCommentaire(InterventionForum possesseurDeCommentaires) {
 | 
        
           |  |  | 23 | 		TreeItem racineArbreCommentaires = new TreeItem();
 | 
        
           |  |  | 24 | 		addItem(racineArbreCommentaires);
 | 
        
           |  |  | 25 |   | 
        
           |  |  | 26 | 		if (possesseurDeCommentaires instanceof Commentaire) {
 | 
        
           |  |  | 27 | 			List<Commentaire> commentaires = new ArrayList<Commentaire>();
 | 
        
           |  |  | 28 | 			commentaires.add((Commentaire) possesseurDeCommentaires);
 | 
        
           |  |  | 29 | 			creerListeCommentaireRecursive(racineArbreCommentaires, commentaires);
 | 
        
           |  |  | 30 | 		} else {
 | 
        
           |  |  | 31 | 			creerListeCommentaireRecursive(racineArbreCommentaires, possesseurDeCommentaires.getListeCommentaires());
 | 
        
           |  |  | 32 | 		}
 | 
        
           |  |  | 33 | 	}
 | 
        
           |  |  | 34 |   | 
        
           |  |  | 35 | 	private void creerListeCommentaireRecursive(TreeItem parentTreeItem, List<Commentaire> commentaires) {
 | 
        
           |  |  | 36 |   | 
        
           |  |  | 37 | 		for (Commentaire commentaire : commentaires) {
 | 
        
           |  |  | 38 | 			String commentaireHTML = commentaire.getCommentaire();
 | 
        
           |  |  | 39 | 			HTML commentaireWidget = new HTML(commentaireHTML);
 | 
        
           |  |  | 40 | 			parentTreeItem.setWidget(commentaireWidget);
 | 
        
           |  |  | 41 | 			if (commentaire.getListeCommentaires().size() != 0) {
 | 
        
           |  |  | 42 | 				TreeItem childTreeItem = new TreeItem();
 | 
        
           |  |  | 43 | 				parentTreeItem.addItem(childTreeItem);
 | 
        
           |  |  | 44 | 				creerListeCommentaireRecursive(childTreeItem, commentaire.getListeCommentaires());
 | 
        
           |  |  | 45 | 			}
 | 
        
           |  |  | 46 | 		}
 | 
        
           |  |  | 47 | 		parentTreeItem.setState(true);
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 | 	}
 | 
        
           |  |  | 50 | }
 |