Subversion Repositories eFlore/Applications.coel

Rev

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

Rev Author Line No. Line
150 gduche 1
package org.tela_botanica.client.vues;
2
 
189 gduche 3
 
4
 
253 gduche 5
 
6
 
7
import java.util.Collection;
197 gduche 8
import java.util.HashMap;
9
import java.util.Iterator;
253 gduche 10
import java.util.LinkedList;
11
import java.util.MissingResourceException;
189 gduche 12
 
197 gduche 13
 
150 gduche 14
import org.tela_botanica.client.RegistreId;
253 gduche 15
import org.tela_botanica.client.i18n.Constantes;
150 gduche 16
import org.tela_botanica.client.interfaces.Rafraichissable;
17
import org.tela_botanica.client.modeles.Personne;
267 gduche 18
import org.tela_botanica.client.modeles.PersonneListe;
259 gduche 19
import org.tela_botanica.client.util.UtilTruk;
150 gduche 20
 
21
import com.extjs.gxt.ui.client.Registry;
259 gduche 22
 
23
 
150 gduche 24
import com.extjs.gxt.ui.client.Style.Scroll;
253 gduche 25
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
259 gduche 26
 
215 aurelien 27
import com.extjs.gxt.ui.client.widget.ContentPanel;
189 gduche 28
import com.extjs.gxt.ui.client.widget.TabItem;
29
import com.extjs.gxt.ui.client.widget.TabPanel;
197 gduche 30
import com.extjs.gxt.ui.client.widget.form.FieldSet;
246 gduche 31
import com.extjs.gxt.ui.client.widget.form.LabelField;
150 gduche 32
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
197 gduche 33
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
34
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
253 gduche 35
import com.extjs.gxt.ui.client.widget.layout.TableData;
197 gduche 36
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
253 gduche 37
import com.google.gwt.core.client.GWT;
260 gduche 38
import com.google.gwt.user.client.Window;
197 gduche 39
import com.google.gwt.user.client.ui.Image;
150 gduche 40
 
