Subversion Repositories eFlore/Applications.coel

Rev

Rev 1844 | Rev 1846 | 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;
127 gduche 2
 
283 gduche 3
import java.util.ArrayList;
352 gduche 4
import java.util.Collection;
376 gduche 5
import java.util.Date;
276 gduche 6
import java.util.HashMap;
283 gduche 7
import java.util.Iterator;
352 gduche 8
import java.util.LinkedList;
283 gduche 9
import java.util.List;
276 gduche 10
 
11
import org.tela_botanica.client.ComposantClass;
12
import org.tela_botanica.client.Mediateur;
13
import org.tela_botanica.client.RegistreId;
692 gduche 14
import org.tela_botanica.client.composants.ChampMultiValeurs;
701 gduche 15
import org.tela_botanica.client.composants.ChampMultiValeursImage;
722 gduche 16
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes;
1292 cyprien 17
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypesPaginable;
973 gduche 18
import org.tela_botanica.client.composants.HashMapComposants;
907 jpm 19
import org.tela_botanica.client.configuration.Configuration;
991 gduche 20
import org.tela_botanica.client.images.Images;
127 gduche 21
import org.tela_botanica.client.interfaces.Rafraichissable;
293 gduche 22
 
352 gduche 23
import org.tela_botanica.client.modeles.Information;
850 gduche 24
import org.tela_botanica.client.modeles.MenuApplicationId;
280 gduche 25
import org.tela_botanica.client.modeles.Valeur;
283 gduche 26
import org.tela_botanica.client.modeles.ValeurListe;
935 jpm 27
import org.tela_botanica.client.modeles.personne.Personne;
1845 aurelien 28
import org.tela_botanica.client.modeles.personne.PersonneAsyncDao;
935 jpm 29
import org.tela_botanica.client.modeles.personne.PersonneListe;
991 gduche 30
import org.tela_botanica.client.modeles.publication.Publication;
31
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
32
import org.tela_botanica.client.modeles.publication.PublicationListe;
1322 gduche 33
import org.tela_botanica.client.synchronisation.Sequenceur;
1468 jpm 34
import org.tela_botanica.client.util.Debug;
729 jp_milcent 35
import org.tela_botanica.client.util.Pattern;
1845 aurelien 36
import org.tela_botanica.client.util.UtilDate;
622 gduche 37
import org.tela_botanica.client.util.UtilString;
935 jpm 38
import org.tela_botanica.client.vues.Formulaire;
127 gduche 39
 
1292 cyprien 40
import com.extjs.gxt.ui.client.data.ModelData;
41
import com.extjs.gxt.ui.client.data.ModelType;
42
import com.extjs.gxt.ui.client.data.PagingLoadResult;
488 gduche 43
import com.extjs.gxt.ui.client.event.Events;
276 gduche 44
import com.extjs.gxt.ui.client.Registry;
283 gduche 45
import com.extjs.gxt.ui.client.Style.Scroll;
1292 cyprien 46
import com.extjs.gxt.ui.client.Style.SortDir;
821 gduche 47
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
386 gduche 48
 
1186 gduche 49
import com.extjs.gxt.ui.client.binding.FieldBinding;
376 gduche 50
import com.extjs.gxt.ui.client.binding.FormBinding;
386 gduche 51
 
1845 aurelien 52
import com.extjs.gxt.ui.client.event.BaseEvent;
488 gduche 53
import com.extjs.gxt.ui.client.event.ButtonEvent;
276 gduche 54
import com.extjs.gxt.ui.client.event.ComponentEvent;
55
import com.extjs.gxt.ui.client.event.KeyListener;
446 gduche 56
import com.extjs.gxt.ui.client.event.Listener;
280 gduche 57
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
58
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
276 gduche 59
import com.extjs.gxt.ui.client.event.SelectionListener;
280 gduche 60
import com.extjs.gxt.ui.client.store.ListStore;
127 gduche 61
import com.extjs.gxt.ui.client.widget.LayoutContainer;
319 gduche 62
import com.extjs.gxt.ui.client.widget.MessageBox;
338 gduche 63
 
991 gduche 64
import com.extjs.gxt.ui.client.widget.ContentPanel;
1239 cyprien 65
import org.tela_botanica.client.composants.InfoLogger;
1292 cyprien 66
import org.tela_botanica.client.composants.pagination.Proxy;
67
import org.tela_botanica.client.composants.pagination.ProxyValeur;
68
 
276 gduche 69
import com.extjs.gxt.ui.client.widget.TabItem;
70
import com.extjs.gxt.ui.client.widget.TabPanel;
973 gduche 71
import com.extjs.gxt.ui.client.widget.Text;
283 gduche 72
 
356 gduche 73
import com.extjs.gxt.ui.client.widget.button.Button;
74
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
280 gduche 75
import com.extjs.gxt.ui.client.widget.form.ComboBox;
76
import com.extjs.gxt.ui.client.widget.form.DateField;
1329 cyprien 77
import com.extjs.gxt.ui.client.widget.form.Field;
276 gduche 78
import com.extjs.gxt.ui.client.widget.form.FieldSet;
79
import com.extjs.gxt.ui.client.widget.form.LabelField;
446 gduche 80
import com.extjs.gxt.ui.client.widget.form.Radio;
81
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
286 gduche 82
import com.extjs.gxt.ui.client.widget.form.TextArea;
276 gduche 83
import com.extjs.gxt.ui.client.widget.form.TextField;
1329 cyprien 84
import com.extjs.gxt.ui.client.widget.form.Validator;
456 gduche 85
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
850 gduche 86
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
276 gduche 87
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
88
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
991 gduche 89
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
319 gduche 90
import com.extjs.gxt.ui.client.widget.layout.FormData;
276 gduche 91
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
356 gduche 92
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
821 gduche 93
import com.extjs.gxt.ui.client.widget.layout.TableData;
94
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
991 gduche 95
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
96
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
1845 aurelien 97
import com.google.gwt.core.client.Callback;
386 gduche 98
import com.google.gwt.core.client.GWT;
1845 aurelien 99
import com.google.gwt.json.client.JSONArray;
100
import com.google.gwt.json.client.JSONObject;
991 gduche 101
import com.google.gwt.user.client.Window;
127 gduche 102
 
850 gduche 103
public class PersonneForm extends Formulaire implements Rafraichissable {
127 gduche 104
 
730 jp_milcent 105
	// VARIABLES
276 gduche 106
	private TabItem tiIdentite, tiAdresses, tiInfosNat;
991 gduche 107
	PersonneFormPublication tiPubli;
283 gduche 108
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
991 gduche 109
	protected Personne personneSelectionnee, personneSauvegarde = null;
276 gduche 110
 
657 gduche 111
	//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
973 gduche 112
	private HashMapComposants hmIdentite = new HashMapComposants();
976 gduche 113
	private HashMapComposants hmAdresse = new HashMapComposants();
979 gduche 114
	private HashMapComposants hmInfosNat = new HashMapComposants();
730 jp_milcent 115
	private HashMap<String, Valeur> hmCbSelectionnee = new HashMap();
829 gduche 116
	private FormData fd100 = new FormData("95%");
657 gduche 117
 
668 gduche 118
	private Button enregistrer, enregistrerEtRevenir;
119
 
875 jpm 120
	private Personne personne = null;
121
	private String personneId = null;
376 gduche 122
	private FormBinding binding = null;
123
 
1322 gduche 124
	//Gestion du mode synchrone
125
	private Sequenceur sequenceur;
126
 
991 gduche 127
	//Publi
128
	private ComboBox<Publication> cbPubli;
129
	private ListStore<Publication> storePubli;
130
 
1845 aurelien 131
	// Gestion de la vérification des doublons
132
	private boolean verificationDoublonEffectuee = false;
133
 
991 gduche 134
	// CONSTRUCTEUR
915 jpm 135
	public PersonneForm(Mediateur mediateurCourrant, String personneId) {
875 jpm 136
		initialiserPersonneForm(mediateurCourrant, personneId);
137
	}
446 gduche 138
 
875 jpm 139
	public PersonneForm(Mediateur mediateurCourrant, String personneId, Rafraichissable vueARafraichirApresValidation) {
140
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
1014 gduche 141
		initialiserPersonneForm(mediateurCourrant, personneId);
875 jpm 142
	}
850 gduche 143
 
875 jpm 144
	private void initialiserPersonneForm(Mediateur mediateurCourrant, String personneIdCourrant) {
1014 gduche 145
 
1322 gduche 146
		//Initialisation du séquenceur
147
		sequenceur = new Sequenceur();
875 jpm 148
		personne = new Personne();
149
		personne.setId(personneIdCourrant);
150
		personneId = personneIdCourrant;
850 gduche 151
 
884 jpm 152
		String modeDeCreation = (UtilString.isEmpty(personneId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
875 jpm 153
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PERSONNE);
154
 
386 gduche 155
		initialiserComposants();
875 jpm 156
		genererTitreFormulaire();
850 gduche 157
 
1369 cyprien 158
		mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", sequenceur);
1367 cyprien 159
		mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", null);
875 jpm 160
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
1764 aurelien 161
			mediateur.selectionnerPersonne(this, personne.getId(), sequenceur);
850 gduche 162
		}
352 gduche 163
	}
164
 
875 jpm 165
	private void genererTitreFormulaire() {
166
		String titre = i18nC.personneModeAjout();
167
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
168
			 titre = i18nC.personneModeModifier()+" - "+i18nC.id()+": "+personneId;
169
		}
1680 raphael 170
		panneauFormulaire.setHeadingHtml(titre);
875 jpm 171
	}
