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