Subversion Repositories eFlore/Applications.coel

Rev

Rev 1513 | Rev 1784 | 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
 
1513 jpm 123
			tabLogos.removeAll();
820 gduche 124
			LinkedList lstLogos = (LinkedList) personne
125
					.getChaineDenormaliseAsMapOrList("truk_logo");
126
			if (lstLogos != null && lstLogos.size() > 0) {
127
 
1513 jpm 128
 
435 gduche 129
				String urlLogoPrinc = (String) lstLogos.get(0);
820 gduche 130
				if (!urlLogoPrinc.trim().equals("")) {
131
					tplEntete = "<div id='personne-logo-div'><img src='{image}' alt='logo' /></div>"
132
							+ tplEntete;
435 gduche 133
					enteteParams.set("image", urlLogoPrinc);
253 gduche 134
				}
820 gduche 135
 
435 gduche 136
				Iterator<String> itLogo = lstLogos.iterator();
820 gduche 137
				while (itLogo.hasNext()) {
435 gduche 138
					String urlLogoCourant = itLogo.next();
139
					Image imgCourante = new Image(urlLogoCourant);
820 gduche 140
					tabLogos.add(imgCourante);
435 gduche 141
				}
527 gduche 142
				tabLogos.enable();
820 gduche 143
 
435 gduche 144
			} else {
472 gduche 145
				enteteParams.set("image", "");
435 gduche 146
				tabLogos.disable();
472 gduche 147
			}
820 gduche 148
 
915 jpm 149
			entete.el().setInnerHtml(Format.substitute(tplEntete, enteteParams));
820 gduche 150
 
527 gduche 151
			String tplIdentite = initialiserTplIdentite();
820 gduche 152
 
435 gduche 153
			Params tabIdentiteParams = new Params();
828 gduche 154
			tabIdentiteParams.set("nom_complet", personne.getString("fmt_nom_complet"));
155
			tabIdentiteParams.set("abreviation", personne.getString("abreviation"));
1590 delphine 156
			tabIdentiteParams.set("naissance_date", personne.getAnneeOuDateNaiss().equals("") ? "" : personne.getAnneeOuDateNaiss());
828 gduche 157
			tabIdentiteParams.set("naissance_lieu", personne.getString("naissance_lieu"));
158
			String tplDeces = "";
159
			if (personne.estDecedee())	{
160
				tplDeces = " <h2>Décès:</h2>"
161
						+ " <span><b>"
915 jpm 162
						+ i18nC.personneDateDeces()
828 gduche 163
						+ ":</b></span> {deces_date}<br />"
164
						+ " 	 <span><b>"
915 jpm 165
						+ i18nC.personneLieuDeces()
828 gduche 166
						+ ":</b></span> {deces_lieu}<br /><br />";
167
 
1590 delphine 168
				tabIdentiteParams.set("deces_date", personne.getAnneeOuDateDeces().equals("") ? "" : personne.getAnneeOuDateDeces());
828 gduche 169
				tabIdentiteParams.set("deces_lieu", personne.getString("deces_lieu"));
170
			}
171
 
172
			Params paramsDeces = new Params();
173
			paramsDeces.set("tplDeces", tplDeces);
174
			tplIdentite = Format.substitute(tplIdentite, paramsDeces);
175
 
176
			tabIdentiteParams.set("description", personne.getString("description"));
820 gduche 177
 
321 gduche 178
			tabInfosNat.removeAll();
820 gduche 179
 
180
			tabIdentiteParams.set("nom_autre", construireTxtTruck(personne.getString("truk_nom_autre")));
181
			tabIdentiteParams.set("abreviation_autre", construireTxtTruck(personne.getString("truk_abreviation_autre")));
182
 
977 gduche 183
			tplIdentite += construireTxtListeOntologie(personne.getString("truk_telephone"));
820 gduche 184
 
185
			// Courriel :Champ truk de la forme
186
			// "Adresse@adr.com;; adr2@adr.fr ..."
187
			LinkedList<String> listeCourriel = (LinkedList<String>) personne
188
					.getChaineDenormaliseAsMapOrList("truk_courriel");
