Subversion Repositories eFlore/Applications.coel

Rev

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