Subversion Repositories eFlore/Applications.coel

Rev

Rev 1415 | Rev 1513 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
935 jpm 1
package org.tela_botanica.client.vues.personne;
150 gduche 2
 
253 gduche 3
import java.util.Collection;
197 gduche 4
import java.util.HashMap;
5
import java.util.Iterator;
253 gduche 6
import java.util.LinkedList;
1284 gduche 7
import java.util.List;
189 gduche 8
 
435 gduche 9
import org.tela_botanica.client.ComposantId;
305 gduche 10
import org.tela_botanica.client.Mediateur;
150 gduche 11
import org.tela_botanica.client.RegistreId;
907 jpm 12
import org.tela_botanica.client.configuration.Configuration;
150 gduche 13
import org.tela_botanica.client.interfaces.Rafraichissable;
1369 cyprien 14
import org.tela_botanica.client.modeles.Valeur;
305 gduche 15
import org.tela_botanica.client.modeles.ValeurListe;
935 jpm 16
import org.tela_botanica.client.modeles.personne.Personne;
1284 gduche 17
import org.tela_botanica.client.modeles.publication.Publication;
18
import org.tela_botanica.client.modeles.publication.PublicationAPersonne;
19
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
1322 gduche 20
import org.tela_botanica.client.synchronisation.Sequenceur;
1292 cyprien 21
import org.tela_botanica.client.util.Debug;
936 jpm 22
import org.tela_botanica.client.vues.DetailVue;
527 gduche 23
 
150 gduche 24
import com.extjs.gxt.ui.client.Registry;
25
import com.extjs.gxt.ui.client.Style.Scroll;
435 gduche 26
import com.extjs.gxt.ui.client.util.Format;
27
import com.extjs.gxt.ui.client.util.Params;
215 aurelien 28
import com.extjs.gxt.ui.client.widget.ContentPanel;
527 gduche 29
import com.extjs.gxt.ui.client.widget.Html;
189 gduche 30
import com.extjs.gxt.ui.client.widget.TabItem;
31
import com.extjs.gxt.ui.client.widget.TabPanel;
197 gduche 32
import com.extjs.gxt.ui.client.widget.form.FieldSet;
246 gduche 33
import com.extjs.gxt.ui.client.widget.form.LabelField;
527 gduche 34
import com.extjs.gxt.ui.client.widget.layout.AnchorLayout;
150 gduche 35
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
197 gduche 36
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
37
import com.google.gwt.user.client.ui.Image;
150 gduche 38
 