189
			if ((listeCourriel != null) && (listeCourriel.size() > 0)) {
253 gduche 190
				String strLabelCourriel = "Courriel";
820 gduche 191
				if (listeCourriel.size() > 1) {
192
					strLabelCourriel += "s";
253 gduche 193
				}
820 gduche 194
 
253 gduche 195
				String valeurCourriel = "";
196
				Iterator<String> itCourriel = listeCourriel.iterator();
820 gduche 197
				while (itCourriel.hasNext()) {
253 gduche 198
					String valeurCourante = itCourriel.next();
820 gduche 199
					valeurCourriel += "<br /><a href=\"mailto:"
200
							+ valeurCourante + "\">" + valeurCourante + "</a>";
253 gduche 201
				}
527 gduche 202
				tplIdentite += valeurCourriel;
253 gduche 203
			}
472 gduche 204
 
260 gduche 205
			// Url Site Webs
820 gduche 206
			LinkedList listeUrl = (LinkedList) personne
207
					.getChaineDenormaliseAsMapOrList("truk_url");
208
			if (listeUrl != null && listeUrl.size() > 0) {
209
 
527 gduche 210
				tplIdentite += "<br /><br /><b>Sites web:</b><br /><span style='display:inline-block'>";
260 gduche 211
				String strUrl = "";
212
				Iterator<String> urlIt = listeUrl.iterator();
820 gduche 213
				while (urlIt.hasNext()) {
260 gduche 214
					String urlCourante = urlIt.next();
820 gduche 215
					strUrl += "<a href=\"" + urlCourante + "\">" + urlCourante
216
							+ "</a> <br/>";
260 gduche 217
				}
527 gduche 218
				tplIdentite += strUrl + "</span><br />";
820 gduche 219
			}
220
 
527 gduche 221
			tplIdentite += "</div>";
820 gduche 222
 
527 gduche 223
			afficherOnglet(tplIdentite, tabIdentiteParams, tabIdentite);
820 gduche 224
 
225
			String tabAdresseTpl = "<div class='{css_corps}'>"
226
					+ "	<div class='{css_fieldset}'>"
227
					+ "		<h2>Adresse personnelle:</h2>"
977 gduche 228
					+ "		<b>Adresse:</b> {adresse01} <br />"
229
					+ "		<b>Complément d'adresse: </b>{adresse02} <br />"
230
					+ "		<b>Boite postale: </b>{boitePostale}<br />"
231
					+ "		<b>Code postal:</b>{codePostal} <br />"
232
					+ "		<b>Région:</b>{region}<br />"
1292 cyprien 233
					+ "		<b>Pays :</b><span style='uppercase'>{pays}</span><br />"
820 gduche 234
					+ "</div>";
235
			// Adresses :
472 gduche 236
			Params paramAdresseTpl = new Params();
820 gduche 237
			paramAdresseTpl.set("adresse01", (String) personne
238
					.obtenirValeurChamp("adresse_01"));
239
			paramAdresseTpl.set("adresse02", (String) personne
240
					.obtenirValeurChamp("adresse_02"));
241
			paramAdresseTpl.set("boitePostale", (String) personne
242
					.obtenirValeurChamp("bp"));
243
			paramAdresseTpl.set("codePostal", (String) personne
244
					.obtenirValeurChamp("code_postal"));
245
			paramAdresseTpl.set("ville", (String) personne
246
					.obtenirValeurChamp("ville"));
247
			paramAdresseTpl.set("region", (String) personne
1292 cyprien 248
					.obtenirValeurChamp("ce_truk_region"));
249
			paramAdresseTpl.set("pays", construireTxtListeOntologie((String) personne
250
					.obtenirValeurChamp("ce_truk_pays")));
820 gduche 251
 
472 gduche 252
			afficherOnglet(tabAdresseTpl, paramAdresseTpl, tabAdresse);
253
			tabAdresse.setStyleAttribute("padding", "15px");
215 aurelien 254
 
472 gduche 255
			// Infos naturalistes :Biographie, Spécialité (typé)
820 gduche 256
			String tplInfosNat = "<div class='{css_corps}'>"
257
					+ "	<div class='{css_fieldset}'>" + "		<h2>"
1284 gduche 258
					+ i18nC.personneBiographie() + "</h2>"
259
					+ "			{biographie}" + "		"
260
					+ "<h2>" + i18nC.personneSpecialite() + "</h2>"
261
					+ "			{specialites}" + "	<h2>"
915 jpm 262
					+ i18nC.personneRecolte() + "</h2>"
820 gduche 263
					+ "		{recoltes}" + "  </div>" + "</div>";
527 gduche 264
			Params prmInfosNat = new Params();
820 gduche 265
 
1284 gduche 266
			prmInfosNat.set("biographie", personne.get("biographie"));
267
 
797 gduche 268
			String specialite = construireTxtTruck(personne.getSpecialite());
269
			prmInfosNat.set("specialites", specialite);