172
 
386 gduche 173
	public void initialiserComposants()	{
376 gduche 174
		personneSelectionnee = new Personne();
175
		personneSauvegarde = new Personne();
176
 
276 gduche 177
		initialiserOnglets();
178
 
179
		creerComposantsIdentite();
293 gduche 180
		creerComposantsAdresse();
821 gduche 181
		creerComposantsInfosNat();
991 gduche 182
		//creerComposantsPubli();
338 gduche 183
 
376 gduche 184
		binderPersonne(personneSelectionnee);
276 gduche 185
	}
186
 
187
	/**
188
	 * Crée les onglets identité, adresse et informations naturaliste
189
	 *
190
	 * */
191
	public void initialiserOnglets()	{
192
		//TabPanel
193
		TabPanel formulaireOnglets = new TabPanel();
194
 
195
		//Tab 1 : identite
991 gduche 196
		tiIdentite = creerOnglet(i18nC.personneIdentite(), "tiIdentite");
197
		tiIdentite.setStyleAttribute("padding", "0");
276 gduche 198
		formulaireOnglets.add(tiIdentite);
199
 
200
		//Tab 2 : Adresse
991 gduche 201
		tiAdresses = creerOnglet(i18nC.adresse(), "tiAdresses");
276 gduche 202
		formulaireOnglets.add(tiAdresses);
203
 
204
		//Tab 3 : Infos Naturalistes
991 gduche 205
		tiInfosNat = creerOnglet(i18nC.personneInfoNat(), "tiInfosNat");
206
		formulaireOnglets.add(tiInfosNat);
446 gduche 207
 
1239 cyprien 208
		//Tab 4 : Publications
991 gduche 209
		tiPubli = new PersonneFormPublication(this);
210
		formulaireOnglets.add(tiPubli);
211
 
850 gduche 212
		getFormulaire().add(formulaireOnglets);
276 gduche 213
	}
214
 
215
	/**
216
	 * Crée les widgets pour l'onglet identité
217
	 *
218
	 * */
219
 
220
 
