Subversion Repositories eFlore/Applications.coel

Rev

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