527 gduche 39
public class PersonneDetailVue extends DetailVue implements Rafraichissable {
150 gduche 40
 
269 gduche 41
	private TabPanel tabPanel;
527 gduche 42
	private Html entete;
915 jpm 43
 
215 aurelien 44
	private TabItem tabIdentite;
200 gduche 45
	private TabItem tabAdresse;
215 aurelien 46
	private TabItem tabInfosNat;
435 gduche 47
	private TabItem tabLogos;
1284 gduche 48
	private TabItem tabPublications;
49
 
915 jpm 50
	private HashMap hmLabelFieldRegion = new HashMap();
51
 
52
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
53
	private Personne personneAAfficher = null;
54
 
1284 gduche 55
	private String tableauPublicationsLieesTpl = "";
56
	private String lignePublicationLieeTpl = "";
915 jpm 57
 
1322 gduche 58
	private Sequenceur sequenceur = new Sequenceur();
435 gduche 59
 
527 gduche 60
	public PersonneDetailVue(Mediateur mediateur) {
61
		super(mediateur);
1369 cyprien 62
 
820 gduche 63
		setLayout(new FitLayout());
64
 
527 gduche 65
		entete = new Html();
66
		entete.setId(ComposantId.ZONE_DETAIL_ENTETE);
820 gduche 67
 
527 gduche 68
		ContentPanel panneauPrincipal = new ContentPanel();
69
		panneauPrincipal.setLayout(new FitLayout());
70
		panneauPrincipal.setHeaderVisible(false);
71
		panneauPrincipal.setBodyBorder(true);
72
		panneauPrincipal.setTopComponent(entete);
820 gduche 73
 
915 jpm 74
		tabIdentite = new TabItem(i18nC.personneIdentite());
1369 cyprien 75
		tabIdentite.setTitle(i18nC.personneIdentite());
527 gduche 76
		tabIdentite.setLayout(new AnchorLayout());
820 gduche 77
		tabIdentite.setScrollMode(Scroll.AUTO);
78
 
915 jpm 79
		tabAdresse = new TabItem(i18nC.personneAdresses());
1369 cyprien 80
		tabAdresse.setTitle(i18nC.personneAdresses());
472 gduche 81
		tabAdresse.setLayout(new FitLayout());
82
		tabAdresse.setScrollMode(Scroll.AUTO);
820 gduche 83
 
915 jpm 84
		tabInfosNat = new TabItem(i18nC.personneInfoNat());
1369 cyprien 85
		tabInfosNat.setTitle(i18nC.personneInfoNat());
321 gduche 86
		tabInfosNat.setScrollMode(Scroll.AUTO);
820 gduche 87
 
1284 gduche 88
		tabPublications = new TabItem(i18nC.tabPublications());
1369 cyprien 89
		tabPublications.setTitle(i18nC.tabPublications());
1284 gduche 90
		tabPublications.setScrollMode(Scroll.AUTO);
91
		tabPublications.setLayout(new FlowLayout());
92
 
915 jpm 93
		tabLogos = new TabItem(i18nC.personneLogos());
1369 cyprien 94
		tabLogos.setTitle(i18nC.personneLogos());
680 gduche 95
		tabLogos.setScrollMode(Scroll.AUTO);
435 gduche 96
		tabLogos.setLayout(new FlowLayout());
820 gduche 97
 
527 gduche 98
		tabPanel = new TabPanel();
99
		tabPanel.setId(ComposantId.ZONE_DETAIL_CORPS);
100
		tabPanel.setBodyBorder(false);
820 gduche 101
 
527 gduche 102
		tabPanel.add(tabIdentite);
103
		tabPanel.add(tabAdresse);
104
		tabPanel.add(tabInfosNat);
1284 gduche 105
		tabPanel.add(tabPublications);
435 gduche 106
		tabPanel.add(tabLogos);
820 gduche 107
 
527 gduche 108
		panneauPrincipal.add(tabPanel);
109
		add(panneauPrincipal);
150 gduche 110
	}
111
 
112
	public void afficherDetailPersonne(Personne personne) {
113
		if (personne != null) {
527 gduche 114
			String tplEntete = initialiserTplEntete();
1284 gduche 115
 
116
			//Sélection des publication à personne
1367 cyprien 117
			mediateur.selectionnerPublicationAPersonne(this, null, personne.getId(), new LinkedList(), null);
820 gduche 118
 
435 gduche 119
			Params enteteParams = new Params();
120
			enteteParams.set("nom", (String) personne.get("fmt_nom_complet"));
947 gduche 121
			enteteParams.set("mail", (String) personne.getCourrielPrinc());
820 gduche 122
 
123
			LinkedList lstLogos = (LinkedList) personne
124
					.getChaineDenormaliseAsMapOrList("truk_logo");
125
			if (lstLogos != null && lstLogos.size() > 0) {
126
 
435 gduche 127
				tabLogos.removeAll();
128
				String urlLogoPrinc = (String) lstLogos.get(0);
820 gduche 129
				if (!urlLogoPrinc.trim().equals("")) {
130
					tplEntete = "<div id='personne-logo-div'><img src='{image}' alt='logo' /></div>"
131
							+ tplEntete;
435 gduche 132
					enteteParams.set("image", urlLogoPrinc);
253 gduche 133
				}
820 gduche 134
 
435 gduche 135
				Iterator<String> itLogo = lstLogos.iterator();
820 gduche 136
				while (itLogo.hasNext()) {
435 gduche 137
					String urlLogoCourant = itLogo.next();
138
					Image imgCourante = new Image(urlLogoCourant);
820 gduche 139
					tabLogos.add(imgCourante);
435 gduche 140
				}
527 gduche 141
				tabLogos.enable();
820 gduche 142
 
435 gduche 143
			} else {
472 gduche 144
				enteteParams.set("image", "");
435 gduche 145
				tabLogos.disable();
472 gduche 146
			}
820 gduche 147
 
915 jpm 148
			entete.el().setInnerHtml(Format.substitute(tplEntete, enteteParams));
820 gduche 149
 
527 gduche 150
			String tplIdentite = initialiserTplIdentite();
820 gduche 151
 
435 gduche 152
			Params tabIdentiteParams = new Params();
828 gduche 153
			tabIdentiteParams.set("nom_complet", personne.getString("fmt_nom_complet"));
154
			tabIdentiteParams.set("abreviation", personne.getString("abreviation"));
1284 gduche 155
			tabIdentiteParams.set("naissance_date", personne.getAnneeOuDateNaiss().equals("") ? mediateur.i18nC.inconnue() : personne.getAnneeOuDateNaiss());
828 gduche 156
			tabIdentiteParams.set("naissance_lieu", personne.getString("naissance_lieu"));
157
			String tplDeces = "";
158
			if (personne.estDecedee())	{
159
				tplDeces = " <h2>Décès:</h2>"
160
						+ " <span><b>"
915 jpm 161
						+ i18nC.personneDateDeces()
828 gduche 162
						+ ":</b></span> {deces_date}<br />"
163
						+ " 	 <span><b>"
915 jpm 164
						+ i18nC.personneLieuDeces()
828 gduche 165
						+ ":</b></span> {deces_lieu}<br /><br />";
166
 
1284 gduche 167
				tabIdentiteParams.set("deces_date", personne.getAnneeOuDateDeces().equals("") ? mediateur.i18nC.inconnue() : personne.getAnneeOuDateDeces());
828 gduche 168
				tabIdentiteParams.set("deces_lieu", personne.getString("deces_lieu"));
169
			}
170
 
171
			Params paramsDeces = new Params();
172
			paramsDeces.set("tplDeces", tplDeces);
173
			tplIdentite = Format.substitute(tplIdentite, paramsDeces);
174
 
175
			tabIdentiteParams.set("description", personne.getString("description"));
820 gduche 176
 
321 gduche 177
			tabInfosNat.removeAll();
820 gduche 178
 
179
			tabIdentiteParams.set("nom_autre", construireTxtTruck(personne.getString("truk_nom_autre")));
180
			tabIdentiteParams.set("abreviation_autre", construireTxtTruck(personne.getString("truk_abreviation_autre")));
181
 
977 gduche 182
			tplIdentite += construireTxtListeOntologie(personne.getString("truk_telephone"));
820 gduche 183
 
184
			// Courriel :Champ truk de la forme
185
			// "Adresse@adr.com;; adr2@adr.fr ..."
186
			LinkedList<String> listeCourriel = (LinkedList<String>) personne
187
					.getChaineDenormaliseAsMapOrList("truk_courriel");
188
			if ((listeCourriel != null) && (listeCourriel.size() > 0)) {
253 gduche 189
				String strLabelCourriel = "Courriel";
820 gduche 190
				if (listeCourriel.size() > 1) {
191
					strLabelCourriel += "s";
253 gduche 192
				}
820 gduche 193
 
253 gduche 194
				String valeurCourriel = "";
195
				Iterator<String> itCourriel = listeCourriel.iterator();
820 gduche 196
				while (itCourriel.hasNext()) {
253 gduche 197
					String valeurCourante = itCourriel.next();
820 gduche 198
					valeurCourriel += "<br /><a href=\"mailto:"
199
							+ valeurCourante + "\">" + valeurCourante + "</a>";
253 gduche 200
				}
527 gduche 201
				tplIdentite += valeurCourriel;
253 gduche 202
			}
472 gduche 203
 
260 gduche 204
			// Url Site Webs
820 gduche 205
			LinkedList listeUrl = (LinkedList) personne
206
					.getChaineDenormaliseAsMapOrList("truk_url");
207
			if (listeUrl != null && listeUrl.size() > 0) {
208
 
527 gduche 209
				tplIdentite += "<br /><br /><b>Sites web:</b><br /><span style='display:inline-block'>";
260 gduche 210
				String strUrl = "";
211
				Iterator<String> urlIt = listeUrl.iterator();
820 gduche 212
				while (urlIt.hasNext()) {
260 gduche 213
					String urlCourante = urlIt.next();
820 gduche 214
					strUrl += "<a href=\"" + urlCourante + "\">" + urlCourante
215
							+ "</a> <br/>";
260 gduche 216
				}
527 gduche 217
				tplIdentite += strUrl + "</span><br />";
820 gduche 218
			}
219
 
527 gduche 220
			tplIdentite += "</div>";
820 gduche 221
 
527 gduche 222
			afficherOnglet(tplIdentite, tabIdentiteParams, tabIdentite);
820 gduche 223
 
224
			String tabAdresseTpl = "<div class='{css_corps}'>"
225
					+ "	<div class='{css_fieldset}'>"
226
					+ "		<h2>Adresse personnelle:</h2>"
977 gduche 227
					+ "		<b>Adresse:</b> {adresse01} <br />"
228
					+ "		<b>Complément d'adresse: </b>{adresse02} <br />"
229
					+ "		<b>Boite postale: </b>{boitePostale}<br />"
230
					+ "		<b>Code postal:</b>{codePostal} <br />"
231
					+ "		<b>Région:</b>{region}<br />"
1292 cyprien 232
					+ "		<b>Pays :</b><span style='uppercase'>{pays}</span><br />"
820 gduche 233
					+ "</div>";
234
			// Adresses :
472 gduche 235
			Params paramAdresseTpl = new Params();
820 gduche 236
			paramAdresseTpl.set("adresse01", (String) personne
237
					.obtenirValeurChamp("adresse_01"));
238
			paramAdresseTpl.set("adresse02", (String) personne
239
					.obtenirValeurChamp("adresse_02"));
240
			paramAdresseTpl.set("boitePostale", (String) personne
241
					.obtenirValeurChamp("bp"));
242
			paramAdresseTpl.set("codePostal", (String) personne
243
					.obtenirValeurChamp("code_postal"));
244
			paramAdresseTpl.set("ville", (String) personne
245
					.obtenirValeurChamp("ville"));
246
			paramAdresseTpl.set("region", (String) personne
1292 cyprien 247
					.obtenirValeurChamp("ce_truk_region"));
248
			paramAdresseTpl.set("pays", construireTxtListeOntologie((String) personne
249
					.obtenirValeurChamp("ce_truk_pays")));
820 gduche 250
 
472 gduche 251
			afficherOnglet(tabAdresseTpl, paramAdresseTpl, tabAdresse);
252
			tabAdresse.setStyleAttribute("padding", "15px");
215 aurelien 253
 
472 gduche 254
			// Infos naturalistes :Biographie, Spécialité (typé)
820 gduche 255
			String tplInfosNat = "<div class='{css_corps}'>"
256
					+ "	<div class='{css_fieldset}'>" + "		<h2>"
1284 gduche 257
					+ i18nC.personneBiographie() + "</h2>"
258
					+ "			{biographie}" + "		"
259
					+ "<h2>" + i18nC.personneSpecialite() + "</h2>"
260
					+ "			{specialites}" + "	<h2>"
915 jpm 261
					+ i18nC.personneRecolte() + "</h2>"
820 gduche 262
					+ "		{recoltes}" + "  </div>" + "</div>";
527 gduche 263
			Params prmInfosNat = new Params();
820 gduche 264
 
1284 gduche 265
			prmInfosNat.set("biographie", personne.get("biographie"));
266
 
797 gduche 267
			String specialite = construireTxtTruck(personne.getSpecialite());
268
			prmInfosNat.set("specialites", specialite);
820 gduche 269
 
270
			String recolte = construireTxtListeOntologie(personne.getString("truk_recolte"));
797 gduche 271
			prmInfosNat.set("recoltes", recolte);
820 gduche 272
 
797 gduche 273
			afficherOnglet(tplInfosNat, prmInfosNat, tabInfosNat);
274
			tabAdresse.setStyleAttribute("padding", "15px");
820 gduche 275
 
305 gduche 276
			changerLabelRegions();
150 gduche 277
			layout();
820 gduche 278
		}
197 gduche 279
	}
820 gduche 280
 
281
	public String initialiserTplEntete() {
282
		return "<div id='{css_id}'>" + "<h1>{nom}</h1>"
283
				+ "<h2><a href='{mail}'>{mail}</a></h2>" + "</div>";
472 gduche 284
	}
820 gduche 285
 
527 gduche 286
	public String initialiserTplIdentite() {
820 gduche 287
		return "<div class='{css_corps}'>" + "	<div class='{css_fieldset}'>"
288
				+ "	 <h2>Noms:</h2>" + "	 <span><b>"
915 jpm 289
				+ i18nC.personneNomComplet()
820 gduche 290
				+ ":</b></span> {nom_complet}<br />"
291
				+ "	 <span><b>"
915 jpm 292
				+ i18nC.personneNomAutre()
820 gduche 293
				+ ":</b></span> {nom_autre}<br />"
294
				+ "	 <span><b>"
915 jpm 295
				+ i18nC.personneAbreviation()
820 gduche 296
				+ ":</b></span> {abreviation}<br />"
297
				+ " 	 <span><b>"
915 jpm 298
				+ i18nC.personneAbreviationAutre()
820 gduche 299
				+ ":</b></b></span> {abreviation_autre}<br /><br />"
300
				+ "	 <h2>Naissance:</h2>"
301
				+ " 	 <span><b>"
915 jpm 302
				+ i18nC.personneDateNaissance()
828 gduche 303
				+ ":</b></span> {naissance_date}<br />"
820 gduche 304
				+ " 	 <span><b>"
915 jpm 305
				+ i18nC.personneLieuNaissance()
820 gduche 306
				+ ":</b></span> {naissance_lieu}<br /><br />"
828 gduche 307
				+ "{tplDeces}"
820 gduche 308
				+ " 	</div>"
309
				+ "</div>"
310
				+ "<div class='{css_corps}'>"
311
				+ "	<div class='css_fieldset'> "
312
				+ "	<h2>Description:</h2>"
313
				+ " 		{description}<br />" + "	</div>" + "<br />";
527 gduche 314
	}
820 gduche 315
 
316
	private void changerLabelRegions() {
321 gduche 317
		Collection<String> colClesComposants = hmLabelFieldRegion.keySet();
305 gduche 318
		Iterator<String> itComposants = colClesComposants.iterator();
820 gduche 319
 
320
		while (itComposants.hasNext()) {
305 gduche 321
			String region = itComposants.next();
1322 gduche 322
			mediateur.obtenirValeurEtRafraichir(this, "region", region, sequenceur);
305 gduche 323
		}
324
	}
197 gduche 325
 
820 gduche 326
	private void ajouterLabelField(FieldSet fs, String tfLabel, Object tfValue) {
327
		if ((tfValue != null) && (!tfValue.toString().trim().equals(""))) {
328
 
246 gduche 329
			LabelField tf = new LabelField();
820 gduche 330
 
246 gduche 331
			tf.setFieldLabel(tfLabel + ":");
820 gduche 332
			if ((tfLabel == null) || ("".equals(tfLabel))) {
197 gduche 333
				tf.setHideLabel(true);
334
				tf.setStyleAttribute("margin", "0 0 0 105px");
335
			}
336
			tf.setValue(tfValue);
820 gduche 337
 
338
			// Ajout au fieldSet
200 gduche 339
			fs.add(tf);
340
		}
341
	}
342
 
1284 gduche 343
 
344
	private void initialiserTableauPublicationsLieesTpl() {
345
 
346
		tableauPublicationsLieesTpl =
347
			"<div class='{css_corps}'>" +
348
			"	<h2>{i18n_titre_publication}</h2>"+
349
			"	<table>"+
350
			"	<thead>"+
351
			"		<tr>" +
352
			"			<th>{i18n_relation}</th>" +
353
			"			<th>{i18n_auteur}</th>" +
354
			"			<th>{i18n_titre}</th>" +
355
			"			<th>{i18n_revue}</th>" +
356
			"			<th>{i18n_editeur}</th>" +
357
			"			<th>{i18n_annee}</th>" +
358
			"			<th>{i18n_nvt}</th>" +
359
			"			<th>{i18n_fascicule}</th>" +
360
			"			<th>{i18n_page}</th>" +
361
			"		</tr>"+
362
			"	</thead>"+
363
			"	<tbody>"+
364
			"		{lignes}"+
365
			"	</tbody>"+
366
			"</table>";
367
	}
368
 
369
	private void initialiserLignePublicationLieeTpl() {
370
		lignePublicationLieeTpl =
371
			"<tr>"+
372
			"	<td>{relation}</td>"+
373
			"	<td>{auteur}</td>"+
374
			"	<td>{titre}</td>"+
375
			"	<td>{revue}</td>"+
376
			"	<td>{editeur}</td>"+
377
			"	<td>{annee}</td>"+
378
			"	<td>{nvt}</td>"+
379
			"	<td>{fascicule}</td>"+
380
			"	<td>{page}</td>"+
381
			"</tr>";
382
	}
383
	/**
384
	 * @author greg
385
	 * Rempli l'onglet des publications liées
386
	 * @param listePublications la liste des publications
387
	 */
388
	private void afficherPublications(PublicationAPersonneListe listePublications)	{
389
		List<PublicationAPersonne> publicationsLiees = listePublications.toList();
390
		Iterator<PublicationAPersonne> iterateur = publicationsLiees.iterator();
391
 
392
		//Onglet Publications
393
		initialiserTableauPublicationsLieesTpl();
394
		Params paramsPublis = new Params();
395
 
396
		String contenuLignes = "";
397
		while (iterateur.hasNext())	{
398
			initialiserLignePublicationLieeTpl();
399
 
400
			PublicationAPersonne publicationAPersonneCourante = iterateur.next();
401
			Publication publication = publicationAPersonneCourante.getPublicationLiee();
402
 
403
			Params ligneParams = new Params();
404
			ligneParams.set("relation", construireTxtListeOntologie(publicationAPersonneCourante.getRole()));
405
			ligneParams.set("auteur", publication.getAuteur());
406
			ligneParams.set("titre", publication.getTitre());
407
			ligneParams.set("revue", publication.getCollection());
408
			ligneParams.set("editeur", publication.getEditeur());
409
			ligneParams.set("annee", publication.getAnneeParution());
410
			ligneParams.set("nvt", publication.getIndicationNvt());
411
			ligneParams.set("fascicule", publication.getFascicule());
412
			ligneParams.set("page", publication.getPages());
413
			contenuLignes += Format.substitute(lignePublicationLieeTpl, ligneParams);
414
		}
415
 
416
		paramsPublis.set("lignes", contenuLignes);
417
		paramsPublis.set("i18n_titre_publication", i18nC.tabPublications());
418
		paramsPublis.set("i18n_relation", i18nC.publicationAuteurs());
419
		paramsPublis.set("i18n_auteur", i18nC.publicationAuteurs());
420
		paramsPublis.set("i18n_titre", i18nC.publicationTitre());
421
		paramsPublis.set("i18n_revue", i18nC.publicationRevueCollection());
422
		paramsPublis.set("i18n_editeur", i18nC.publicationEditeur());
423
		paramsPublis.set("i18n_annee", i18nC.publicationDateParution());
424
		paramsPublis.set("i18n_nvt", i18nC.publicationNvt());
425
		paramsPublis.set("i18n_fascicule", i18nC.publicationFascicule());
426
		paramsPublis.set("i18n_page", i18nC.publicationPage());
427
		afficherOnglet(tableauPublicationsLieesTpl, paramsPublis, tabPublications);
428
 
429
	}
430
 
305 gduche 431
	public void rafraichir(Object nouvellesDonnees) {
820 gduche 432
 
1322 gduche 433
		if (nouvellesDonnees instanceof ValeurListe)	{
434
			ajouterListeValeursAOntologie((ValeurListe) nouvellesDonnees);
435
		} else if (nouvellesDonnees instanceof Personne) {
436
			afficherDetailPersonne((Personne) nouvellesDonnees);
1284 gduche 437
		} else if (nouvellesDonnees instanceof PublicationAPersonneListe)	{
438
			afficherPublications((PublicationAPersonneListe) nouvellesDonnees);
1373 cyprien 439
			layout();
305 gduche 440
		}
150 gduche 441
	}
442
 
197 gduche 443
}