221
	public void creerComposantsIdentite()	{
676 gduche 222
		// Gestion de l'affichage en colonnes : 3 Layout container : principal, gauche & droite
223
		LayoutContainer left = new LayoutContainer();
224
		left.setLayout(new FormLayout());
829 gduche 225
		left.setStyleAttribute("padding", "15px");
226
 
676 gduche 227
		LayoutContainer right = new LayoutContainer();
228
		right.setLayout(new FormLayout());
829 gduche 229
		right.setStyleAttribute("padding", "15px");
456 gduche 230
 
676 gduche 231
		LayoutContainer main = new LayoutContainer();
232
 
233
		main.add(left, new ColumnData(.45));
1844 aurelien 234
		main.add(right, new ColumnData(.50));
676 gduche 235
 
236
		main.setLayout(new ColumnLayout());
237
		main.setHeight("100%");
238
		main.setScrollMode(Scroll.AUTO);
239
 
240
		// Création des champs
241
		FormLayout formLayout = new FormLayout();
242
		formLayout.setLabelAlign(LabelAlign.LEFT);
1086 jpm 243
 
244
		//+------------------------------------------------------------------------------------------------------------+
245
		// Fieldset NOM
676 gduche 246
		FieldSet fsNoms = new FieldSet();
1680 raphael 247
		fsNoms.setHeadingHtml("Noms");
676 gduche 248
		fsNoms.setLayout(formLayout);
456 gduche 249
 
676 gduche 250
		// Nom complet : Affiché que si valeurs saisies
251
		LabelField nomComplet = new LabelField();
875 jpm 252
		nomComplet.setFieldLabel(i18nC.personneNomComplet() +" :");
676 gduche 253
		nomComplet.hide();
456 gduche 254
 
676 gduche 255
		fsNoms.add(nomComplet);
256
		hmIdentite.put("nomComplet", nomComplet);
276 gduche 257
 
676 gduche 258
		//Préfixe
259
		ListStore<Valeur> storePrefixe = new ListStore<Valeur>();
260
		ComboBox<Valeur> cbPrefixe = new ComboBox<Valeur>();
261
		cbPrefixe.setStore(storePrefixe);
262
		cbPrefixe.setDisplayField("nom");
263
		cbPrefixe.setEmptyText("Choisissez le préfixe:");
264
		cbPrefixe.setFieldLabel("Prefix");
265
 
266
		fsNoms.add(cbPrefixe);
267
		hmIdentite.put("cbPrefixe", cbPrefixe);
268
 
1369 cyprien 269
		mediateur.obtenirListeValeurEtRafraichir(this, "prefixe", sequenceur);
676 gduche 270
 
271
		//Prénom
272
		TextField<String> tfPrenom = new TextField<String>();
273
		tfPrenom.setFieldLabel("Prénom");
274
		tfPrenom.setName("prenom");
275
 
1086 jpm 276
		fsNoms.add(tfPrenom, new FormData(300, 0));
676 gduche 277
		hmIdentite.put("tfPrenom", tfPrenom);
1845 aurelien 278
 
279
		tfPrenom.addListener(Events.Blur, creerEcouteurNomPrenomExistant());
280
		tfPrenom.addListener(Events.Change, new Listener<BaseEvent>() {
281
			@Override
282
			public void handleEvent(BaseEvent be) {
283
				verificationDoublonEffectuee = false;
284
			}
285
		});
676 gduche 286
 
287
		//Nom
288
		TextField<String> tfNom = new TextField<String>();
289
		tfNom.setFieldLabel("Nom");
290
		tfNom.setAllowBlank(false);
291
		tfNom.setName("nom");
981 jpm 292
		tfNom.addStyleName(ComposantClass.OBLIGATOIRE);
293
		tfNom.addListener(Events.Valid, creerEcouteurChampObligatoire());
676 gduche 294
 
1845 aurelien 295
		tfNom.addListener(Events.Blur, creerEcouteurNomPrenomExistant());
296
		tfNom.addListener(Events.Change, new Listener<BaseEvent>() {
297
			@Override
298
			public void handleEvent(BaseEvent be) {
299
				verificationDoublonEffectuee = false;
300
			}
301
		});
302
 
1086 jpm 303
		fsNoms.add(tfNom, new FormData(300, 0));
676 gduche 304
		hmIdentite.put("tfNom", tfNom);
305
 
306
		//Suffixe
307
		ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();
308
		ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();
309
		cbSuffixe.setStore(storeSuffixe);
310
		cbSuffixe.setFieldLabel("Suffixe");
311
		cbSuffixe.setDisplayField("nom");
312
		cbSuffixe.setEmptyText("Choisissez un suffixe:");
313
 
314
		fsNoms.add(cbSuffixe);
315
		hmIdentite.put("cbSuffixe", cbSuffixe);
316
 
1369 cyprien 317
		mediateur.obtenirListeValeurEtRafraichir(this, "suffixes", sequenceur);
676 gduche 318
 
319
		TextField<String> tfAbreviation = new TextField<String>();
320
		tfAbreviation.setFieldLabel("Abréviation");
321
		tfAbreviation.setName("abreviation");
322
 
323
		fsNoms.add(tfAbreviation);
324
		hmIdentite.put("tfAbreviation", tfAbreviation);
325
 
821 gduche 326
		TableLayout layoutAutreNoms = new TableLayout(2);
327
		layoutAutreNoms.setCellVerticalAlign(VerticalAlignment.TOP);
328
		LayoutContainer autresNoms = new LayoutContainer(layoutAutreNoms);
329
		ChampMultiValeurs nomAutre = new ChampMultiValeurs("Autres noms",150);
330
		hmIdentite.put("nomAutre", nomAutre);
331
		autresNoms.add(nomAutre, new TableData("200px", "15px"));
676 gduche 332
 
821 gduche 333
		ChampMultiValeurs abreviationAutre = new ChampMultiValeurs("Autres abréviation",150);
334
		hmIdentite.put("abreviationAutre", abreviationAutre);
335
		autresNoms.add(abreviationAutre, new TableData("200px", "15px"));
336
		fsNoms.add(autresNoms);
376 gduche 337
 
676 gduche 338
		left.add(fsNoms);
339
 
1086 jpm 340
		//+------------------------------------------------------------------------------------------------------------+
341
		// Fieldset NAISSANCE ET DÉCÈS
973 gduche 342
		FieldSet fsNaissanceEtDeces = new FieldSet();
1680 raphael 343
		fsNaissanceEtDeces.setHeadingHtml("Naissance et Décès");
973 gduche 344
		fsNaissanceEtDeces.setLayout(new ColumnLayout());
345
 
676 gduche 346
		formLayout = new FormLayout();
973 gduche 347
		formLayout.setLabelAlign(LabelAlign.TOP);
348
		LayoutContainer containerNaissance = new LayoutContainer(formLayout);
349
 
1284 gduche 350
		//Remplacement du DateField par un champ texte
351
		TextField tfDateNaissance = new TextField();
352
		tfDateNaissance.setFieldLabel("Date de naissance");
353
		containerNaissance.add(tfDateNaissance);
354
		hmIdentite.put("tfDateNaissance", tfDateNaissance);
676 gduche 355
 
356
		// Lieu naissance
730 jp_milcent 357
		TextField<String> tfLieuNaissance = new TextField<String>();
973 gduche 358
		tfLieuNaissance.setFieldLabel("Lieu de naissance");
676 gduche 359
		tfLieuNaissance.setName("naissance_lieu");
360
 
973 gduche 361
		containerNaissance.add(tfLieuNaissance);
676 gduche 362
		hmIdentite.put("tfLieuNaissance", tfLieuNaissance);
363
 
973 gduche 364
		fsNaissanceEtDeces.add(containerNaissance, new ColumnData(.5));
365
		left.add(fsNaissanceEtDeces);
366
 
676 gduche 367
		formLayout = new FormLayout();
973 gduche 368
		formLayout.setLabelAlign(LabelAlign.TOP);
369
		LayoutContainer containerDeces = new LayoutContainer(formLayout);
676 gduche 370
 
371
		Radio rbEstDecedee = new Radio();
973 gduche 372
		rbEstDecedee.setId("ce_deces");
373
 
676 gduche 374
		rbEstDecedee.setBoxLabel("oui");
829 gduche 375
		rbEstDecedee.setValueAttribute("1");
973 gduche 376
		rbEstDecedee.setId("rbEstD");
377
 
676 gduche 378
		rbEstDecedee.addListener(Events.Change, new Listener<ComponentEvent>() {
446 gduche 379
 
676 gduche 380
			public void handleEvent(ComponentEvent be) {
381
				if(((Radio) be.getComponent()).getValue().equals(true))	{
1284 gduche 382
					hmIdentite.getTextField("tfDateDeces").setVisible(true);
973 gduche 383
					hmIdentite.getTextField("tfLieuDeces").setVisible(true);
676 gduche 384
				} else	{
1284 gduche 385
					TextField tfDateDeces = hmIdentite.getTextField("tfDateDeces");
386
					tfDateDeces.setValue(null);
387
					tfDateDeces.setVisible(false);
829 gduche 388
 
973 gduche 389
					TextField tfLieuDeces = hmIdentite.getTextField("tfLieuDeces");
829 gduche 390
					tfLieuDeces.setValue(null);
391
					tfLieuDeces.setVisible(false);
676 gduche 392
				}
393
			}
394
		});
446 gduche 395
 
1284 gduche 396
		TextField tfDateDeces = new TextField();
397
		tfDateDeces.setFieldLabel("Date de décès");
398
		tfDateDeces.setVisible(false);
676 gduche 399
 
1284 gduche 400
		containerDeces.add(tfDateDeces);
401
		hmIdentite.put("tfDateDeces", tfDateDeces);
676 gduche 402
 
730 jp_milcent 403
		TextField<String> tfLieuDeces = new TextField<String>();
973 gduche 404
		tfLieuDeces.setFieldLabel("Lieu de décès");
676 gduche 405
		tfLieuDeces.setName("deces_lieu");
406
		tfLieuDeces.setVisible(false);
407
 
973 gduche 408
		containerDeces.add(tfLieuDeces);
676 gduche 409
		hmIdentite.put("tfLieuDeces", tfLieuDeces);
973 gduche 410
		hmIdentite.put("rbEstDecedee", rbEstDecedee);
411
 
412
		Radio rbNestPasDecedee = new Radio();
413
		rbNestPasDecedee.setValueAttribute("0");
414
		rbNestPasDecedee.setBoxLabel("non");
415
		rbNestPasDecedee.setValue(true);
276 gduche 416
 
973 gduche 417
		RadioGroup rbgDeces = new RadioGroup();
1186 gduche 418
		rbgDeces.setId("rbgDeces");
419
 
973 gduche 420
		rbgDeces.setFieldLabel("Est décédée");
421
		rbgDeces.add(rbEstDecedee);
422
		rbgDeces.add(rbNestPasDecedee);
1186 gduche 423
		hmIdentite.put("rbgDeces", rbgDeces);
973 gduche 424
 
425
		containerDeces.add(rbgDeces);
426
 
427
		fsNaissanceEtDeces.add(containerDeces, new ColumnData(.5));
676 gduche 428
		tiIdentite.add(main);
1086 jpm 429
 
430
		//+------------------------------------------------------------------------------------------------------------+
431
		// Fieldset CONTACT
973 gduche 432
		FieldSet fsContact = new FieldSet();
1680 raphael 433
		fsContact.setHeadingHtml("Contact");
973 gduche 434
		fsContact.setLayout(new RowLayout());
676 gduche 435
 
973 gduche 436
		ChampMultiValeursMultiTypes telephones = new ChampMultiValeursMultiTypes("Téléphones", 180, 100);
1086 jpm 437
		telephones.initialiserType("tel");
438
		fsContact.add(telephones, new FormData(450, 0));
722 gduche 439
		hmIdentite.put("telephones", telephones);
676 gduche 440
 
973 gduche 441
		ChampMultiValeurs courriels = new ChampMultiValeurs("Courriels", 280);
442
		courriels.setValidation(Pattern.email, "moi@domaine.fr");
1086 jpm 443
		fsContact.add(courriels, new FormData(450, 0));
692 gduche 444
		hmIdentite.put("courriels", courriels);
676 gduche 445
 
446
		LayoutContainer lcCourrielContainer = new LayoutContainer(new RowLayout());
447
		fsContact.add(lcCourrielContainer);
448
		hmIdentite.put("lcCourrielContainer", lcCourrielContainer);
449
 
973 gduche 450
		fsContact.add(new Text(""));
451
 
692 gduche 452
		ChampMultiValeurs sites = new ChampMultiValeurs("Sites web");
695 gduche 453
		sites.setValeurParDefaut("http://");
729 jp_milcent 454
		sites.setValidation(Pattern.url, "http://www.monsite.com");
692 gduche 455
		fsContact.add(sites);
456
		hmIdentite.put("sites", sites);
1086 jpm 457
 
458
		right.add(fsContact);
459
 
460
		//+------------------------------------------------------------------------------------------------------------+
461
		// Fieldset AUTRES INFOS
676 gduche 462
		FieldSet fsAutresInfos = new FieldSet();
1680 raphael 463
		fsAutresInfos.setHeadingHtml("Autres informations");
676 gduche 464
 
465
		formLayout = new FormLayout();
466
		formLayout.setLabelAlign(LabelAlign.LEFT);
467
		fsAutresInfos.setLayout(formLayout);
356 gduche 468
 
386 gduche 469
 
676 gduche 470
		formLayout = new FormLayout();
471
		formLayout.setLabelAlign(LabelAlign.TOP);
472
		LayoutContainer lcAutreInformations1 = new LayoutContainer(formLayout);
1086 jpm 473
 
676 gduche 474
		ListStore<Valeur> storeSexe = new ListStore<Valeur>();
475
		ComboBox<Valeur> cbSexe = new ComboBox<Valeur>();
476
		cbSexe.setStore(storeSexe);
477
		cbSexe.setFieldLabel("Sexe");
478
		cbSexe.setDisplayField("nom");
479
		cbSexe.setEmptyText("Choisissez le sexe:");
1101 gduche 480
		cbSexe.setTypeAhead(true);
481
		cbSexe.setTriggerAction(TriggerAction.ALL);
973 gduche 482
 
483
		FormData fd = new FormData();
484
		fd.setWidth(100);
485
		lcAutreInformations1.add(cbSexe, fd);
676 gduche 486
		hmIdentite.put("cbSexe", cbSexe);
386 gduche 487
 
1369 cyprien 488
		mediateur.obtenirListeValeurEtRafraichir(this, "sexe", sequenceur);
676 gduche 489
 
490
		//Description
491
		TextArea taDescription = new TextArea();
492
		taDescription.setEmptyText("Saisissez une description");
493
		taDescription.setFieldLabel("Description");
494
		taDescription.setWidth("100%");
495
		taDescription.setName("description");
496
 
1086 jpm 497
		lcAutreInformations1.add(taDescription, new FormData(500, 200));
676 gduche 498
		hmIdentite.put("taDescription", taDescription);
499
 
500
		fsAutresInfos.add(lcAutreInformations1);
501
 
502
		// Logo
689 gduche 503
		LayoutContainer lcLogoUrl = new LayoutContainer();
504
		hmIdentite.put("lcLogoUrl", lcLogoUrl);
676 gduche 505
 
875 jpm 506
		ChampMultiValeursImage logo = new ChampMultiValeursImage(i18nC.personneLogos());
701 gduche 507
		logo.setImageHeight("150px");
508
		logo.setValeurParDefaut("http://");
729 jp_milcent 509
		logo.setValidation(Pattern.url, "http://www.monsite.com/mon_image.jpg");
701 gduche 510
		logo.setValeurBoutonSupprimer("Supprimer");
511
		hmIdentite.put("logos", logo);
676 gduche 512
 
701 gduche 513
		lcLogoUrl.add(logo);
676 gduche 514
 
701 gduche 515
		fsAutresInfos.add(logo);
689 gduche 516
 
517
		LayoutContainer lcAutreInformations2 = new LayoutContainer(new ColumnLayout());
518
		hmIdentite.put("lcAutreInformations2", lcAutreInformations2);
676 gduche 519
		fsAutresInfos.add(lcAutreInformations2);
386 gduche 520
 
676 gduche 521
		right.add(fsAutresInfos);
1086 jpm 522
 
523
		//+------------------------------------------------------------------------------------------------------------+
676 gduche 524
		// Ajout des évènements saisi
525
		KeyListener klNoms = new KeyListener()	{
526
			public void componentKeyUp(ComponentEvent ev)	{
527
				rafraichir(null);
528
			}
529
		};
530
 
531
		SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
532
			public void selectionChanged(SelectionChangedEvent se) {
730 jp_milcent 533
				rafraichir(null);
534
			}
676 gduche 535
		};