189 gduche 41
public class PersonneDetailPanneauVue extends TabPanel implements Rafraichissable {
150 gduche 42
 
197 gduche 43
	// Le panneau détail se compose de formulaires tabulés
189 gduche 44
 
197 gduche 45
	// Onglet 1 : identite & contact
215 aurelien 46
	private TabItem tabIdentite;
47
 
48
	private ContentPanel panneauIdentite;
49
	private ContentPanel panneauImage;
50
 
197 gduche 51
	private FieldSet fsIdentite;
52
	private FieldSet fsContact;
189 gduche 53
 
200 gduche 54
	// Onglet 2 : Adresses
55
	private TabItem tabAdresse;
56
	private FieldSet fsAdressePerso;
198 gduche 57
		// contient : adresse perso / adresse pro
58
 
215 aurelien 59
	// Onglet 3 : Informations naturalistes
60
	private TabItem tabInfosNat;
267 gduche 61
	private FieldSet fsInfosNat;
198 gduche 62
 
267 gduche 63
 
150 gduche 64
	public PersonneDetailPanneauVue() {
189 gduche 65
 
198 gduche 66
		//Constructeur de la classe
150 gduche 67
		Registry.register(RegistreId.PANNEAU_PERSONNE_DETAIL, this);
189 gduche 68
		setLayout(new FitLayout());
150 gduche 69
 
215 aurelien 70
		tabIdentite = new TabItem("Identité");
71
		TableLayout tLayout = new TableLayout(2);
72
		tabIdentite.setLayout(tLayout);
73
		tabIdentite.setScrollMode(Scroll.AUTO);
189 gduche 74
 
215 aurelien 75
		panneauIdentite = new ContentPanel();
76
		panneauIdentite.setWidth("400px");
77
		panneauIdentite.setHeaderVisible(false);
78
		panneauIdentite.setBorders(false);
79
		panneauIdentite.setBodyBorder(false);
80
		panneauImage = new ContentPanel();
253 gduche 81
		panneauImage.setLayout(new FlowLayout());
215 aurelien 82
		panneauImage.setBorders(false);
253 gduche 83
		panneauImage.setWidth(350);
215 aurelien 84
		panneauImage.setBodyBorder(false);
85
		panneauImage.setHeaderVisible(false);
200 gduche 86
 
259 gduche 87
		//Gérer l'alignement vertical en haut
253 gduche 88
		TableData td = new TableData();
259 gduche 89
		td.setVerticalAlign(VerticalAlignment.TOP);
90
 
91
		tabIdentite.add(panneauIdentite, td);
253 gduche 92
		tabIdentite.add(panneauImage, td);
259 gduche 93
 
253 gduche 94
 
197 gduche 95
		fsIdentite = new FieldSet();
96
		fsIdentite.setLayout(new FormLayout());
97
 
98
 
99
		fsContact = new FieldSet();
100
		fsContact.setLayout(new FormLayout());
101
 
215 aurelien 102
		this.add(tabIdentite);
197 gduche 103
 
200 gduche 104
		//Onglet Adresse:
259 gduche 105
		tabAdresse = new TabItem("Adresses");
200 gduche 106
		fsAdressePerso = new FieldSet();
107
		fsAdressePerso.setLayout(new FormLayout());
108
 
215 aurelien 109
		this.add(tabAdresse);
200 gduche 110
 
215 aurelien 111
		//Onglet info naturalistes
112
		tabInfosNat = new TabItem("Informations naturalistes");
267 gduche 113
		fsInfosNat = new FieldSet();
114
		fsInfosNat.setLayout(new FormLayout());
200 gduche 115
 
215 aurelien 116
		this.add(tabInfosNat);
198 gduche 117
 
150 gduche 118
	}
119
 
120
	public void afficherDetailPersonne(Personne personne) {
121
		if (personne != null) {
198 gduche 122
 
123
 
124
			//MAJ Identité : Configurer les fieldSet
215 aurelien 125
			panneauIdentite.removeAll();
126
			panneauImage.removeAll();
150 gduche 127
 
197 gduche 128
			fsIdentite.setHeading("Identité");
259 gduche 129
			//fsIdentite.setWidth("350px");
183 gduche 130
 
197 gduche 131
			fsContact.setHeading("Contact");
259 gduche 132
			//fsContact.setWidth("350px");
183 gduche 133
 
215 aurelien 134
			panneauIdentite.add(fsIdentite);
135
 
259 gduche 136
 
253 gduche 137
			//La personne peut avoir un ou plusieurs logo
138
			panneauImage.setHeight("100%");
259 gduche 139
			panneauImage.setPosition(0, 6);
140
			panneauImage.setBorders(false);
198 gduche 141
 
253 gduche 142
			LinkedList<String> listeLogos = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_logo");
143
			if ((listeLogos != null)&&(listeLogos.size() > 0))	{
259 gduche 144
				panneauImage.setBorders(true);
253 gduche 145
				for (int i = 0; i < listeLogos.size(); i++)	{
146
					String logoUrl = listeLogos.get(i);
147
					if ((logoUrl!=null)&&(!logoUrl.trim().equals("")))	{
148
						//Si c'est le cas, on l'affiche sur la même ligne que fsIdentité
149
						Image img = new Image();
150
						img.setUrl(logoUrl);
151
 
152
						panneauImage.add(img);
153
						if (panneauImage.getWidth() < (img.getWidth() + 15))	{
154
							panneauImage.setWidth(img.getWidth() + 15);
155
						}
156
 
157
					}
158
				}
246 gduche 159
 
189 gduche 160
			}
150 gduche 161
 
215 aurelien 162
			panneauIdentite.add(fsContact);
183 gduche 163
 
197 gduche 164
			fsIdentite.removeAll();
165
			fsContact.removeAll();
215 aurelien 166
			fsAdressePerso.removeAll();
267 gduche 167
			fsInfosNat.removeAll();
197 gduche 168
			//Ajout des champs Identité
169
 
170
 
171
 
172
			// TODO: projet
173
 
174
			// nom complet
175
			Object nomComplet = personne.obtenirValeurChamp("fmt_nom_complet");
266 gduche 176
			ajouterLabelField(fsIdentite,"Nom Complet", nomComplet);
197 gduche 177
 
259 gduche 178
			// Nom autre : champ truk; non-typé
179
			LinkedList<String> nomsAutre = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_nom_autre");
180
			if ((nomsAutre != null)&&(nomsAutre.size() > 0))	{
181
 
182
				LabelField noms = new LabelField();
183
				noms.setFieldLabel("Autres noms:");
184
				String listeNoms = UtilTruk.traiterTrukListe(nomsAutre, ", ");
185
				noms.setValue(listeNoms);
186
				fsIdentite.add(noms);
187
			}
197 gduche 188
 
189
			// abreviation
190
			Object abreviation = personne.obtenirValeurChamp("abreviation");
266 gduche 191
			ajouterLabelField(fsIdentite, "Abreviation", abreviation);
197 gduche 192
 
259 gduche 193
			// Abréviations, autre : non-typé
194
			LinkedList<String> abrevAutres = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_abreviation_autre");
195
			if ((abrevAutres != null)&&(abrevAutres.size() > 0))	{
196
 
197
				LabelField abreviations = new LabelField();
198
				abreviations.setFieldLabel("Autres abreviations:");
199
				String listeAbrev = UtilTruk.traiterTrukListe(abrevAutres, ", ");
200
				abreviations.setValue(listeAbrev);
201
				fsIdentite.add(abreviations);
202
			}
203
			fsIdentite.addText("<hr>");
197 gduche 204
 
259 gduche 205
			// date naissance
206
			// TODO : Mettre la date en format FR 10/12/09
207
			Object dateNaissance = personne.obtenirValeurChamp("naissance_date");
266 gduche 208
			ajouterLabelField(fsIdentite, "Né le", dateNaissance);
259 gduche 209
 
197 gduche 210
			// lieu naissance
259 gduche 211
			Object lieuNaissance = personne.obtenirValeurChamp("naissance_lieu");
266 gduche 212
			ajouterLabelField(fsIdentite, "A", lieuNaissance);
197 gduche 213
 
214
			// date deces
259 gduche 215
			Object dateDeces = personne.obtenirValeurChamp("deces_date");
266 gduche 216
			ajouterLabelField(fsIdentite, "Date décès", dateDeces);
197 gduche 217
 
218
			// lieu deces
259 gduche 219
			Object lieuDeces = personne.obtenirValeurChamp("deces_lieu");
266 gduche 220
			ajouterLabelField(fsIdentite, "Lieu de décès", lieuDeces);
197 gduche 221
 
259 gduche 222
			fsIdentite.addText("<hr>");
223
 
200 gduche 224
			//Description
225
			String description = (String) personne.obtenirValeurChamp("description");
226
			if ((description!=null)&&(!description.trim().equals("")))	{
253 gduche 227
				LabelField txtDescription = new LabelField();
228
				txtDescription.setFieldLabel("Description:");
200 gduche 229
				txtDescription.setValue(description);
230
 
253 gduche 231
				//rendreNonEditable(txtDescription);
200 gduche 232
 
233
				fsIdentite.add(txtDescription);
234
			}
197 gduche 235
 
236
 
253 gduche 237
			// CONTACT
238
			// Téléphones
239
			// > Plusieurs téléphones possible, typés
240
			Constantes constantesI18n = (Constantes) GWT.create(Constantes.class);
197 gduche 241
 
253 gduche 242
			HashMap<String, String> mapTelephones = (HashMap<String, String>) personne.getChaineDenormaliseAsMapOrList("truk_telephone");
243
			if ((mapTelephones != null)&&(mapTelephones.size() > 0))	{
244
 
245
				Collection<String> telephoneKeys = mapTelephones.keySet();
246
				Iterator<String> itTelephones = telephoneKeys.iterator();
247
 
248
				while (itTelephones.hasNext())	{
249
					String key = itTelephones.next();
250
					LabelField telephoneLabel = new LabelField();
251
					String label = "";
252
					try {
253
						label = constantesI18n.getString(key);
254
					}
255
					catch (MissingResourceException e)	{
256
						label = key;
257
					}
258
 
259
					telephoneLabel.setFieldLabel( label + ":");
260
 
261
					telephoneLabel.setValue(mapTelephones.get(key));
262
 
263
					fsContact.add(telephoneLabel);
264
				}
215 aurelien 265
			}
197 gduche 266
 
253 gduche 267
			// Fax
268
			// > Plusieurs fax possible, typés
269
 
270
			HashMap<String, String> mapFax = (HashMap<String, String>) personne.getChaineDenormaliseAsMapOrList("truk_fax");
271
			if ((mapFax != null)&&(mapFax.size() > 0))	{
272
 
273
				Collection<String> faxKeys = mapFax.keySet();
274
				Iterator<String> itFax = faxKeys.iterator();
275
 
276
				while (itFax.hasNext())	{
277
					String key = itFax.next();
278
					LabelField faxLabel = new LabelField();
279
					String label = "";
280
					try {
281
						label = constantesI18n.getString(key);
282
					}
283
					catch (MissingResourceException e)	{
284
						label = key;
285
					}
286
 
287
					faxLabel.setFieldLabel( label + ":");
288
 
289
					faxLabel.setValue(mapTelephones.get(key));
290
 
291
					fsContact.add(faxLabel);
292
				}
293
			}
294
 
295
			// Courriel
296
			// Courriel est un champ truk de la forme "Adresse@adr.com;; adr2@adr.fr ..."
297
 
298
			LinkedList<String> listeCourriel = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_courriel");
299
			if ((listeCourriel!=null)&&(listeCourriel.size() > 0))	{
300
				String strLabelCourriel = "Courriel";
301
				if (listeCourriel.size() > 1)	{
302
					strLabelCourriel += "s";
303
				}
304
 
305
				LabelField labelCourriel = new LabelField();
306
				labelCourriel.setFieldLabel(strLabelCourriel);
307
 
308
				String valeurCourriel = "";
309
				Iterator<String> itCourriel = listeCourriel.iterator();
310
				while (itCourriel.hasNext())	{
311
					String valeurCourante = itCourriel.next();
312
					valeurCourriel += "<a href=\"mailto:" + valeurCourante + "\">" + valeurCourante + "</a><br />";
313
 
314
				}
315
 
316
				labelCourriel.setValue(valeurCourriel);
317
				fsContact.add(labelCourriel);
318
			}
319
 
320
 
260 gduche 321
			// Url Site Webs
322
			LinkedList listeUrl = (LinkedList) personne.getChaineDenormaliseAsMapOrList("truk_url");
323
			if (listeUrl!=null && listeUrl.size() > 0)	{
324
				String strUrl = "";
325
				Iterator<String> urlIt = listeUrl.iterator();
326
				while (urlIt.hasNext())	{
327
					String urlCourante = urlIt.next();
328
					strUrl += "<a href=\""+urlCourante+"\">" + urlCourante + "</a> <br/>";
329
 
330
 
331
				}
332
 
333
				LabelField urlLabelField = new LabelField();
334
				urlLabelField.setFieldLabel("Url:");
335
				urlLabelField.setValue(strUrl);
336
				fsContact.add(urlLabelField);
337
			}
338
 
339
 
215 aurelien 340
			panneauIdentite.add(fsContact);
197 gduche 341
 
198 gduche 342
 
215 aurelien 343
			fsAdressePerso.setHeading("Adresse personnelle");
344
 
198 gduche 345
			/*
346
			 * Adresses :
215 aurelien 347
			 * */
197 gduche 348
			String adresse01 = (String) personne.obtenirValeurChamp("adresse_01");
266 gduche 349
			ajouterLabelField(fsAdressePerso, "Adresse", adresse01);
197 gduche 350
 
351
			String adresse02 = (String) personne.obtenirValeurChamp("adresse_02");
266 gduche 352
			ajouterLabelField(fsAdressePerso, "", adresse02);
197 gduche 353
 
354
			String boitePostale = (String) personne.obtenirValeurChamp("bp");
266 gduche 355
			ajouterLabelField(fsAdressePerso, "Boite Postale", boitePostale);
197 gduche 356
 
357
			String codePostal = (String) personne.obtenirValeurChamp("code_postal");
266 gduche 358
			ajouterLabelField(fsAdressePerso, "Code postal", codePostal);
197 gduche 359
 
360
			String ville = (String) personne.obtenirValeurChamp("ville");
266 gduche 361
			ajouterLabelField(fsAdressePerso, "Ville", ville);
197 gduche 362
 
363
			String region = (String) personne.obtenirValeurChamp("region");
266 gduche 364
			ajouterLabelField(fsAdressePerso, "Région", region);
197 gduche 365
 
366
			String pays = (String) personne.obtenirValeurChamp("pays");
266 gduche 367
			ajouterLabelField(fsAdressePerso, "Pays", pays);
197 gduche 368
 
215 aurelien 369
			fsAdressePerso.addText("<br >");
370
			fsAdressePerso.setWidth("350px");
197 gduche 371
 
215 aurelien 372
			tabAdresse.add(fsAdressePerso);
267 gduche 373
			//tabAdresse.setScrollMode(Scroll.AUTO);
246 gduche 374
 
215 aurelien 375
 
260 gduche 376
			/*
377
			 *	Infos naturalistes
378
			 * */
379
 
380
			// Biographie
267 gduche 381
			// Spécialité (typé)
382
 
383
			fsInfosNat.setHeading("Infos...");
384
			tabInfosNat.add(fsInfosNat);
385
 
386
			HashMap hmSpecialite = (HashMap) personne.getChaineDenormaliseAsMapOrList("ce_truk_specialite");
387
			if ((hmSpecialite != null)&&(hmSpecialite.size() > 0))	{
388
 
389
				Collection<String> specialiteKeys = hmSpecialite.keySet();
390
				Iterator<String> itSpec = specialiteKeys.iterator();
391
 
392
				while (itSpec.hasNext())	{
393
					String key = itSpec.next();
394
					LabelField specLabel = new LabelField();
395
					String label = "";
396
					try {
397
						label = constantesI18n.getString(key);
398
					}
399
					catch (MissingResourceException e)	{
400
						label = key;
401
					}
402
 
403
					specLabel.setFieldLabel( label + ":");
404
 
405
					specLabel.setValue(hmSpecialite.get(key));
406
 
407
					fsInfosNat.add(specLabel);
408
				}
409
			}
266 gduche 410
			// Recolte
260 gduche 411
			// tabInfosNat
150 gduche 412
			layout();
197 gduche 413
		}
414
	}
415
 
266 gduche 416
	private void ajouterLabelField(FieldSet fs, String tfLabel, Object tfValue)	{
197 gduche 417
 
418
		if ((tfValue!=null)&&(!tfValue.toString().trim().equals("")))	{
189 gduche 419
 
246 gduche 420
 
421
			LabelField tf = new LabelField();
197 gduche 422
 
246 gduche 423
			tf.setFieldLabel(tfLabel + ":");
197 gduche 424
			if ((tfLabel==null)||("".equals(tfLabel)))	{
425
				tf.setHideLabel(true);
426
				tf.setStyleAttribute("margin", "0 0 0 105px");
427
			}
428
			tf.setValue(tfValue);
429
 
200 gduche 430
			//Ajout au fieldSet
431
			fs.add(tf);
432
		}
433
	}
434
 
266 gduche 435
 
197 gduche 436
 
437
 
183 gduche 438
	public void rafraichir(Object nouvelleDonnees) {
227 aurelien 439
 
440
		// Si on a reçu une personne on en affiche les détails
183 gduche 441
		if (nouvelleDonnees instanceof Personne) {
442
			afficherDetailPersonne((Personne) nouvelleDonnees);
227 aurelien 443
		}
150 gduche 444
	}
445
 
197 gduche 446
}