Subversion Repositories eFlore/Applications.coel

Rev

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