283 gduche 536
 
676 gduche 537
		cbPrefixe.addSelectionChangedListener(selectionChange);
538
		cbPrefixe.addKeyListener(klNoms);
539
		tfPrenom.addKeyListener(klNoms);
540
		tfNom.addKeyListener(klNoms);
541
		cbSuffixe.addSelectionChangedListener(selectionChange);
276 gduche 542
 
543
	}
544
 
293 gduche 545
	public void creerComposantsAdresse()	{
546
		// Gauche
547
		LayoutContainer left = new LayoutContainer();
548
		left.setLayout(new FormLayout());
821 gduche 549
		left.setStyleAttribute("padding", "15px");
293 gduche 550
		// Droite
551
		LayoutContainer right = new LayoutContainer();
552
		right.setLayout(new FormLayout());
553
 
554
		// Principal
555
		LayoutContainer main = new LayoutContainer();
821 gduche 556
		main.setLayout(new TableLayout(2));
293 gduche 557
 
558
		// Ajout au principal
821 gduche 559
		main.add(left);
560
		main.add(right);
293 gduche 561
 
562
		TextField<String> tfAdresse1 = new TextField();
563
		tfAdresse1.setFieldLabel("Adresse");
376 gduche 564
		tfAdresse1.setName("adresse_01");
319 gduche 565
		left.add(tfAdresse1, fd100);
293 gduche 566
		hmAdresse.put("tfAdresse1", tfAdresse1);
567
 
568
		ComboBox<Valeur> cbPays = new ComboBox<Valeur>();
569
		cbPays.setFieldLabel("Pays");
570
		cbPays.setDisplayField("nom");
571
		cbPays.setEmptyText("Sélectionnez le pays:");
572
 
573
		ListStore<Valeur> storePays = new ListStore<Valeur>();
574
		cbPays.setStore(storePays);
575
 
319 gduche 576
		right.add(cbPays, fd100);
293 gduche 577
		hmAdresse.put("cbPays", cbPays);
578
 
579
		TextField<String> tfBoitePostale = new TextField<String>();
580
		tfBoitePostale.setFieldLabel("Boite postale");
376 gduche 581
		tfBoitePostale.setName("bp");
582
 
319 gduche 583
		left.add(tfBoitePostale, fd100);
293 gduche 584
		hmAdresse.put("tfBoitePostale", tfBoitePostale);
585
 
586
		TextField<Integer> tfCodePostal = new TextField<Integer>();
587
		tfCodePostal.setFieldLabel("Code postal");
376 gduche 588
		tfCodePostal.setName("code_postal");
589
 
319 gduche 590
		right.add(tfCodePostal, fd100);
293 gduche 591
		hmAdresse.put("tfCodePostal", tfCodePostal);
592
 
593
		TextField tfVille = new TextField();
594
		tfVille.setFieldLabel("Ville");
376 gduche 595
		tfVille.setName("ville");
293 gduche 596
 
319 gduche 597
		right.add(tfVille, fd100);
293 gduche 598
		hmAdresse.put("tfVille", tfVille);
599
 
600
		// MAJ ComboBox
1369 cyprien 601
		mediateur.obtenirListeValeurEtRafraichir(this, "pays", sequenceur);
293 gduche 602
 
304 gduche 603
		FieldSet fsAdresse = new FieldSet();
1680 raphael 604
		fsAdresse.setHeadingHtml("Adresse personnelle");
304 gduche 605
		fsAdresse.add(main);
293 gduche 606
 
304 gduche 607
		tiAdresses.add(fsAdresse);
293 gduche 608
	}
821 gduche 609
 
610
	public void creerComposantsInfosNat()	{
338 gduche 611
 
979 gduche 612
		FormLayout fl = new FormLayout();
613
		fl.setLabelAlign(LabelAlign.TOP);
821 gduche 614
		FieldSet fsInfosNat = new FieldSet();
979 gduche 615
		fsInfosNat.setLayout(fl);
821 gduche 616
		fsInfosNat.setTitle("Informations Naturaliste");
1292 cyprien 617
 
979 gduche 618
		TextArea taBiographie = new TextArea();
619
		taBiographie.setFieldLabel("Vie et renommée de l'auteur");
620
		taBiographie.setWidth("400");
621
		taBiographie.setName("biographie");
1086 jpm 622
		fsInfosNat.add(taBiographie, new FormData(800, 200));
1292 cyprien 623
 
875 jpm 624
		ChampMultiValeurs specialite = new ChampMultiValeurs(i18nC.personneSpecialite());
821 gduche 625
		fsInfosNat.add(specialite);
626
		hmInfosNat.put("specialite", specialite);
1292 cyprien 627
 
628
		ModelType typeTypes = new ModelType();
629
		typeTypes.setRoot("valeurs");
630
		typeTypes.setTotalName("nbElements");
631
		typeTypes.addField("cmlv_nom");
632
		typeTypes.addField("cmlv_id_valeur");
633
		typeTypes.addField("cmlv_abreviation");
634
		typeTypes.addField("cmlv_description");
821 gduche 635
 
1292 cyprien 636
		String displayNameTypes = "cmlv_nom";
637
		String nomListeTypes = "pays";
1468 jpm 638
		ProxyValeur<ModelData> proxyTypes = new ProxyValeur<ModelData>(nomListeTypes, null);
1292 cyprien 639
 
640
		ChampMultiValeursMultiTypesPaginable recolte = new ChampMultiValeursMultiTypesPaginable(i18nC.personneRecolte(), 450, false, null, null, null, typeTypes, proxyTypes, displayNameTypes);
641
 
821 gduche 642
		hmInfosNat.put("recolte", recolte);
643
		fsInfosNat.add(recolte);
644
		tiInfosNat.add(fsInfosNat);
645
	}
646
 
991 gduche 647
	public void creerComposantsPubli(){
648
		//Création des composants de l'onglet publication
649
 
650
		ContentPanel cp = new ContentPanel();
1680 raphael 651
		cp.setHeadingHtml("Publications dont la personne est le sujet");
991 gduche 652
		cp.setIcon(Images.ICONES.table());
653
		cp.setLayout(new FitLayout());
654
		cp.setFrame(true);
655
 
656
		ToolBar toolBar = new ToolBar();
657
 
658
		Button ajouterPubli = new Button("Ajouter");
659
		ajouterPubli.setIcon(Images.ICONES.vcardAjouter());
660
		ajouterPubli.addSelectionListener(new SelectionListener<ButtonEvent>() {
661
			@Override
662
			public void componentSelected(ButtonEvent ce) {
663
				/*StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
664
				ajouterMembreAGrillePersonnel(membreDuPersonnel);*/
665
			}
666
		});
667
		toolBar.add(ajouterPubli);
668
 
669
		toolBar.add(new SeparatorToolItem());
670
 
671
		Button supprimerPubli = new Button("Supprimer");
672
		supprimerPubli.setIcon(Images.ICONES.vcardSupprimer());
673
		supprimerPubli.addSelectionListener(new SelectionListener<ButtonEvent>() {
674
			@Override
675
			public void componentSelected(ButtonEvent ce) {
676
				/*StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
677
				if (personne != null) {
678
					// Ajout de la personne supprimée à la liste
679
					if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {
680
						personnelSupprime.put(personne.getId(), personne);
681
					}
682
 
683
					// Suppression de l'enregistrement de la grille
684
					grillePersonnel.getStore().remove(personne);
685
 
686
					// Désactivation du bouton supprimer si la grille contient plus d'élément
687
					if (grillePersonnel.getStore().getCount() == 0) {
688
						//TODO : check : Item -> component
689
						ce.getComponent().disable();
690
					}
691
				}*/
692
				Window.alert("supprimer");
693
			}
694
		});
695
		toolBar.add(supprimerPubli);
696
 
697
		toolBar.add(new SeparatorToolItem());
698
 
699
		Button rafraichirPersonnelBtn = new Button("Rafraichir");
700
		rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir());
