Subversion Repositories eFlore/Applications.coel

Rev

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