Subversion Repositories eFlore/Applications.coel

Rev

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