701
		rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {
702
			@Override
703
			public void componentSelected(ButtonEvent ce) {
704
				//rafraichirPersonnel();
705
				Window.alert("rafraichir");
706
			}
707
		});
708
		toolBar.add(rafraichirPersonnelBtn);
709
 
710
		//Ajout d'une ComboBox
711
		storePubli = new ListStore<Publication>();
712
		storePubli.add(new ArrayList<Publication>());
713
 
714
		cbPubli = new ComboBox<Publication>();
715
		cbPubli.setWidth(200);
716
		cbPubli.setEmptyText("Chercher une publication existante...");
717
		cbPubli.setTriggerAction(TriggerAction.ALL);
718
		cbPubli.setEditable(true);
719
		cbPubli.setDisplayField("fmt_nom_complet");
720
		cbPubli.setStore(storePubli);
721
		cbPubli.addKeyListener(new KeyListener() {
722
 
723
			public void componentKeyUp(ComponentEvent ce) {
724
				if (!ce.isNavKeyPress() && cbPubli.getRawValue() != null && cbPubli.getRawValue().length() > 0) {
725
					rafraichirPublicationsExistante(cbPubli.getRawValue());
726
				}
727
			}
728
 
729
		});
730
 
731
		toolBar.add(cbPubli);
732
		toolBar.add(new SeparatorToolItem());
733
		cp.setTopComponent(toolBar);
734
 
735
 
736
		tiPubli.add(cp);
737
	}
738
 
1262 cyprien 739
	public void rafraichirPublicationsExistante(String nomPubli)	{
991 gduche 740
		nomPubli +="%";
1764 aurelien 741
		mediateur.selectionnerPublicationParNomComplet(this, nomPubli);
991 gduche 742
	}
743
 
276 gduche 744
	/**
745
	 * Ajouter le bouton annuler à la barre d'outils donnée
746
	 *
747
	 * @param barreOutils la barre d'outils à modifier
748
	 * */
356 gduche 749
	public static void ajouterBoutonAnnuler(ButtonBar barreOutils)	{
276 gduche 750
 
751
		// Le bouton annuler ne sauvegarde pas les informations et renvoie vers la page précédente
356 gduche 752
		Button annuler = new Button("Revenir à la liste");
488 gduche 753
		annuler.addSelectionListener(new SelectionListener<ButtonEvent>() {
754
			public void componentSelected(ButtonEvent ce) {
276 gduche 755
				((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
756
			}
757
		});
758
		annuler.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
759
		barreOutils.add(annuler);
760
	}
761
 
730 jp_milcent 762
	// RAFRAICHISSEMENT DU PANNEAU
763
 
283 gduche 764
	public void rafraichir(Object nouvellesDonnees) {
1292 cyprien 765
 
1262 cyprien 766
		if (nouvellesDonnees instanceof PublicationAPersonneListe)	{
991 gduche 767
			Information info = new Information();
768
			info.setType("publication_liees");
769
			info.setDonnee(0, (PublicationAPersonneListe) nouvellesDonnees);
770
			tiPubli.rafraichir(info);
1014 gduche 771
 
1292 cyprien 772
		} else if (nouvellesDonnees instanceof ValeurListe) {
283 gduche 773
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
774
			// Créer une liste de valeurs
775
			List<Valeur> liste = new ArrayList<Valeur>();
776
			for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
777
				liste.add(listeValeurs.get(it.next()));
778
			}
1014 gduche 779
			if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication")))	{
1262 cyprien 780
				tiPubli.rafraichir(nouvellesDonnees);
1014 gduche 781
			} else if (listeValeurs.getId().equals(config.getListeId("prefixe")))	{
319 gduche 782
				remplirCombobox("cbPrefixe", liste, "hmIdentite");
293 gduche 783
			} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) {
784
				remplirCombobox("cbSuffixe", liste, "hmIdentite");
785
			} else if (listeValeurs.getId().equals(config.getListeId("sexe"))) {
1101 gduche 786
 
787
				//Ajout de la valeur "Inconnu"
788
				ComboBox<Valeur> cbSexe = hmAdresse.getComboBoxValeur("cbSexe");
789
				Valeur inconnu = new Valeur();
790
				inconnu.set("nom", "Inconnu");
791
				inconnu.set("id", "0");
792
				liste.add(0, inconnu);
793
 
293 gduche 794
				remplirCombobox("cbSexe", liste, "hmIdentite");
1101 gduche 795
 
796
				/*List<Valeur> selection = new LinkedList<Valeur>();
797
				selection.add(inconnu);
798
				cbSexe.setSelection(s);*/
799
 
800
 
293 gduche 801
			} else if (listeValeurs.getId().equals(config.getListeId("tel"))) {
802
				remplirCombobox("cbTelephone", liste, "hmIdentite");
730 jp_milcent 803
 
319 gduche 804
				//Préselection du tél
973 gduche 805
				ComboBox<Valeur> cbTelephone = hmIdentite.getComboBoxValeur("cbTelephone");
319 gduche 806
				cbTelephone.setValue(liste.get(1));
293 gduche 807
			} else if (listeValeurs.getId().equals(config.getListeId("pays")))	{
808
				remplirCombobox("cbPays", liste, "hmAdresse");
283 gduche 809
			}
991 gduche 810
		} else if (nouvellesDonnees instanceof PublicationListe)	{
811
			PublicationListe publicationListe = (PublicationListe) nouvellesDonnees;
812
			List<Publication> liste = publicationListe.toList();
813
			storePubli.removeAll();
814
			storePubli.add(liste);
815
			cbPubli.setStore(storePubli);
1262 cyprien 816
		} else if (nouvellesDonnees instanceof Information)	{
352 gduche 817
			Information info = (Information) nouvellesDonnees;
386 gduche 818
			if (info.getType().equals("ajout_personne"))	{
884 jpm 819
				if (info.getDonnee(0) != null) {
820
					personneSelectionnee.setId(info.getDonnee(0).toString());
821
					GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null);
1329 cyprien 822
					this.personne = personneSelectionnee;
823
					this.personneId = personneSelectionnee.getId();
1239 cyprien 824
					InfoLogger.display("Enregistrement", "La personne a été ajoutée (id: " + personneSelectionnee.getId() + ")");
884 jpm 825
					repandreRafraichissement();
826
					if (clicBoutonvalidation)	{
827
						mediateur.clicMenu(menuIdCourant);
1617 aurelien 828
					} else {
829
						this.mode = MODE_MODIFIER;
884 jpm 830
					}
831
				} else {
1239 cyprien 832
					InfoLogger.display("Enregistrement", info.getMessages().toString());
852 gduche 833
				}
433 gduche 834
			} else if (info.getType().equals("modification_personne"))	{
1239 cyprien 835
				InfoLogger.display("Enregistrement", "Les modifications apportées à la personne " + personneSelectionnee.getId() + " ont été correctement enregistrées.");
884 jpm 836
				repandreRafraichissement();
1613 aurelien 837
				controlerFermeture();
884 jpm 838
			} else if (info.getType().equals("maj_utilisateur"))	{
668 gduche 839
				gererEtatActivationBouton();
386 gduche 840
			} else if (info.getDonnee(0) instanceof PersonneListe)	{
776 gduche 841
 
730 jp_milcent 842
				Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values();
843
				Iterator itPersonneListe = colPersonneListe.iterator();
844
				Personne personne = (Personne) itPersonneListe.next();
845
 
991 gduche 846
				//TODO : Je vois pas l'intérêt des lignes ci dessous..
730 jp_milcent 847
				personneSauvegarde = new Personne();
848
				personneSauvegarde = (Personne) personne.cloner(personneSauvegarde);
849
 
850
				binderPersonne(personne);
851
 
776 gduche 852
				mettreAJourPersonne(personne);
730 jp_milcent 853
 
1329 cyprien 854
				this.personne = personne;
855
				this.personneId = personne.getId();
856
 
1513 jpm 857
				tiPubli.rafraichirInformation(new Information("personne"));
858
 
730 jp_milcent 859
				nouvellesDonnees = null;
860
			} else {
1239 cyprien 861
				InfoLogger.display("messages", info.getMessages().toString());
730 jp_milcent 862
			}
776 gduche 863
		}
283 gduche 864
 
