935 |
jpm |
1 |
package org.tela_botanica.client.vues.projet;
|
834 |
aurelien |
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;
|
908 |
aurelien |
7 |
import org.tela_botanica.client.modeles.ValeurListe;
|
935 |
jpm |
8 |
import org.tela_botanica.client.modeles.projet.Projet;
|
|
|
9 |
import org.tela_botanica.client.modeles.projet.ProjetListe;
|
1114 |
jpm |
10 |
import org.tela_botanica.client.util.UtilString;
|
936 |
jpm |
11 |
import org.tela_botanica.client.vues.DetailVue;
|
834 |
aurelien |
12 |
|
|
|
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 ProjetDetailVue extends DetailVue implements Rafraichissable {
|
|
|
21 |
|
|
|
22 |
private String enteteTpl = null;
|
|
|
23 |
private String contenuTpl = null;
|
1121 |
jpm |
24 |
private String indexationTpl = null;
|
834 |
aurelien |
25 |
|
|
|
26 |
private ContentPanel panneauPrincipal = null;
|
|
|
27 |
private Html entete = null;
|
|
|
28 |
private Html contenu = null;
|
|
|
29 |
|
928 |
jpm |
30 |
private final String listeValeurIndexationDureeId = "dureesIndexation";
|
|
|
31 |
private final int listeValeurIndexationDureeInt = 1072;
|
|
|
32 |
private final String listeValeurIndexationFrequenceId = "frequencesIndexation";
|
|
|
33 |
private final int listeValeurIndexationFrequenceInt = 1073;
|
|
|
34 |
private final String listeLanguesId = "langues";
|
|
|
35 |
private final int listeLanguesInt = 1071;
|
|
|
36 |
|
834 |
aurelien |
37 |
private Projet projet = null;
|
|
|
38 |
private boolean projetChargementOk = false;
|
928 |
jpm |
39 |
private ValeurListe valeurListeIndexationDuree = null;
|
|
|
40 |
private boolean listeIndexationDureeChargee = false;
|
908 |
aurelien |
41 |
private ValeurListe valeurListeIndexationFrequence = null;
|
928 |
jpm |
42 |
private boolean listeIndexationFrequenceChargee = false;
|
908 |
aurelien |
43 |
private ValeurListe valeurListeLangue = null;
|
|
|
44 |
private boolean listeLangueChargee = false;
|
834 |
aurelien |
45 |
|
|
|
46 |
public ProjetDetailVue(Mediateur mediateurCourant) {
|
|
|
47 |
super(mediateurCourant);
|
|
|
48 |
|
|
|
49 |
initialiserTousLesTpl();
|
|
|
50 |
|
|
|
51 |
panneauPrincipal = new ContentPanel();
|
|
|
52 |
panneauPrincipal.setLayout(new FitLayout());
|
|
|
53 |
panneauPrincipal.setHeaderVisible(false);
|
|
|
54 |
panneauPrincipal.setBodyBorder(false);
|
|
|
55 |
|
|
|
56 |
entete = new Html();
|
|
|
57 |
entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
|
|
|
58 |
panneauPrincipal.setTopComponent(entete);
|
|
|
59 |
|
|
|
60 |
contenu = new Html();
|
|
|
61 |
panneauPrincipal.add(contenu);
|
|
|
62 |
|
|
|
63 |
add(panneauPrincipal);
|
908 |
aurelien |
64 |
|
|
|
65 |
mediateurCourant.obtenirListeValeurEtRafraichir(this, listeValeurIndexationDureeId);
|
|
|
66 |
mediateurCourant.obtenirListeValeurEtRafraichir(this, listeValeurIndexationFrequenceId);
|
|
|
67 |
mediateurCourant.obtenirListeValeurEtRafraichir(this, listeLanguesId);
|
834 |
aurelien |
68 |
}
|
|
|
69 |
|
|
|
70 |
private void initialiserTousLesTpl() {
|
|
|
71 |
initialiserEnteteHtmlTpl();
|
|
|
72 |
initialiserGeneralTpl();
|
1121 |
jpm |
73 |
initialiserIndexationTpl();
|
834 |
aurelien |
74 |
}
|
|
|
75 |
|
|
|
76 |
private void initialiserEnteteHtmlTpl() {
|
|
|
77 |
enteteTpl =
|
|
|
78 |
"<div id='{css_id}'>"+
|
877 |
aurelien |
79 |
" <h1>{projet}</h1>"+
|
|
|
80 |
" <h2>{abreviation} <span class='{css_meta}'>{projet} <br /> {i18n_id}:{id} - {guid}</span></h2>" +
|
834 |
aurelien |
81 |
"</div>";
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
private void initialiserGeneralTpl() {
|
|
|
85 |
contenuTpl =
|
|
|
86 |
"<div class='{css_corps}'>"+
|
|
|
87 |
" <div class='{css_fieldset}'>"+
|
928 |
jpm |
88 |
" <h2>{i18n_titre_info_generale}</h2>"+
|
877 |
aurelien |
89 |
" <span class='{css_label}'>{i18n_nom} :</span> {nom}<br />"+
|
|
|
90 |
" <span class='{css_label}'>{i18n_abreviation} :</span> {abreviation}<br />"+
|
|
|
91 |
" <span class='{css_label}'>{i18n_resume} :</span> {resume}<br />"+
|
|
|
92 |
" <span class='{css_label}'>{i18n_description} :</span> {description}<br />"+
|
1121 |
jpm |
93 |
" <span class='{css_label}'>{i18n_url} :</span> <a class='{css_lien_ext}' href='{url}' onclick='window.open(this.href); return false;'>{url}</a><br />"+
|
928 |
jpm |
94 |
" </div>"+
|
|
|
95 |
" <div class='{css_fieldset}'>"+
|
|
|
96 |
" <h2>{i18n_titre_complement}</h2>"+
|
|
|
97 |
" <span class='{css_label}'>{i18n_mot_cles} :</span> {mot_cles}<br />"+
|
877 |
aurelien |
98 |
" <span class='{css_label}'>{i18n_citation} :</span> {citation}<br />"+
|
|
|
99 |
" <span class='{css_label}'>{i18n_licence} :</span> {licence}<br />"+
|
|
|
100 |
" <span class='{css_label}'>{i18n_langue} :</span> {langue}<br />"+
|
928 |
jpm |
101 |
" </div>"+
|
|
|
102 |
" <hr class='{css_clear}'/>"+
|
|
|
103 |
" <div class='{css_fieldset}'>"+
|
|
|
104 |
" <h2>{i18n_titre_indexation}</h2>"+
|
877 |
aurelien |
105 |
" <span class='{css_label}'>{i18n_mark_public} :</span> {mark_public}<br />"+
|
1121 |
jpm |
106 |
" {indexation}"+
|
834 |
aurelien |
107 |
" </div>"+
|
|
|
108 |
"</div>";
|
|
|
109 |
}
|
|
|
110 |
|
1121 |
jpm |
111 |
private void initialiserIndexationTpl() {
|
|
|
112 |
indexationTpl =
|
|
|
113 |
" <span class='{css_label}'>{i18n_indexation_heure} :</span> {indexation_heure}<br />"+
|
|
|
114 |
" <span class='{css_label}'>{i18n_indexation_duree} :</span> {indexation_duree}<br />"+
|
|
|
115 |
" <span class='{css_label}'>{i18n_indexation_frequence} :</span> {indexation_frequence}<br />";
|
|
|
116 |
}
|
|
|
117 |
|
834 |
aurelien |
118 |
public void afficherDetail() {
|
|
|
119 |
if (projet != null) {
|
|
|
120 |
afficherEntete();
|
|
|
121 |
afficherDetailProjet();
|
|
|
122 |
}
|
|
|
123 |
layout();
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
private void afficherEntete() {
|
|
|
127 |
Params enteteParams = new Params();
|
|
|
128 |
enteteParams.set("css_id", ComposantId.ZONE_DETAIL_ENTETE);
|
|
|
129 |
enteteParams.set("css_meta", ComposantClass.META);
|
|
|
130 |
|
|
|
131 |
enteteParams.set("i18n_id", i18nC.id());
|
|
|
132 |
|
|
|
133 |
enteteParams.set("id", projet.getId());
|
|
|
134 |
enteteParams.set("guid", getGuid());
|
|
|
135 |
enteteParams.set("projet", construireTxtProjet(projet.getId()));
|
877 |
aurelien |
136 |
enteteParams.set("abreviation", projet.getAbreviation());
|
834 |
aurelien |
137 |
GWT.log("entete généré", null);
|
|
|
138 |
String eHtml = Format.substitute(enteteTpl, enteteParams);
|
|
|
139 |
entete.getElement().setInnerHTML(eHtml);
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
public String getGuid() {
|
|
|
143 |
String guid = "URN:tela-botanica.org:";
|
|
|
144 |
guid += "coel"+projet.getId()+":";
|
|
|
145 |
guid += "pro"+projet.getId();
|
|
|
146 |
return guid;
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
public void afficherDetailProjet() {
|
|
|
150 |
Params contenuParams = new Params();
|
|
|
151 |
|
928 |
jpm |
152 |
contenuParams.set("i18n_titre_info_generale", i18nC.projetTitreInfoGenerale());
|
834 |
aurelien |
153 |
|
877 |
aurelien |
154 |
contenuParams.set("i18n_nom", i18nC.nom());
|
|
|
155 |
contenuParams.set("nom", projet.getNom());
|
|
|
156 |
|
|
|
157 |
contenuParams.set("i18n_abreviation", i18nC.projetAbreviation());
|
|
|
158 |
contenuParams.set("abreviation", projet.getAbreviation());
|
|
|
159 |
|
|
|
160 |
contenuParams.set("i18n_resume", i18nC.projetResume());
|
|
|
161 |
contenuParams.set("resume", projet.getResume());
|
|
|
162 |
|
|
|
163 |
contenuParams.set("i18n_description", i18nC.projetDescription());
|
|
|
164 |
contenuParams.set("description", projet.getDescription());
|
|
|
165 |
|
1121 |
jpm |
166 |
contenuParams.set("i18n_url", i18nC.projetUrl());
|
|
|
167 |
contenuParams.set("url", projet.getUrl());
|
|
|
168 |
|
928 |
jpm |
169 |
contenuParams.set("i18n_titre_complement", i18nC.projetTitreComplement());
|
877 |
aurelien |
170 |
|
928 |
jpm |
171 |
contenuParams.set("i18n_mot_cles", i18nC.projetMotsCles());
|
|
|
172 |
contenuParams.set("mot_cles", projet.getMotsCles());
|
|
|
173 |
|
877 |
aurelien |
174 |
contenuParams.set("i18n_citation", i18nC.projetCitation());
|
|
|
175 |
contenuParams.set("citation", projet.getCitation());
|
|
|
176 |
|
|
|
177 |
contenuParams.set("i18n_licence", i18nC.projetLicence());
|
|
|
178 |
contenuParams.set("licence", projet.getLicence());
|
|
|
179 |
|
|
|
180 |
contenuParams.set("i18n_langue", i18nC.projetLangue());
|
908 |
aurelien |
181 |
contenuParams.set("langue", obtenirValeurLangue(projet.getLangue()));
|
877 |
aurelien |
182 |
|
928 |
jpm |
183 |
contenuParams.set("i18n_titre_indexation", i18nC.projetTitreIndexation());
|
|
|
184 |
|
877 |
aurelien |
185 |
contenuParams.set("i18n_mark_public", i18nC.projetMarkPublic());
|
908 |
aurelien |
186 |
contenuParams.set("mark_public", obtenirValeurPublic(projet.getMarkPublic()));
|
877 |
aurelien |
187 |
|
1121 |
jpm |
188 |
contenuParams.set("indexation", creerIndexation());
|
|
|
189 |
|
834 |
aurelien |
190 |
String gHtml = formaterContenu(contenuTpl, contenuParams);
|
|
|
191 |
contenu.getElement().setInnerHTML(gHtml);
|
|
|
192 |
}
|
|
|
193 |
|
1114 |
jpm |
194 |
private String corrigerIndexationHeure(String heureMinuteSecondeEnBdd) {
|
|
|
195 |
String heureMinute = "";
|
|
|
196 |
if (!UtilString.isEmpty(heureMinuteSecondeEnBdd)) {
|
|
|
197 |
heureMinute = heureMinuteSecondeEnBdd.replaceAll(":00$", "");
|
|
|
198 |
}
|
|
|
199 |
return heureMinute;
|
|
|
200 |
}
|
|
|
201 |
|
1121 |
jpm |
202 |
private String creerIndexation() {
|
|
|
203 |
String html = "";
|
|
|
204 |
if (projet.getMarkPublic().equals("1")) {
|
|
|
205 |
Params indexationParams = new Params();
|
|
|
206 |
|
|
|
207 |
indexationParams.set("i18n_indexation_heure", i18nC.projetIndexationHeure());
|
|
|
208 |
indexationParams.set("indexation_heure", corrigerIndexationHeure(projet.getIndexationHeure()));
|
|
|
209 |
|
|
|
210 |
indexationParams.set("i18n_indexation_duree", i18nC.projetIndexationDuree());
|
|
|
211 |
indexationParams.set("indexation_duree", obtenirValeurIndexationDuree(projet.getIndexationDuree()));
|
|
|
212 |
|
|
|
213 |
indexationParams.set("i18n_indexation_frequence", i18nC.projetIndexationFrequence());
|
|
|
214 |
indexationParams.set("indexation_frequence", obtenirValeurIndexationFrequence(projet.getIndexationFreq()));
|
|
|
215 |
|
|
|
216 |
html = Format.substitute(indexationTpl, indexationParams);
|
|
|
217 |
}
|
|
|
218 |
return html;
|
|
|
219 |
}
|
|
|
220 |
|
834 |
aurelien |
221 |
public void rafraichir(Object nouvellesDonnees) {
|
|
|
222 |
if (nouvellesDonnees instanceof Projet) {
|
|
|
223 |
projet = (Projet) nouvellesDonnees;
|
|
|
224 |
projetChargementOk = true;
|
|
|
225 |
} else if (nouvellesDonnees instanceof ProjetListe) {
|
|
|
226 |
projets = (ProjetListe) nouvellesDonnees;
|
|
|
227 |
projetsChargementOk = true;
|
908 |
aurelien |
228 |
} else if(nouvellesDonnees instanceof ValeurListe) {
|
|
|
229 |
ValeurListe nValeurListe = (ValeurListe)nouvellesDonnees;
|
|
|
230 |
|
924 |
jpm |
231 |
if (nValeurListe.getId() == listeValeurIndexationDureeInt) {
|
908 |
aurelien |
232 |
valeurListeIndexationDuree = (ValeurListe)nouvellesDonnees;
|
|
|
233 |
listeIndexationDureeChargee = true;
|
|
|
234 |
}
|
|
|
235 |
|
924 |
jpm |
236 |
if (nValeurListe.getId() == listeValeurIndexationFrequenceInt) {
|
908 |
aurelien |
237 |
valeurListeIndexationFrequence = (ValeurListe)nouvellesDonnees;
|
|
|
238 |
listeIndexationFrequenceChargee = true;
|
|
|
239 |
}
|
|
|
240 |
|
924 |
jpm |
241 |
if (nValeurListe.getId() == listeLanguesInt) {
|
908 |
aurelien |
242 |
valeurListeLangue = (ValeurListe)nouvellesDonnees;
|
|
|
243 |
listeLangueChargee = true;
|
|
|
244 |
}
|
928 |
jpm |
245 |
} else {
|
834 |
aurelien |
246 |
GWT.log(Mediateur.i18nM.erreurRafraichir(nouvellesDonnees.getClass(), this.getClass()), null);
|
|
|
247 |
}
|
|
|
248 |
|
|
|
249 |
if (avoirDonneesChargees()) {
|
|
|
250 |
afficherDetail();
|
|
|
251 |
}
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
private boolean avoirDonneesChargees() {
|
|
|
255 |
boolean ok = false;
|
928 |
jpm |
256 |
if (projetsChargementOk && projetChargementOk && listeIndexationDureeChargee && listeIndexationFrequenceChargee && listeLangueChargee) {
|
834 |
aurelien |
257 |
ok = true;
|
|
|
258 |
}
|
|
|
259 |
return ok;
|
|
|
260 |
}
|
908 |
aurelien |
261 |
|
|
|
262 |
private String obtenirValeurIndexationDuree(String id) {
|
924 |
jpm |
263 |
if (valeurListeIndexationDuree.get(id) != null) {
|
908 |
aurelien |
264 |
return valeurListeIndexationDuree.get(id).getNom();
|
|
|
265 |
}
|
|
|
266 |
return "";
|
|
|
267 |
}
|
|
|
268 |
|
|
|
269 |
private String obtenirValeurIndexationFrequence(String id) {
|
924 |
jpm |
270 |
if (valeurListeIndexationFrequence.get(id) != null) {
|
908 |
aurelien |
271 |
return valeurListeIndexationFrequence.get(id).getNom();
|
|
|
272 |
}
|
|
|
273 |
return "";
|
|
|
274 |
}
|
|
|
275 |
|
|
|
276 |
private String obtenirValeurLangue(String id) {
|
924 |
jpm |
277 |
if (valeurListeLangue.get(id) != null) {
|
908 |
aurelien |
278 |
return valeurListeLangue.get(id).getNom();
|
|
|
279 |
}
|
|
|
280 |
return "";
|
|
|
281 |
}
|
|
|
282 |
|
|
|
283 |
private String obtenirValeurPublic(String ouiNon) {
|
924 |
jpm |
284 |
if (ouiNon.equals("1")) {
|
908 |
aurelien |
285 |
return i18nC.oui();
|
|
|
286 |
}
|
|
|
287 |
return i18nC.non();
|
|
|
288 |
}
|
834 |
aurelien |
289 |
}
|