| 985 | jpm | 1 | package org.tela_botanica.client.vues.commentaire;
 | 
        
           |  |  | 2 |   | 
        
           |  |  | 3 | import org.tela_botanica.client.ComposantClass;
 | 
        
           |  |  | 4 | import org.tela_botanica.client.ComposantId;
 | 
        
           |  |  | 5 | import org.tela_botanica.client.Mediateur;
 | 
        
           |  |  | 6 | import org.tela_botanica.client.interfaces.Rafraichissable;
 | 
        
           |  |  | 7 | import org.tela_botanica.client.modeles.ValeurListe;
 | 
        
           |  |  | 8 | import org.tela_botanica.client.modeles.commentaire.Commentaire;
 | 
        
           |  |  | 9 | import org.tela_botanica.client.modeles.projet.ProjetListe;
 | 
        
           |  |  | 10 | import org.tela_botanica.client.vues.DetailVue;
 | 
        
           |  |  | 11 |   | 
        
           | 1329 | cyprien | 12 | import com.extjs.gxt.ui.client.Style.Scroll;
 | 
        
           | 985 | jpm | 13 | import com.extjs.gxt.ui.client.util.Format;
 | 
        
           |  |  | 14 | import com.extjs.gxt.ui.client.util.Params;
 | 
        
           |  |  | 15 | import com.extjs.gxt.ui.client.widget.ContentPanel;
 | 
        
           |  |  | 16 | import com.extjs.gxt.ui.client.widget.Html;
 | 
        
           |  |  | 17 | import com.extjs.gxt.ui.client.widget.layout.FitLayout;
 | 
        
           |  |  | 18 | import com.google.gwt.core.client.GWT;
 | 
        
           |  |  | 19 |   | 
        
           |  |  | 20 | public class CommentaireDetailVue extends DetailVue implements Rafraichissable {
 | 
        
           |  |  | 21 |   | 
        
           |  |  | 22 | 	private String enteteTpl = null;
 | 
        
           |  |  | 23 | 	private String contenuTpl = null;
 | 
        
           |  |  | 24 |   | 
        
           |  |  | 25 | 	private ContentPanel panneauPrincipal = null;
 | 
        
           |  |  | 26 | 	private Html entete = null;
 | 
        
           |  |  | 27 | 	private Html contenu = null;
 | 
        
           |  |  | 28 |   | 
        
           |  |  | 29 | 	private Commentaire commentaire = null;
 | 
        
           |  |  | 30 | 	private boolean commentaireChargementOk = false;
 | 
        
           |  |  | 31 |   | 
        
           |  |  | 32 | 	public CommentaireDetailVue(Mediateur mediateurCourant) {
 | 
        
           |  |  | 33 | 		super(mediateurCourant);
 | 
        
           |  |  | 34 |   | 
        
           |  |  | 35 | 		initialiserTousLesTpl();
 | 
        
           |  |  | 36 | 		chargerOntologie();
 | 
        
           |  |  | 37 |   | 
        
           |  |  | 38 | 		panneauPrincipal = new ContentPanel();
 | 
        
           |  |  | 39 | 		panneauPrincipal.setLayout(new FitLayout());
 | 
        
           |  |  | 40 | 		panneauPrincipal.setHeaderVisible(false);
 | 
        
           |  |  | 41 | 		panneauPrincipal.setBodyBorder(false);
 | 
        
           | 1329 | cyprien | 42 | 		panneauPrincipal.setScrollMode(Scroll.AUTO);
 | 
        
           | 985 | jpm | 43 |   | 
        
           |  |  | 44 | 	    entete = new Html();
 | 
        
           |  |  | 45 | 	    entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
 | 
        
           |  |  | 46 | 	    panneauPrincipal.setTopComponent(entete);
 | 
        
           |  |  | 47 |   | 
        
           |  |  | 48 | 	    contenu = new Html();
 | 
        
           |  |  | 49 | 	    panneauPrincipal.add(contenu);
 | 
        
           |  |  | 50 |   | 
        
           |  |  | 51 | 		add(panneauPrincipal);
 | 
        
           |  |  | 52 | 	}
 | 
        
           |  |  | 53 |   | 
        
           |  |  | 54 | 	private void initialiserTousLesTpl() {
 | 
        
           |  |  | 55 | 		initialiserEnteteHtmlTpl();
 | 
        
           |  |  | 56 | 		initialiserGeneralTpl();
 | 
        
           |  |  | 57 | 	}
 | 
        
           |  |  | 58 |   | 
        
           |  |  | 59 | 	private void initialiserEnteteHtmlTpl() {
 | 
        
           |  |  | 60 | 		enteteTpl =
 | 
        
           |  |  | 61 | 			"<div id='{css_id}'>"+
 | 
        
           |  |  | 62 | 			"	<h1>{titre}</h1>"+
 | 
        
           |  |  | 63 | 			"	<h2>{collection}<span class='{css_meta}'>{projet} <br /> {i18n_id}:{id} - {guid}</span></h2>" +
 | 
        
           |  |  | 64 | 			"</div>";
 | 
        
           |  |  | 65 | 	}
 | 
        
           |  |  | 66 |   | 
        
           |  |  | 67 | 	private void initialiserGeneralTpl() {
 | 
        
           |  |  | 68 | 		contenuTpl =
 | 
        
           |  |  | 69 | 			"<div class='{css_corps}'>"+
 | 
        
           |  |  | 70 | 			"		<span class='{css_label}'>{i18n_type} :</span> {type}<br />"+
 | 
        
           |  |  | 71 | 			"		<span class='{css_label}'>{i18n_public} :</span> {public}<br />"+
 | 
        
           |  |  | 72 | 			"		<span class='{css_label}'>{i18n_ponderation} :</span> {ponderation}<br />"+
 | 
        
           |  |  | 73 | 			"		<span class='{css_label}'>{i18n_texte} :</span>"+
 | 
        
           |  |  | 74 | 			"		{texte}"+
 | 
        
           |  |  | 75 | 			"</div>";
 | 
        
           |  |  | 76 | 	}
 | 
        
           |  |  | 77 |   | 
        
           |  |  | 78 | 	private void chargerOntologie() {
 | 
        
           |  |  | 79 | 		String[] listesCodes = {"typeCommentaireCollection"};
 | 
        
           |  |  | 80 | 		lancerChargementListesValeurs(listesCodes);
 | 
        
           |  |  | 81 | 	}
 | 
        
           |  |  | 82 |   | 
        
           |  |  | 83 | 	public void afficherDetail() {
 | 
        
           |  |  | 84 | 		if (commentaire != null) {
 | 
        
           |  |  | 85 | 			afficherEntete();
 | 
        
           |  |  | 86 | 			afficherDetailCommentaire();
 | 
        
           |  |  | 87 | 		}
 | 
        
           |  |  | 88 | 		layout();
 | 
        
           |  |  | 89 | 	}
 | 
        
           |  |  | 90 |   | 
        
           |  |  | 91 | 	private void afficherEntete() {
 | 
        
           |  |  | 92 | 		Params enteteParams = new Params();
 | 
        
           |  |  | 93 | 		enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
 | 
        
           |  |  | 94 | 		enteteParams.set("css_meta", ComposantClass.META);
 | 
        
           |  |  | 95 |   | 
        
           |  |  | 96 | 		enteteParams.set("i18n_id", i18nC.id());
 | 
        
           |  |  | 97 |   | 
        
           |  |  | 98 | 		enteteParams.set("collection", commentaire.getCollection().getNom());
 | 
        
           |  |  | 99 | 		enteteParams.set("titre", commentaire.getTitre());
 | 
        
           |  |  | 100 | 		enteteParams.set("id", commentaire.getId());
 | 
        
           |  |  | 101 | 		enteteParams.set("guid", getGuid());
 | 
        
           |  |  | 102 | 		enteteParams.set("projet", construireTxtProjet(commentaire.getIdProjet()));
 | 
        
           |  |  | 103 |   | 
        
           |  |  | 104 | 		String eHtml = Format.substitute(enteteTpl, enteteParams);
 | 
        
           |  |  | 105 | 		entete.getElement().setInnerHTML(eHtml);
 | 
        
           |  |  | 106 | 	}
 | 
        
           |  |  | 107 |   | 
        
           |  |  | 108 | 	public String getGuid() {
 | 
        
           |  |  | 109 | 		String guid = "URN:tela-botanica.org:";
 | 
        
           |  |  | 110 | 		guid += "coel"+commentaire.getIdProjet()+":";
 | 
        
           |  |  | 111 | 		guid += "com"+commentaire.getId();
 | 
        
           |  |  | 112 | 		return guid;
 | 
        
           |  |  | 113 | 	}
 | 
        
           |  |  | 114 |   | 
        
           |  |  | 115 | 	public void afficherDetailCommentaire() {
 | 
        
           |  |  | 116 | 		Params contenuParams = new Params();
 | 
        
           |  |  | 117 |   | 
        
           |  |  | 118 | 		contenuParams.set("i18n_type", i18nC.commentaireType());
 | 
        
           |  |  | 119 | 		contenuParams.set("i18n_public", i18nC.commentairePublic());
 | 
        
           |  |  | 120 | 		contenuParams.set("i18n_ponderation", i18nC.commentairePonderation());
 | 
        
           |  |  | 121 | 		contenuParams.set("i18n_texte", i18nC.commentaireTexte());
 | 
        
           |  |  | 122 |   | 
        
           |  |  | 123 | 		String type = construireTxtListeOntologie(commentaire.getCollectionACommentaire().getType());
 | 
        
           |  |  | 124 |   | 
        
           |  |  | 125 | 		contenuParams.set("type", type);
 | 
        
           |  |  | 126 | 		contenuParams.set("ponderation", commentaire.getPonderation());
 | 
        
           |  |  | 127 | 		contenuParams.set("public", (commentaire.etrePublic() ? "public" : "privé"));
 | 
        
           |  |  | 128 | 		contenuParams.set("texte", commentaire.getTexte());
 | 
        
           |  |  | 129 |   | 
        
           |  |  | 130 | 		String gHtml = formaterContenu(contenuTpl, contenuParams);
 | 
        
           |  |  | 131 | 		contenu.getElement().setInnerHTML(gHtml);
 | 
        
           |  |  | 132 | 	}
 | 
        
           |  |  | 133 |   | 
        
           |  |  | 134 | 	public void rafraichir(Object nouvellesDonnees) {
 | 
        
           |  |  | 135 | 		if (nouvellesDonnees instanceof Commentaire) {
 | 
        
           |  |  | 136 | 			commentaire = (Commentaire) nouvellesDonnees;
 | 
        
           |  |  | 137 | 			commentaireChargementOk = true;
 | 
        
           |  |  | 138 | 		} else if (nouvellesDonnees instanceof ProjetListe) {
 | 
        
           |  |  | 139 | 			projets = (ProjetListe) nouvellesDonnees;
 | 
        
           |  |  | 140 | 			projetsChargementOk = true;
 | 
        
           |  |  | 141 | 		} else if (nouvellesDonnees instanceof ValeurListe) {
 | 
        
           |  |  | 142 | 			ValeurListe listeValeursReceptionnee = (ValeurListe) nouvellesDonnees;
 | 
        
           |  |  | 143 | 			receptionerListeValeurs(listeValeursReceptionnee);
 | 
        
           |  |  | 144 | 		} else {
 | 
        
           |  |  | 145 | 			GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
 | 
        
           |  |  | 146 | 		}
 | 
        
           |  |  | 147 |   | 
        
           |  |  | 148 | 		if (avoirDonneesChargees()) {
 | 
        
           |  |  | 149 | 			afficherDetail();
 | 
        
           |  |  | 150 | 		}
 | 
        
           |  |  | 151 | 	}
 | 
        
           |  |  | 152 |   | 
        
           |  |  | 153 | 	private boolean avoirDonneesChargees() {
 | 
        
           |  |  | 154 | 		boolean ok = false;
 | 
        
           |  |  | 155 | 		if (projetsChargementOk && commentaireChargementOk) {
 | 
        
           |  |  | 156 | 			ok = true;
 | 
        
           |  |  | 157 | 		}
 | 
        
           |  |  | 158 | 		return ok;
 | 
        
           |  |  | 159 | 	}
 | 
        
           |  |  | 160 | }
 |