1262 cyprien 865
		if (nouvellesDonnees == null) {
973 gduche 866
			ComboBox<Valeur> cb= hmIdentite.getComboBoxValeur("cbPrefixe");
293 gduche 867
 
868
			//Met à jour le nom Complet du formulaire
283 gduche 869
			String valeurRetour = "";
870
 
871
			// Prefixe
872
			String prefixe = "";
973 gduche 873
			Valeur valPrefixe = cb.getValue();
283 gduche 874
 
875
			if (valPrefixe != null)	{
876
				prefixe = valPrefixe.getNom();
293 gduche 877
			} else 	{
973 gduche 878
				prefixe =  (String) cb.getRawValue();
293 gduche 879
			}
283 gduche 880
 
881
			// Prénom
973 gduche 882
			String prenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
283 gduche 883
 
884
			// Nom
973 gduche 885
			String nom = (String) hmIdentite.getTextField("tfNom").getValue();
283 gduche 886
 
887
			// Suffixe
973 gduche 888
			ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe");
889
 
283 gduche 890
			String suffixe = "";
973 gduche 891
			Valeur valSuffixe = cbSuffixe.getValue();
283 gduche 892
 
893
			if (valSuffixe != null)	{
894
				suffixe = valSuffixe.getNom();
293 gduche 895
			} else 	{
973 gduche 896
				suffixe =  (String) cbSuffixe.getRawValue();
283 gduche 897
			}
898
 
899
			// Mettre à jour la valeur
900
			valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
901
			valeurRetour = valeurRetour.replaceAll("null", "");
902
 
973 gduche 903
			hmIdentite.getLabelField("nomComplet").setValue(valeurRetour);
283 gduche 904
 
905
			if (!valeurRetour.trim().equals(""))	{
973 gduche 906
				hmIdentite.getLabelField("nomComplet").show();
283 gduche 907
			} else {
973 gduche 908
				hmIdentite.getLabelField("nomComplet").hide();
283 gduche 909
			}
910
		}
338 gduche 911
 
912
		mediateur.masquerPopinChargement();
456 gduche 913
 
461 gduche 914
		if (this.mode.equals(MODE_AJOUTER))	{
668 gduche 915
			gererEtatActivationBouton();
1262 cyprien 916
		}
127 gduche 917
	}
918
 
1262 cyprien 919
	private void repandreRafraichissement() {
884 jpm 920
		if (vueExterneARafraichirApresValidation != null) {
921
			String type = "personne_modifiee";
922
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
923
				type = "personne_ajoutee";
924
			}
925
			Information info = new Information(type);
926
			info.setDonnee(0, personneSelectionnee);
927
			vueExterneARafraichirApresValidation.rafraichir(info);
928
		}
929
	}
930
 
776 gduche 931
	private void mettreAJourPersonne(Personne personne)	{
1292 cyprien 932
 
1329 cyprien 933
		//Mise à jour de la personne
776 gduche 934
 
935
		//Prefixe
936
		String prefixe = personne.get("ce_truk_prefix");
973 gduche 937
		ComboBox<Valeur> cbPrefixe = hmIdentite.getComboBoxValeur("cbPrefixe");
776 gduche 938
 
939
 
940
		String prefixeCourant = personne.get("ce_truk_prefix");
941
		if (cbPrefixe.getStore().findModel("id_valeur", prefixeCourant) != null)	{
942
			cbPrefixe.setValue(cbPrefixe.getStore().findModel("id_valeur", prefixeCourant));
943
		}	else	{
944
			cbPrefixe.setRawValue(prefixeCourant);
945
		}
946
 
973 gduche 947
		hmIdentite.getTextField("tfPrenom").setValue(personne.get("prenom"));
948
		hmIdentite.getTextField("tfNom").setValue(personne.get("nom"));
776 gduche 949
 
950
		//Suffixe
951
		String suffixe = personne.get("ce_truk_suffixe");
973 gduche 952
		ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe");
776 gduche 953
 
954
		String suffixeCourant = personne.get("ce_truk_suffix");
955
		if (cbSuffixe.getStore().findModel("id_valeur", suffixeCourant) != null)	{
956
			cbSuffixe.setValue(cbSuffixe.getStore().findModel("id_valeur", suffixeCourant));
957
		}	else	{
958
			cbSuffixe.setRawValue(suffixeCourant);
959
		}
960
 
973 gduche 961
		hmIdentite.getChampMultiValeurs("nomAutre").peupler(personne.getString("truk_nom_autre"));
962
		hmIdentite.getTextField("tfAbreviation").setValue(personne.get("abreviation"));
963
		hmIdentite.getChampMultiValeurs("abreviationAutre").peupler(personne.getString("truk_abreviation_autre"));
776 gduche 964
 
1284 gduche 965
		hmIdentite.getTextField("tfDateNaissance").setValue(personne.getAnneeOuDateNaiss());
973 gduche 966
		hmIdentite.getTextField("tfLieuNaissance").setValue(personne.get("naissance_lieu"));
776 gduche 967
 
1186 gduche 968
 
829 gduche 969
		if (personne.estDecedee())	{
1284 gduche 970
			hmIdentite.getTextField("tfDateDeces").setValue(personne.getAnneeOuDateDeces());
973 gduche 971
			hmIdentite.getTextField("tfLieuDeces").setValue(personne.get("deces_lieu"));
972
			Radio rbEstDecede = hmIdentite.getRadio("rbEstDecedee");
829 gduche 973
			rbEstDecede.setValue(true);
974
		}
776 gduche 975
 
973 gduche 976
		hmIdentite.getChampMultiValeurs("telephones").peupler(personne.getString("truk_telephone"));
776 gduche 977
 
978
		//Courriel
973 gduche 979
		hmIdentite.getChampMultiValeurs("courriels").peupler(personne.getCourriel());
776 gduche 980
 
981
		//Sites web
973 gduche 982
		hmIdentite.getChampMultiValeurs("sites").peupler(personne.getString("truk_url"));
776 gduche 983
 
984
		// Sexe
985
		String strSexe = personne.get("ce_sexe");
973 gduche 986
		ComboBox<Valeur> cbSexe = hmIdentite.getComboBoxValeur("cbSexe");
776 gduche 987
 
988
		if (cbSexe.getStore().findModel("id_valeur", strSexe) != null)	{
989
			cbSexe.setValue(cbSexe.getStore().findModel("id_valeur", strSexe));
990
		}
991
 
973 gduche 992
		hmIdentite.getTextArea("taDescription").setRawValue((String) personne.get("description"));
776 gduche 993
 
994
		//Logo
973 gduche 995
		hmIdentite.getChampMultiValeurs("logos").peupler(personne.getString("truk_logo"));
776 gduche 996
 
997
		/*--------------------------------------------------
998
		                      Adresse
999
		 ---------------------------------------------------*/
1000
 
1001
		// Adresse
976 gduche 1002
		hmAdresse.getTextField("tfAdresse1").setValue((String) personne.get("adresse_01"));
776 gduche 1003
 
1004
		//Boite postale
976 gduche 1005
		hmAdresse.getTextField("tfBoitePostale").setValue((String) personne.get("bp"));
776 gduche 1006
 
1007
		//Pays
1026 gduche 1008
		String strPays = personne.get("ce_truk_pays");
976 gduche 1009
		ComboBox<Valeur> cbPays = hmAdresse.getComboBoxValeur("cbPays");
1292 cyprien 1010
		cbPays.getStore().sort("nom", SortDir.ASC);
1011
 
1026 gduche 1012
		if (cbPays.getStore().findModel("id_valeur", strPays) != null)	{
1013
			cbPays.setValue(cbPays.getStore().findModel("id_valeur", strPays));
1014
			cbPays.fireEvent(Events.OnChange);
776 gduche 1015
		}	else	{
1016
			cbPays.setRawValue(strPays);
1017
		}
1018
 
1019
		//Cp
976 gduche 1020
		hmAdresse.getTextField("tfCodePostal").setValue(personne.get("code_postal"));
776 gduche 1021
 
1022
		//Ville
976 gduche 1023
		hmAdresse.getTextField("tfVille").setValue(personne.get("ville"));
776 gduche 1024
 
821 gduche 1025
		/*--------------------------------------------------------
1026
		 * 					Infos naturalistes
1027
		 * -----------------------------------------------------*/
1028
 
979 gduche 1029
		hmInfosNat.getChampMultiValeurs("specialite").peupler(personne.getString("ce_truk_specialite"));
1292 cyprien 1030
		String tr = personne.getString("truk_recolte");
1031
		hmInfosNat.getChampMultiValeursMultiTypesPaginable("recolte").peupler(tr);
991 gduche 1032
 
1262 cyprien 1033
		//Onglet publi
991 gduche 1034
		tiPubli.mettreAJourPersonne();
776 gduche 1035
		gererEtatActivationBouton();
1036
	}
730 jp_milcent 1037
 
293 gduche 1038
	public void remplirCombobox(String idComboBox, List liste, String hashMapId)	{
1039
		HashMap hm = null;
1040
		if (hashMapId.equals("hmIdentite"))	{
1041
			hm = hmIdentite;
1042
		} else if (hashMapId.equals("hmAdresse")){
1043
			hm = hmAdresse;
1044
		} else {
1045
			hm = hmInfosNat;
1046
		}
1047
 
1048
		ListStore<Valeur> store = ((ComboBox) hm.get(idComboBox)).getStore();
376 gduche 1049
 
293 gduche 1050
		store.removeAll();
1051
		store.add(liste);
1052
		((ComboBox) hm.get(idComboBox)).setStore(store);
1053
	}