820 gduche 270
 
271
			String recolte = construireTxtListeOntologie(personne.getString("truk_recolte"));
797 gduche 272
			prmInfosNat.set("recoltes", recolte);
820 gduche 273
 
797 gduche 274
			afficherOnglet(tplInfosNat, prmInfosNat, tabInfosNat);
275
			tabAdresse.setStyleAttribute("padding", "15px");
820 gduche 276
 
305 gduche 277
			changerLabelRegions();
150 gduche 278
			layout();
820 gduche 279
		}
197 gduche 280
	}
820 gduche 281
 
282
	public String initialiserTplEntete() {
283
		return "<div id='{css_id}'>" + "<h1>{nom}</h1>"
284
				+ "<h2><a href='{mail}'>{mail}</a></h2>" + "</div>";
472 gduche 285
	}
820 gduche 286
 
527 gduche 287
	public String initialiserTplIdentite() {
820 gduche 288
		return "<div class='{css_corps}'>" + "	<div class='{css_fieldset}'>"
289
				+ "	 <h2>Noms:</h2>" + "	 <span><b>"
915 jpm 290
				+ i18nC.personneNomComplet()
820 gduche 291
				+ ":</b></span> {nom_complet}<br />"
292
				+ "	 <span><b>"
915 jpm 293
				+ i18nC.personneNomAutre()
820 gduche 294
				+ ":</b></span> {nom_autre}<br />"
295
				+ "	 <span><b>"
915 jpm 296
				+ i18nC.personneAbreviation()
820 gduche 297
				+ ":</b></span> {abreviation}<br />"
298
				+ " 	 <span><b>"
915 jpm 299
				+ i18nC.personneAbreviationAutre()
820 gduche 300
				+ ":</b></b></span> {abreviation_autre}<br /><br />"
301
				+ "	 <h2>Naissance:</h2>"
302
				+ " 	 <span><b>"
915 jpm 303
				+ i18nC.personneDateNaissance()
828 gduche 304
				+ ":</b></span> {naissance_date}<br />"
820 gduche 305
				+ " 	 <span><b>"
915 jpm 306
				+ i18nC.personneLieuNaissance()
820 gduche 307
				+ ":</b></span> {naissance_lieu}<br /><br />"
828 gduche 308
				+ "{tplDeces}"
820 gduche 309
				+ " 	</div>"
310
				+ "</div>"
311
				+ "<div class='{css_corps}'>"
312
				+ "	<div class='css_fieldset'> "
313
				+ "	<h2>Description:</h2>"
314
				+ " 		{description}<br />" + "	</div>" + "<br />";
527 gduche 315
	}
820 gduche 316
 
317
	private void changerLabelRegions() {
321 gduche 318
		Collection<String> colClesComposants = hmLabelFieldRegion.keySet();
305 gduche 319
		Iterator<String> itComposants = colClesComposants.iterator();
820 gduche 320
 
321
		while (itComposants.hasNext()) {
305 gduche 322
			String region = itComposants.next();
1322 gduche 323
			mediateur.obtenirValeurEtRafraichir(this, "region", region, sequenceur);
305 gduche 324
		}
325
	}
197 gduche 326
 
820 gduche 327
	private void ajouterLabelField(FieldSet fs, String tfLabel, Object tfValue) {
328
		if ((tfValue != null) && (!tfValue.toString().trim().equals(""))) {
329
 
246 gduche 330
			LabelField tf = new LabelField();
820 gduche 331
 
246 gduche 332
			tf.setFieldLabel(tfLabel + ":");
820 gduche 333
			if ((tfLabel == null) || ("".equals(tfLabel))) {
197 gduche 334
				tf.setHideLabel(true);
335
				tf.setStyleAttribute("margin", "0 0 0 105px");
336
			}
337
			tf.setValue(tfValue);
820 gduche 338
 
339
			// Ajout au fieldSet
200 gduche 340
			fs.add(tf);
341
		}
342
	}
343
 
1284 gduche 344
 
