Subversion Repositories eFlore/Applications.coel

Rev

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