130 gduche 1054
 
668 gduche 1055
	private void gererEtatActivationBouton()	{
850 gduche 1056
	/*	if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie() == false)	{
668 gduche 1057
			enregistrer.setEnabled(false);
1058
			enregistrerEtRevenir.setEnabled(false);
1059
		} else	{
1060
			enregistrer.setEnabled(true);
1061
			enregistrerEtRevenir.setEnabled(true);
850 gduche 1062
		}*/
668 gduche 1063
	}
1064
 
376 gduche 1065
	public void binderPersonne(Personne personne)	{
850 gduche 1066
		binding = new FormBinding(getFormulaire());
731 jp_milcent 1067
 
376 gduche 1068
		personneSelectionnee = personne;
1186 gduche 1069
 
1070
		FieldBinding f = new FieldBinding((RadioGroup) hmIdentite.get("rbgDeces"), null);
376 gduche 1071
		binding.autoBind();
1186 gduche 1072
		binding.removeFieldBinding(f);
1073
 
376 gduche 1074
		binding.bind(personneSelectionnee);
1075
		layout();
1076
	}
1292 cyprien 1077
 
376 gduche 1078
	private String obtenirValeurCombo(String strComboName)	{
1079
		String strValeur = "";
1080
		Valeur valeur;
1081
 
973 gduche 1082
		ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur(strComboName);
376 gduche 1083
		if (combo == null)	{
976 gduche 1084
			combo = hmAdresse.getComboBoxValeur(strComboName);
376 gduche 1085
		}
829 gduche 1086
		strValeur = combo.getRawValue();
1026 gduche 1087
		valeur = combo.getValue();
829 gduche 1088
		if (valeur != null)	{
1089
			strValeur = valeur.getId();
1090
		}
1091
 
376 gduche 1092
		return strValeur;
1093
	}
850 gduche 1094
 
934 jpm 1095
	public boolean soumettreFormulaire() {
1014 gduche 1096
		tiPubli.collecter();
850 gduche 1097
		if (verifierFormulaire())	{
991 gduche 1098
			tiPubli.soumettre();
850 gduche 1099
			mediateur.enregistrerPersonne(this, personneSelectionnee);
1262 cyprien 1100
			return true;
850 gduche 1101
		}
1262 cyprien 1102
		else return false;
850 gduche 1103
	}
1104
 
934 jpm 1105
	public boolean verifierFormulaire() {
884 jpm 1106
		boolean success = true;
1107
		LinkedList<String> lstMessageErreur = new LinkedList<String>();
850 gduche 1108
 
973 gduche 1109
		String strTfNom = (String) hmIdentite.getTextField("tfNom").getValue();
850 gduche 1110
		if ((strTfNom == null)||(strTfNom.trim().equals("")))	{
1111
			lstMessageErreur.add("Le nom n'a pas été saisi");
1112
		} else {
1113
			strTfNom = UtilString.ucFirst(strTfNom);
1114
			personneSelectionnee.set("nom", strTfNom);
1115
		}
1116
 
973 gduche 1117
		String strTfPrenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
850 gduche 1118
		personneSelectionnee.set("prenom", UtilString.ucFirst(strTfPrenom));
1119
 
1120
		//Préparer les données
973 gduche 1121
		ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur("cbSexe");
850 gduche 1122
		Valeur valeur;
1123
		String strValeur = "";
1124
 
973 gduche 1125
		valeur = combo.getValue();
850 gduche 1126
		if (valeur!=null)	{
1127
			personneSelectionnee.set("ce_sexe", valeur.getId());
1128
		}
1129
 
1130
		strValeur = obtenirValeurCombo("cbPrefixe");
1131
		personneSelectionnee.set("ce_truk_prefix", strValeur);
1132
 
1133
		strValeur = obtenirValeurCombo("cbSuffixe");
1134
		personneSelectionnee.set("ce_truk_suffix", strValeur);
1135
 
973 gduche 1136
		String nomAutre = hmIdentite.getChampMultiValeurs("nomAutre").getValeurs();
850 gduche 1137
		personneSelectionnee.set("truk_nom_autre", nomAutre);
1138
 
973 gduche 1139
		String abreviationAutre = hmIdentite.getChampMultiValeurs("abreviationAutre").getValeurs();
850 gduche 1140
		personneSelectionnee.set("truk_abreviation_autre", abreviationAutre);
1141
 
973 gduche 1142
		personneSelectionnee.set("truk_courriel", hmIdentite.getChampMultiValeurs("courriels").getValeurs());
850 gduche 1143
 
1144
 
1145
		//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
1146
		String strPrefixe = "";
973 gduche 1147
		combo = hmIdentite.getComboBoxValeur("cbPrefixe");
1148
		valeur = combo.getValue();
850 gduche 1149
		if (valeur != null)	{
1150
			strPrefixe = valeur.getNom();
1151
		} else {
1152
			strPrefixe = combo.getRawValue();
1153
		}
1154
 
1155
		String strSuffixe = "";
973 gduche 1156
		combo = hmIdentite.getComboBox("cbSuffixe");
1157
		valeur = combo.getValue();
850 gduche 1158
		if (valeur != null)	{
1159
			strSuffixe = valeur.getNom() + " ";
1160
		} else {
1161
			strSuffixe = combo.getRawValue() +" ";
1162
		}
1163
 
1164
		personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe);
1329 cyprien 1165
 
1166
		/** NAISSANCE **/
1284 gduche 1167
		String valeurDateNaissance = (String) hmIdentite.getTextField("tfDateNaissance").getValue();
1329 cyprien 1168
		traiterDate("naissance", valeurDateNaissance, personneSelectionnee, lstMessageErreur);
850 gduche 1169
 
1329 cyprien 1170
		/** DECES **/
973 gduche 1171
		Radio rbEstDecedee = hmIdentite.getRadio("rbEstDecedee");
1329 cyprien 1172
		if (rbEstDecedee.getValue() == true) {
1173
			// date
1174
			String valeurDateDeces = (String) hmIdentite.getTextField("tfDateDeces").getValue();
1175
			traiterDate("décès", valeurDateDeces, personneSelectionnee, lstMessageErreur);
1176
			// lieu
973 gduche 1177
			String decesLieu = (String) hmIdentite.getTextField("tfLieuDeces").getValue();
1329 cyprien 1178
			personneSelectionnee.setDecesLieu(decesLieu);
1179
		} else {
1468 jpm 1180
			personneSelectionnee.setNonDecedee();
850 gduche 1181
		}
1182
 
1292 cyprien 1183
		strValeur = obtenirValeurCombo("cbPays");
850 gduche 1184
		personneSelectionnee.set("ce_truk_pays", strValeur);
1185
 
1643 aurelien 1186
		success = hmIdentite.getChampMultiValeursMultiTypes("telephones").estValide(true);
973 gduche 1187
		personneSelectionnee.set("truk_telephone", hmIdentite.getChampMultiValeursMultiTypes("telephones").getValeurs());
850 gduche 1188
 
973 gduche 1189
		String logoUrls = hmIdentite.getChampMultiValeursImage("logos").getValeurs();
850 gduche 1190
		personneSelectionnee.set("truk_logo", logoUrls);
1191
 
973 gduche 1192
		personneSelectionnee.set("truk_url", hmIdentite.getChampMultiValeurs("sites").getValeurs());
850 gduche 1193
 
1194
		//Infos Naturalistes
1292 cyprien 1195
		String recolte = ((ChampMultiValeursMultiTypesPaginable) hmInfosNat.get("recolte")).getValeurs();
850 gduche 1196
		personneSelectionnee.set("truk_recolte", recolte);
1197
 
1198
		String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs();
1199
		personneSelectionnee.set("ce_truk_specialite", specialite);
1200
 
1014 gduche 1201
		lstMessageErreur.addAll(tiPubli.verifier());
850 gduche 1202
 
884 jpm 1203
		if (lstMessageErreur.size() != 0)	{
850 gduche 1204
			String strMessagesErreur = "<span><br />";
1205
			Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
1206
			while (itMessagesErreur.hasNext())	{
1207
				strMessagesErreur += "<br /> - " + itMessagesErreur.next();
1208
			}
1209
			strMessagesErreur += "</span>";
1210
 
1211
 			MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
1212
 			success = false;
1213
		}
1214
 
1215
		return success;
1216
	}
1329 cyprien 1217
 