345
	private void initialiserTableauPublicationsLieesTpl() {
346
 
347
		tableauPublicationsLieesTpl =
348
			"<div class='{css_corps}'>" +
349
			"	<h2>{i18n_titre_publication}</h2>"+
350
			"	<table>"+
351
			"	<thead>"+
352
			"		<tr>" +
353
			"			<th>{i18n_relation}</th>" +
354
			"			<th>{i18n_auteur}</th>" +
355
			"			<th>{i18n_titre}</th>" +
356
			"			<th>{i18n_revue}</th>" +
357
			"			<th>{i18n_editeur}</th>" +
358
			"			<th>{i18n_annee}</th>" +
359
			"			<th>{i18n_nvt}</th>" +
360
			"			<th>{i18n_fascicule}</th>" +
361
			"			<th>{i18n_page}</th>" +
362
			"		</tr>"+
363
			"	</thead>"+
364
			"	<tbody>"+
365
			"		{lignes}"+
366
			"	</tbody>"+
367
			"</table>";
368
	}
369
 
370
	private void initialiserLignePublicationLieeTpl() {
371
		lignePublicationLieeTpl =
372
			"<tr>"+
373
			"	<td>{relation}</td>"+
374
			"	<td>{auteur}</td>"+
375
			"	<td>{titre}</td>"+
376
			"	<td>{revue}</td>"+
377
			"	<td>{editeur}</td>"+
378
			"	<td>{annee}</td>"+
379
			"	<td>{nvt}</td>"+
380
			"	<td>{fascicule}</td>"+
381
			"	<td>{page}</td>"+
382
			"</tr>";
383
	}
384
	/**
385
	 * @author greg
386
	 * Rempli l'onglet des publications liées
387
	 * @param listePublications la liste des publications
388
	 */
389
	private void afficherPublications(PublicationAPersonneListe listePublications)	{
390
		List<PublicationAPersonne> publicationsLiees = listePublications.toList();
391
		Iterator<PublicationAPersonne> iterateur = publicationsLiees.iterator();
392
 
393
		//Onglet Publications
394
		initialiserTableauPublicationsLieesTpl();
395
		Params paramsPublis = new Params();
396
 
397
		String contenuLignes = "";
398
		while (iterateur.hasNext())	{
399
			initialiserLignePublicationLieeTpl();
400
 
401
			PublicationAPersonne publicationAPersonneCourante = iterateur.next();
402
			Publication publication = publicationAPersonneCourante.getPublicationLiee();
403
 
404
			Params ligneParams = new Params();
405
			ligneParams.set("relation", construireTxtListeOntologie(publicationAPersonneCourante.getRole()));
406
			ligneParams.set("auteur", publication.getAuteur());
407
			ligneParams.set("titre", publication.getTitre());
408
			ligneParams.set("revue", publication.getCollection());
409
			ligneParams.set("editeur", publication.getEditeur());
410
			ligneParams.set("annee", publication.getAnneeParution());
411
			ligneParams.set("nvt", publication.getIndicationNvt());
412
			ligneParams.set("fascicule", publication.getFascicule());
413
			ligneParams.set("page", publication.getPages());
414
			contenuLignes += Format.substitute(lignePublicationLieeTpl, ligneParams);
415
		}
416
 
417
		paramsPublis.set("lignes", contenuLignes);
418
		paramsPublis.set("i18n_titre_publication", i18nC.tabPublications());
419
		paramsPublis.set("i18n_relation", i18nC.publicationAuteurs());
420
		paramsPublis.set("i18n_auteur", i18nC.publicationAuteurs());
421
		paramsPublis.set("i18n_titre", i18nC.publicationTitre());
422
		paramsPublis.set("i18n_revue", i18nC.publicationRevueCollection());
423
		paramsPublis.set("i18n_editeur", i18nC.publicationEditeur());
424
		paramsPublis.set("i18n_annee", i18nC.publicationDateParution());
425
		paramsPublis.set("i18n_nvt", i18nC.publicationNvt());
426
		paramsPublis.set("i18n_fascicule", i18nC.publicationFascicule());
427
		paramsPublis.set("i18n_page", i18nC.publicationPage());
428
		afficherOnglet(tableauPublicationsLieesTpl, paramsPublis, tabPublications);
429
 
430
	}
431
 
305 gduche 432
	public void rafraichir(Object nouvellesDonnees) {
820 gduche 433
 
1322 gduche 434
		if (nouvellesDonnees instanceof ValeurListe)	{
435
			ajouterListeValeursAOntologie((ValeurListe) nouvellesDonnees);
436
		} else if (nouvellesDonnees instanceof Personne) {
437
			afficherDetailPersonne((Personne) nouvellesDonnees);
1284 gduche 438
		} else if (nouvellesDonnees instanceof PublicationAPersonneListe)	{
439
			afficherPublications((PublicationAPersonneListe) nouvellesDonnees);
1373 cyprien 440
			layout();
305 gduche 441
		}
150 gduche 442
	}
443
 
197 gduche 444
}