1218
	private void traiterDate(String typeDate, String date, Personne personneSelectionnee, LinkedList<String> lstMessageErreur) {
1468 jpm 1219
 
1329 cyprien 1220
		String valeurDate = date;
1468 jpm 1221
 
1329 cyprien 1222
		if (!UtilString.isEmpty(valeurDate)){
1223
			String jour = "";
1224
			String mois = "";
1225
			String annee = "";
1591 delphine 1226
			String dateComplete = "";
1227
			String messageErreur = null;
1329 cyprien 1228
 
1229
			/**  JJ/MM/AAAA  **/
1230
			if (valeurDate.matches("\\d{2}/\\d{2}/\\d{4}")) {
1231
				jour = valeurDate.substring(0,2);
1232
				mois = valeurDate.substring(3,5);
1233
				annee = valeurDate.substring(6,10);
1591 delphine 1234
				if (jour.equals("00") || mois.equals("00") || annee.equals("0000")) {
1235
					messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.";
1236
				} else {
1237
					dateComplete = annee+"-"+mois+"-"+jour;
1329 cyprien 1238
				}
1239
 
1591 delphine 1240
 
1329 cyprien 1241
			/**  MM/AAAA  **/
1242
			} else if (valeurDate.matches("\\d{2}/\\d{4}")) {
1243
				jour = "00";
1244
				mois = valeurDate.substring(0,2);
1245
				annee = valeurDate.substring(3,7);
1591 delphine 1246
				if (mois.equals("00") || annee.equals("0000")) {
1247
					messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.";
1248
				} else {
1249
					dateComplete = annee+"-"+mois+"-"+jour;
1329 cyprien 1250
				}
1591 delphine 1251
 
1329 cyprien 1252
			}
1253
 
1254
			/**  AAAA  **/
1255
			else if (valeurDate.matches("\\d{4}"))	{
1591 delphine 1256
				if (valeurDate.equals("0000")) {
1257
					messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.";
1329 cyprien 1258
				}
1259
				else {
1591 delphine 1260
					dateComplete = valeurDate + "-00-00";
1261
 
1329 cyprien 1262
				}
1468 jpm 1263
			}
1264
			else {
1329 cyprien 1265
				lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.");
1266
			}
1591 delphine 1267
			if (messageErreur == null) {
1268
				if (typeDate=="naissance") personneSelectionnee.set("naissance_date", dateComplete);
1269
				else if (typeDate=="décès") {
1270
					personneSelectionnee.set("deces_date", dateComplete);
1271
					personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE);
1272
				}
1273
			} else {
1274
				lstMessageErreur.add(messageErreur);
1275
			}
1468 jpm 1276
 
1603 aurelien 1277
			if(typeDate.equals("décès")) {
1278
				String valeurDateDeces = hmIdentite.getTextField("tfDateDeces").getRawValue();
1279
				String valeurDateNaissance = hmIdentite.getTextField("tfDateNaissance").getRawValue();
1280
 
1784 aurelien 1281
				if(valeurDateDeces != null && valeurDateNaissance != null &&
1282
						!valeurDateDeces.isEmpty() && !valeurDateNaissance.isEmpty()) {
1283
					Date dateNaissance = parserDate(valeurDateNaissance);
1284
					Date dateDeces = parserDate(valeurDateDeces);
1285
 
1286
					if(dateDeces.compareTo(dateNaissance) < 0) {
1287
						lstMessageErreur.add("La date de décès ne peut pas précéder la date de naissance");
1288
					}
1603 aurelien 1289
				}
1290
			}
1468 jpm 1291
		/** Date vide **/
1292
		} else {
1591 delphine 1293
			if (typeDate=="naissance") {
1294
				personneSelectionnee.setNaissanceDate(null);
1295
			} else if (typeDate=="décès") {
1296
				personneSelectionnee.setDecesDate(null);
1297
				personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE);
1298
			}
1468 jpm 1299
		}
1591 delphine 1300
 
1329 cyprien 1301
	}
1302
 
1604 aurelien 1303
	private Date parserDate(String valeurDate) {
1304
		Date dateParsee = new Date();
1305
		String[] composantsDate = valeurDate.split("/");
1306
		// Attention : la fonction setYear ajoute 1900 à l'année
1307
		int annee = Integer.parseInt(composantsDate[(composantsDate.length-1)]) - 1900;
1308
		// Attention : les mois commencent à 0, donc janvier = 0, février = 1
1309
		int mois = (composantsDate.length > 1) ? Integer.parseInt(composantsDate[(composantsDate.length-2)]) - 1 : 0;
1310
		int jour = (composantsDate.length > 2) ? Integer.parseInt(composantsDate[0]) : 1;
1311
 
1312
		dateParsee.setYear(annee);
1313
		dateParsee.setMonth(mois);
1314
		dateParsee.setDate(jour);
1315
 
1316
		return dateParsee;
1317
	}
1318
 
1329 cyprien 1319
	public Personne getPersonne() {
1320
		return this.personne;
1321
	}
1322
 
1323
	public String getPersonneId() {
1324
		return this.personneId;
1325
	}
1845 aurelien 1326
 
1327
	private Listener<BaseEvent> creerEcouteurNomPrenomExistant() {
1328
		return new Listener<BaseEvent>() {
1329
			public void handleEvent(BaseEvent be) {
1330
				if(mode.equals(MODE_AJOUTER) && !verificationDoublonEffectuee) {
1331
 
1332
					TextField<String> nom = (TextField<String>) hmIdentite.get("tfNom");
1333
					TextField<String> prenom = (TextField<String>) hmIdentite.get("tfPrenom");
1334
					LabelField nomComplet = (LabelField) hmIdentite.get("nomComplet");
1335
 
1336
					if(nom.getValue() != null && !nom.getValue().isEmpty()) {
1337
						PersonneAsyncDao dao = new PersonneAsyncDao(PersonneForm.this);
1338
						// Suppression d'éventuels doubles espaces (ou plus) et ajout d'un joker devant
1339
						// (pour gérer la recherche lorsqu'on a qu'un nom de famille)
1340
						String nomCompletStr = "%"+nomComplet.getValue().toString().trim().replaceAll(" +", " ");
1341
 
1342
						if(prenom.getValue() != null && !prenom.getValue().isEmpty()) {
1343
							// Ajouter un % derrière le prénom permet de gérer facilement le cas de l'initiale
1344
							// et également de rechercher des noms potentiels si l'on a saisi qu'une initiale
1345
							nomCompletStr = nomCompletStr.replaceAll(prenom+" ", prenom+"%");
1346
						}
1347
 
1348
						dao.testerExistencePersonne(nomCompletStr, new Callback<JSONObject, String>() {
1349
							@Override
1350
							public void onSuccess(JSONObject objet) {
1351
 
1352
								String message = formaterMessageAvertissementDoublon(objet);
1353
								verificationDoublonEffectuee = true;
1354
 
1355
								if(!message.isEmpty()) {
1356
									Window.alert(message);
1357
								}
1358
							}
1359
 
1360
							@Override
1361
							public void onFailure(String reason) {
1362
								// TODO Auto-generated method stub
1363
							}
1364
						});
1365
					}
1366
				}
1367
			}
1368
		};
1369
	}
1370
 
1371
	private String formaterMessageAvertissementDoublon(JSONObject objet) {
1372
 
1373
		double nbPers = objet.get("nbElements").isNumber().getValue();
1374
		JSONArray personnes = objet.isObject().get("personnes").isArray();
1375
		String message = "";
1376
		if(nbPers > 0) {
1377
			String pers = nbPers == 1 ? "personne" : "personnes";
1378
			String exist = nbPers == 1 ? "existe" : "existent";
1379
			message = "Attention : "+(int)nbPers+" "+pers+" portant ce nom "+exist+" déjà"+"\n";
1380
			for(int i = 0; i < personnes.size(); i++) {
1381
				message += "- "+personnes.get(i).isObject().get("cp_fmt_nom_complet").isString().stringValue();
1382
				if(personnes.get(i).isObject().get("cp_ville") != null && personnes.get(i).isObject().get("cp_ville").isString() != null) {
1383
					message += " à "+personnes.get(i).isObject().get("cp_ville").isString().stringValue();
1384
				}
1385
 
1386
				if(personnes.get(i).isObject().get("cp_naissance_date") != null
1387
					&& personnes.get(i).isObject().get("cp_naissance_date").isString()!= null
1388
					&& !personnes.get(i).isObject().get("cp_naissance_date").isString().stringValue().equals("0000-00-00")) {
1389
					String dateChaine = personnes.get(i).isObject().get("cp_naissance_date").isString().stringValue();
1390
 
1391
					String dateNaissance = "";
1392
					// Quelque fois on ne possède que l'année de naissance de la personne,
1393
					// dans ce cas là la date est de la forme XXXX-00-00
1394
					if(dateChaine.endsWith("-00-00")) {
1395
						dateNaissance = dateChaine.substring(0, 4);
1396
					} else {
1397
						dateNaissance = UtilDate.formaterEnStringFormatFr(UtilString.formaterEnDate(dateChaine));
1398
					}
1399
 
1400
					message += ", date de naissance : "+dateNaissance;
1401
				}
1402
				message += "\n";
1403
			}
1404
		}
1405
 
1406
		return message;
1407
	}
1408
}