Subversion Repositories eFlore/Applications.coel

Rev

Rev 488 | Rev 540 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
127 gduche 1
package org.tela_botanica.client.vues;
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;
519 gduche 14
import org.tela_botanica.client.images.Images;
127 gduche 15
import org.tela_botanica.client.interfaces.Rafraichissable;
283 gduche 16
import org.tela_botanica.client.modeles.Configuration;
293 gduche 17
 
352 gduche 18
import org.tela_botanica.client.modeles.Information;
286 gduche 19
import org.tela_botanica.client.modeles.Personne;
352 gduche 20
import org.tela_botanica.client.modeles.PersonneListe;
456 gduche 21
import org.tela_botanica.client.modeles.Projet;
22
import org.tela_botanica.client.modeles.ProjetListe;
280 gduche 23
import org.tela_botanica.client.modeles.Valeur;
283 gduche 24
import org.tela_botanica.client.modeles.ValeurListe;
127 gduche 25
 
488 gduche 26
import com.extjs.gxt.ui.client.event.Events;
276 gduche 27
import com.extjs.gxt.ui.client.Registry;
28
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
519 gduche 29
import com.extjs.gxt.ui.client.Style.IconAlign;
283 gduche 30
import com.extjs.gxt.ui.client.Style.Scroll;
386 gduche 31
 
376 gduche 32
import com.extjs.gxt.ui.client.binding.FormBinding;
386 gduche 33
 
488 gduche 34
import com.extjs.gxt.ui.client.event.ButtonEvent;
276 gduche 35
import com.extjs.gxt.ui.client.event.ComponentEvent;
488 gduche 36
import com.extjs.gxt.ui.client.event.IconButtonEvent;
276 gduche 37
import com.extjs.gxt.ui.client.event.KeyListener;
446 gduche 38
import com.extjs.gxt.ui.client.event.Listener;
280 gduche 39
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
40
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
276 gduche 41
import com.extjs.gxt.ui.client.event.SelectionListener;
280 gduche 42
import com.extjs.gxt.ui.client.store.ListStore;
127 gduche 43
import com.extjs.gxt.ui.client.widget.LayoutContainer;
319 gduche 44
import com.extjs.gxt.ui.client.widget.MessageBox;
338 gduche 45
 
386 gduche 46
import com.extjs.gxt.ui.client.widget.Info;
276 gduche 47
import com.extjs.gxt.ui.client.widget.TabItem;
48
import com.extjs.gxt.ui.client.widget.TabPanel;
293 gduche 49
import com.extjs.gxt.ui.client.widget.Text;
283 gduche 50
 
356 gduche 51
import com.extjs.gxt.ui.client.widget.button.Button;
52
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
319 gduche 53
import com.extjs.gxt.ui.client.widget.button.IconButton;
280 gduche 54
import com.extjs.gxt.ui.client.widget.form.ComboBox;
55
import com.extjs.gxt.ui.client.widget.form.DateField;
276 gduche 56
import com.extjs.gxt.ui.client.widget.form.FieldSet;
352 gduche 57
import com.extjs.gxt.ui.client.widget.form.FormPanel;
293 gduche 58
import com.extjs.gxt.ui.client.widget.form.HiddenField;
276 gduche 59
import com.extjs.gxt.ui.client.widget.form.LabelField;
446 gduche 60
import com.extjs.gxt.ui.client.widget.form.Radio;
61
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
286 gduche 62
import com.extjs.gxt.ui.client.widget.form.TextArea;
276 gduche 63
import com.extjs.gxt.ui.client.widget.form.TextField;
456 gduche 64
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
276 gduche 65
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
66
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
67
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
319 gduche 68
import com.extjs.gxt.ui.client.widget.layout.FormData;
276 gduche 69
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
356 gduche 70
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
276 gduche 71
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
386 gduche 72
import com.google.gwt.core.client.GWT;
339 gduche 73
import com.google.gwt.i18n.client.DateTimeFormat;
276 gduche 74
import com.google.gwt.user.client.ui.Widget;
127 gduche 75
 
446 gduche 76
public class PersonneForm extends FormPanel implements Rafraichissable {
127 gduche 77
 
276 gduche 78
	/*--------------------------------------------------------------------------------------
79
	 * 		VARIABLES
80
	 * -------------------------------------------------------------------------------------
81
	 */
82
 
83
	private TabItem tiIdentite, tiAdresses, tiInfosNat;
283 gduche 84
	private Mediateur mediateur = Registry.get(RegistreId.MEDIATEUR);
85
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
376 gduche 86
	private Personne personneSelectionnee, personneSauvegarde = null;
456 gduche 87
	private String mode = "";
276 gduche 88
 
456 gduche 89
	public static final String MODE_AJOUTER = "AJOUT";
90
	public static final String MODE_MODIFIER = "MODIF";
91
 
92
 
376 gduche 93
	private FormBinding binding = null;
94
 
276 gduche 95
	/*--------------------------------------------------------------------------------------
96
	 * 		CONSTRUCTEUR
97
	 * -------------------------------------------------------------------------------------
98
	 */
446 gduche 99
 
276 gduche 100
	/**
101
	 * Constructeur du panneau
102
	 *
103
	 * Initialise le panneau et ajoute une barre d'outils à deux boutons (réinitialiser le
104
	 * formulaire et annuler la saisie).
105
	 *
106
	 * */
456 gduche 107
	public PersonneForm(String mode) {
108
		this.mode = mode;
386 gduche 109
		initialiserComposants();
352 gduche 110
	}
111
 
386 gduche 112
	public void initialiserComposants()	{
352 gduche 113
 
376 gduche 114
		personneSelectionnee = new Personne();
115
		personneSauvegarde = new Personne();
116
 
283 gduche 117
		initialiserPanneau();
276 gduche 118
 
356 gduche 119
		ButtonBar barreOutilsBas = new ButtonBar();
488 gduche 120
		//barreOutilsBas.setButtonAlign(HorizontalAlignment.CENTER);
121
		barreOutilsBas.setAlignment(HorizontalAlignment.CENTER);
276 gduche 122
 
352 gduche 123
		ajouterBoutonEnregistrer(barreOutilsBas);
124
		ajouterBoutonEnregistrerEtRevenir(barreOutilsBas);
125
		ajouterBoutonAnnuler(barreOutilsBas);
276 gduche 126
 
352 gduche 127
		setBottomComponent(barreOutilsBas);
276 gduche 128
 
352 gduche 129
		ToolBar barreOutilsHaut = new ToolBar();
130
		ajouterBoutonReinitialiser(barreOutilsHaut);
131
		setTopComponent(barreOutilsHaut);
338 gduche 132
 
276 gduche 133
		initialiserOnglets();
134
 
135
		creerComposantsIdentite();
293 gduche 136
		creerComposantsAdresse();
280 gduche 137
 
352 gduche 138
		layout();
338 gduche 139
 
376 gduche 140
		binderPersonne(personneSelectionnee);
276 gduche 141
	}
142
 
143
	/*---------------------------------------------------------------------------------------
144
	 * 		SOUS-METHODES
145
	 * --------------------------------------------------------------------------------------
146
	 */
147
	/**
148
	 * Inialise le panneau donné
149
	 *
150
	 * @param contentPanel le panneau à initialiser
151
	 * */
283 gduche 152
	public void initialiserPanneau()	{
276 gduche 153
 
283 gduche 154
		setCollapsible(false);
461 gduche 155
		if (this.mode.equals(MODE_AJOUTER))	{
156
			setHeading(mediateur.i18nC.personneModeAjout());
519 gduche 157
			setIcon(Images.ICONES.ajouter());
461 gduche 158
		} else 	{
159
			setHeading(mediateur.i18nC.personneModeModifier());
519 gduche 160
			setIcon(Images.ICONES.formModifier());
461 gduche 161
		}
283 gduche 162
		setButtonAlign(HorizontalAlignment.CENTER);
386 gduche 163
		setLayout(new FitLayout());
376 gduche 164
		setBodyBorder(false);
165
		setBorders(false);
166
		setPadding(0);
167
		setWidth("100%");
446 gduche 168
 
276 gduche 169
	}
170
 
171
	/**
172
	 * Crée les onglets identité, adresse et informations naturaliste
173
	 *
174
	 * */
175
	public void initialiserOnglets()	{
176
		//TabPanel
177
		TabPanel formulaireOnglets = new TabPanel();
178
 
179
		//Tab 1 : identite
461 gduche 180
		tiIdentite = new TabItem(mediateur.i18nC.personneIdentite());
276 gduche 181
		tiIdentite.setLayout(new FormLayout());
283 gduche 182
		tiIdentite.setScrollMode(Scroll.AUTO);
446 gduche 183
 
276 gduche 184
		formulaireOnglets.add(tiIdentite);
293 gduche 185
		hmIdentite.put("tiIdentite", tiIdentite);
276 gduche 186
 
187
		//Tab 2 : Adresse
461 gduche 188
		tiAdresses = new TabItem(mediateur.i18nC.adresse());
304 gduche 189
		tiAdresses.setLayout(new FormLayout());
283 gduche 190
		tiAdresses.setScrollMode(Scroll.AUTO);
446 gduche 191
 
276 gduche 192
		formulaireOnglets.add(tiAdresses);
193
 
194
		//Tab 3 : Infos Naturalistes
461 gduche 195
		tiInfosNat = new TabItem(mediateur.i18nC.personneInfoNat());
276 gduche 196
		tiInfosNat.setLayout(new FormLayout());
283 gduche 197
		tiInfosNat.setScrollMode(Scroll.AUTO);
446 gduche 198
 
276 gduche 199
		formulaireOnglets.add(tiInfosNat);
200
		add(formulaireOnglets);
201
	}
202
 
203
	/**
204
	 * Crée les widgets pour l'onglet identité
205
	 *
206
	 * */
207
 
293 gduche 208
	//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
276 gduche 209
	private HashMap<String, Widget>hmIdentite = new HashMap<String, Widget>();
293 gduche 210
	private HashMap<String, Widget>hmAdresse = new HashMap<String, Widget>();
211
	private HashMap<String, Widget>hmInfosNat = new HashMap<String, Widget>();
319 gduche 212
	private FormData fd100 = new FormData("1");
276 gduche 213
 
214
	public void creerComposantsIdentite()	{
215
 
456 gduche 216
 
376 gduche 217
			// Gestion de l'affichage en colonnes : 3 Layout container : principal, gauche & droite
276 gduche 218
			LayoutContainer left = new LayoutContainer();
219
			left.setLayout(new FormLayout());
220
			LayoutContainer right = new LayoutContainer();
221
			right.setLayout(new FormLayout());
222
 
223
			LayoutContainer main = new LayoutContainer();
519 gduche 224
 
225
			main.add(left, new ColumnData(.45));
226
			main.add(right, new ColumnData(.45));
227
 
276 gduche 228
			main.setLayout(new ColumnLayout());
519 gduche 229
			main.setHeight("100%");
230
			main.setScrollMode(Scroll.AUTO);
276 gduche 231
 
232
			// Création des champs
233
			FormLayout formLayout = new FormLayout();
234
			formLayout.setLabelAlign(LabelAlign.LEFT);
235
 
456 gduche 236
				FieldSet fsProjet = new FieldSet();
461 gduche 237
				fsProjet.setHeading(mediateur.i18nC.menuProjet());
456 gduche 238
				fsProjet.setLayout(new FormLayout());
239
 
240
					ListStore<Projet> storeProjets = new ListStore<Projet>();
241
					ComboBox cbProjets = new ComboBox<Projet>();
461 gduche 242
					cbProjets.setFieldLabel(mediateur.i18nC.personneProjet()+ " :");
243
					cbProjets.setEmptyText(mediateur.i18nC.txtListeProjetDefaut());
456 gduche 244
					cbProjets.setLabelSeparator("");
245
					cbProjets.setDisplayField("nom");
246
					cbProjets.setEditable(false);
247
					cbProjets.setTriggerAction(TriggerAction.ALL);
248
					cbProjets.setStore(storeProjets);
249
					cbProjets.setAllowBlank(false);
250
					fsProjet.add(cbProjets);
251
 
252
					hmIdentite.put("cbProjets", cbProjets);
253
 
254
					mediateur.selectionnerProjets(this);
255
 
256
				left.add(fsProjet);
257
 
258
 
376 gduche 259
				FieldSet fsNoms = new FieldSet();
260
				fsNoms.setHeading("Noms");
261
				fsNoms.setLayout(formLayout);
456 gduche 262
 
376 gduche 263
					// Nom complet : Affiché que si valeurs saisies
264
					LabelField nomComplet = new LabelField();
461 gduche 265
					nomComplet.setFieldLabel(mediateur.i18nC.personneNomComplet() +" :");
376 gduche 266
					nomComplet.hide();
267
 
268
					fsNoms.add(nomComplet);
269
					hmIdentite.put("nomComplet", nomComplet);
276 gduche 270
 
376 gduche 271
					//Préfixe
272
					ListStore<Valeur> storePrefixe = new ListStore<Valeur>();
273
					ComboBox<Valeur> cbPrefixe = new ComboBox<Valeur>();
274
					cbPrefixe.setStore(storePrefixe);
275
					cbPrefixe.setDisplayField("nom");
276
					cbPrefixe.setEmptyText("Choisissez le préfixe:");
277
					cbPrefixe.setFieldLabel("Prefix");
278
 
279
					fsNoms.add(cbPrefixe);
280
					hmIdentite.put("cbPrefixe", cbPrefixe);
281
 
282
					mediateur.obtenirListeValeurEtRafraichir(this, "prefixe");
352 gduche 283
 
376 gduche 284
					//Prénom
285
					TextField<String> tfPrenom = new TextField<String>();
286
					tfPrenom.setFieldLabel("Prénom");
287
					tfPrenom.setName("prenom");
352 gduche 288
 
376 gduche 289
					fsNoms.add(tfPrenom);
290
					hmIdentite.put("tfPrenom", tfPrenom);
352 gduche 291
 
376 gduche 292
					//Nom
293
					TextField<String> tfNom = new TextField<String>();
294
					tfNom.setFieldLabel("Nom");
456 gduche 295
					tfNom.setAllowBlank(false);
376 gduche 296
					tfNom.setName("nom");
297
 
298
					fsNoms.add(tfNom);
299
					hmIdentite.put("tfNom", tfNom);
300
 
301
					//Suffixe
302
					ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();
303
					ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();
304
					cbSuffixe.setStore(storeSuffixe);
305
					cbSuffixe.setFieldLabel("Suffixe");
306
					cbSuffixe.setDisplayField("nom");
307
					cbSuffixe.setEmptyText("Choisissez un suffixe:");
308
 
309
					fsNoms.add(cbSuffixe);
310
					hmIdentite.put("cbSuffixe", cbSuffixe);
311
 
312
					mediateur.obtenirListeValeurEtRafraichir(this, "suffixes");
352 gduche 313
 
376 gduche 314
					TextField<String> tfNomAutre = new TextField();
315
					tfNomAutre.setFieldLabel("Autres noms");
386 gduche 316
					tfNomAutre.setName("truk_nom_autre");
376 gduche 317
 
318
					fsNoms.add(tfNomAutre);
319
					hmIdentite.put("tfNomAutre", tfNomAutre);
320
 
321
					TextField<String> tfAbreviation = new TextField<String>();
322
					tfAbreviation.setFieldLabel("Abréviation");
323
					tfAbreviation.setName("abreviation");
324
 
325
					fsNoms.add(tfAbreviation);
326
					hmIdentite.put("tfAbreviation", tfAbreviation);
446 gduche 327
 
376 gduche 328
					//Abréviation autres
329
					TextField<String> tfAbreviationAutre = new TextField<String>();
330
					tfAbreviationAutre.setFieldLabel("Autres Abrév.");
331
					tfAbreviationAutre.setName("truk_abreviation_autre");
332
 
333
					fsNoms.add(tfAbreviationAutre);
334
					hmIdentite.put("tfAbreviationAutre", tfAbreviationAutre);
335
 
336
				left.add(fsNoms);
276 gduche 337
 
376 gduche 338
				formLayout = new FormLayout();
339
				formLayout.setLabelAlign(LabelAlign.LEFT);
276 gduche 340
 
376 gduche 341
				FieldSet fsNaissance = new FieldSet();
342
				fsNaissance.setHeading("Naissance");
343
				fsNaissance.setLayout(formLayout);
352 gduche 344
 
376 gduche 345
					DateField dfDateNaissance = new DateField();
346
					dfDateNaissance.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
347
					dfDateNaissance.setFieldLabel("Date");
348
					dfDateNaissance.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");
349
 
350
					fsNaissance.add(dfDateNaissance);
351
					hmIdentite.put("dfDateNaissance", dfDateNaissance);
352
 
353
					// Lieu naissance
354
					TextField<String> tfLieuNaissance = new TextField();
355
					tfLieuNaissance.setFieldLabel("Lieu");
356
					tfLieuNaissance.setName("naissance_lieu");
357
 
358
					fsNaissance.add(tfLieuNaissance);
359
					hmIdentite.put("tfLieuNaissance", tfLieuNaissance);
360
 
361
				left.add(fsNaissance);
276 gduche 362
 
376 gduche 363
				formLayout = new FormLayout();
364
				formLayout.setLabelAlign(LabelAlign.LEFT);
276 gduche 365
 
376 gduche 366
				FieldSet fsDeces = new FieldSet();
367
				fsDeces.setHeading("Décès");
368
				fsDeces.setLayout(formLayout);
446 gduche 369
 
370
					Radio rbEstDecedee = new Radio();
371
					rbEstDecedee.setBoxLabel("oui");
372
 
373
					rbEstDecedee.addListener(Events.Change, new Listener<ComponentEvent>() {
374
 
375
						public void handleEvent(ComponentEvent be) {
488 gduche 376
							if(((Radio) be.getComponent()).getValue().equals(true))	{
446 gduche 377
								((DateField) hmIdentite.get("dfDateDeces")).setVisible(true);
378
								((TextField) hmIdentite.get("tfLieuDeces")).setVisible(true);
379
							} else	{
380
								((DateField) hmIdentite.get("dfDateDeces")).setVisible(false);
381
								((TextField) hmIdentite.get("tfLieuDeces")).setVisible(false);
382
							}
456 gduche 383
						}
446 gduche 384
					});
385
 
456 gduche 386
					hmIdentite.put("rbEstDecedee", rbEstDecedee);
446 gduche 387
 
388
					Radio rbNestPasDecedee = new Radio();
389
					rbNestPasDecedee.setBoxLabel("non");
390
					rbNestPasDecedee.setValue(true);
391
 
392
					RadioGroup rbgDeces = new RadioGroup();
393
					rbgDeces.setFieldLabel("Est décédée");
394
					rbgDeces.add(rbEstDecedee);
395
					rbgDeces.add(rbNestPasDecedee);
396
 
397
					fsDeces.add(rbgDeces);
398
 
376 gduche 399
					DateField dfDateDeces = new DateField();
400
					dfDateDeces.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
401
					dfDateDeces.setFormatValue(true);
402
					dfDateDeces.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");
403
					dfDateDeces.setFieldLabel("Date");
446 gduche 404
					dfDateDeces.setVisible(false);
276 gduche 405
 
376 gduche 406
					fsDeces.add(dfDateDeces);
407
					hmIdentite.put("dfDateDeces", dfDateDeces);
446 gduche 408
 
376 gduche 409
					TextField<String> tfLieuDeces = new TextField();
410
					tfLieuDeces.setFieldLabel("Lieu");
411
					tfLieuDeces.setName("deces_lieu");
446 gduche 412
					tfLieuDeces.setVisible(false);
376 gduche 413
 
414
					fsDeces.add(tfLieuDeces);
415
					hmIdentite.put("tfLieuDeces", tfLieuDeces);
416
 
417
				left.add(fsDeces);
276 gduche 418
 
376 gduche 419
			tiIdentite.add(main);
283 gduche 420
 
376 gduche 421
				FieldSet fsContactTel = new FieldSet();
422
				fsContactTel.setHeading("Contact - Téléphones");
423
				fsContactTel.setLayout(new RowLayout());
424
 
425
				right.add(fsContactTel);
426
				hmIdentite.put("fsContactTel", fsContactTel);
427
 
428
					LayoutContainer lcTelephone = new LayoutContainer();
429
					lcTelephone.setLayout(new ColumnLayout());
430
 
431
						TextField tfTelephone = new TextField();
432
						tfTelephone.setFieldLabel("tel");
433
						lcTelephone.add(tfTelephone, new ColumnData(0.40));
434
 
435
						hmIdentite.put("tfTelephone", tfTelephone);
436
 
437
						ListStore<Valeur> storeTel = new ListStore<Valeur>();
438
						ComboBox<Valeur> cbTelephone = new ComboBox<Valeur>();
439
						cbTelephone.setDisplayField("nom");
440
						cbTelephone.setEmptyText("Choisissez:");
441
						cbTelephone.setStore(storeTel);
442
 
443
						lcTelephone.add(cbTelephone, new ColumnData(0.40));
444
						hmIdentite.put("cbTelephone", cbTelephone);
283 gduche 445
 
376 gduche 446
						mediateur.obtenirListeValeurEtRafraichir(this, "tel");
276 gduche 447
 
376 gduche 448
						IconButton bAjouter = new IconButton(ComposantClass.ICONE_AJOUTER);
449
						bAjouter.addSelectionListener(
488 gduche 450
								new SelectionListener<IconButtonEvent>() {
451
									public void componentSelected(IconButtonEvent ce) {
446 gduche 452
 
376 gduche 453
										String strTelephone = ((TextField<String>) hmIdentite.get("tfTelephone")).getValue();
454
										if ((strTelephone==null)||(strTelephone.trim().equals("")))	{
455
											MessageBox.alert("Erreur de saisie", "Vous devez saisir un numéro de téléphone", null);
456
										} else if (hmIdentite.get("tel-" + strTelephone) != null){
457
											MessageBox.alert("Erreur de saisie", "Le numéro saisi est déjà présent dans la liste", null);
458
										} else {
459
												String strValeurTypeTel = "";
460
												String idTel = "";
461
												Valeur valeurTypeTel = ((ComboBox<Valeur>) hmIdentite.get("cbTelephone")).getValue();
462
 
463
												if (valeurTypeTel != null)	{
464
													strValeurTypeTel = valeurTypeTel.getNom();
465
													idTel = valeurTypeTel.get("abreviation");
466
												}	else {
467
													strValeurTypeTel = ((ComboBox<Valeur>) hmIdentite.get("cbTelephone")).getRawValue();
468
													idTel = strValeurTypeTel;
469
												}
446 gduche 470
 
376 gduche 471
												if (strValeurTypeTel.trim().equals(""))	{
472
													MessageBox.alert("Erreur de saisie", "Vous devez saisir un type de téléphone", null);
473
												}	else {
474
													ajouterTelephone(strTelephone, strValeurTypeTel, idTel);
475
												}
476
											}
477
										}
478
									}
479
								);
276 gduche 480
 
376 gduche 481
						lcTelephone.add(bAjouter, new ColumnData(0.15));
482
 
483
						HiddenField<String> hfTelephone = new HiddenField<String>();
484
						add(hfTelephone);
485
						hmIdentite.put("hfTelephone", hfTelephone);
486
 
487
					fsContactTel.add(lcTelephone);
276 gduche 488
 
376 gduche 489
					FieldSet fsContact = new FieldSet();
490
					fsContact.setHeading("Contact - Autres");
491
					fsContact.setId("fsContact");
492
					fsContact.setLayout(new RowLayout());
276 gduche 493
 
376 gduche 494
					right.add(fsContact);
495
					hmIdentite.put("fsContact", fsContact);
276 gduche 496
 
376 gduche 497
					LabelField lfCourriel = new LabelField();
498
					lfCourriel.setText("<b>Courriels:</b>");
276 gduche 499
 
376 gduche 500
					fsContact.add(lfCourriel);
276 gduche 501
 
376 gduche 502
					LayoutContainer lcCourriel = new LayoutContainer();
503
					lcCourriel.setLayout(new ColumnLayout());
276 gduche 504
 
376 gduche 505
						TextField tfCourriel = new TextField();
506
						lcCourriel.add(tfCourriel, new ColumnData(0.80));
507
 
508
						HiddenField hfHiddenCourriel = new HiddenField();
509
						hfHiddenCourriel.setId("tfHiddenCourriel");
510
						hfHiddenCourriel.setValue("");
446 gduche 511
 
376 gduche 512
						add(hfHiddenCourriel);
513
						hmIdentite.put("hfHiddenCourriel", hfHiddenCourriel);
514
						hmIdentite.put("tfCourriel", tfCourriel);
276 gduche 515
 
376 gduche 516
						IconButton bAjouterCourriel = new IconButton(ComposantClass.ICONE_AJOUTER);
517
						bAjouterCourriel.addSelectionListener(
488 gduche 518
								new SelectionListener<IconButtonEvent>() {
376 gduche 519
 
488 gduche 520
									public void componentSelected(IconButtonEvent ce) {
376 gduche 521
 
522
										String strEmail = ((TextField<String>) hmIdentite.get("tfCourriel")).getValue();
523
										if ((strEmail==null)||(strEmail.trim().equals("")))	{
524
											MessageBox.alert("Erreur de saisie", "Vous devez saisir une adresse", null);
525
										} else if (hmIdentite.get("email-" + strEmail) != null){
526
											MessageBox.alert("Erreur de saisie", "L'adresse saisie est déjà dans la liste", null);
527
										} else {
528
 
529
											if (!strEmail.matches("(\\w+)@(\\w+\\.)(\\w+)(\\.\\w+)*"))	{
530
												MessageBox.alert("Erreur de saisie", "L'adresse n'est pas au bon format (ex: me@domain.com)", null);
531
											} else if (strEmail.length()>255){
532
												MessageBox.alert("Erreur de saisie", "L'adresse ne peut dépasser 255 caractères", null);
533
											} else {
534
												ajouterCourriel(strEmail);
535
											}
536
 
537
										}
538
 
539
 
540
									}
541
								});
276 gduche 542
 
376 gduche 543
						lcCourriel.add(bAjouterCourriel, new ColumnData(0.15));
544
 
545
					fsContact.add(lcCourriel);
276 gduche 546
 
376 gduche 547
					LayoutContainer lcCourrielContainer = new LayoutContainer(new RowLayout());
548
 
549
					fsContact.add(lcCourrielContainer);
550
					hmIdentite.put("lcCourrielContainer", lcCourrielContainer);
280 gduche 551
 
376 gduche 552
 
553
					LabelField lfUrl = new LabelField();
554
					lfUrl.setText("<b>Sites Web:</b>");
555
 
556
					fsContact.add(lfUrl);
280 gduche 557
 
376 gduche 558
					LayoutContainer lcUrl = new LayoutContainer(new ColumnLayout());
559
					hmIdentite.put("lcUrl", lcUrl);
286 gduche 560
 
386 gduche 561
					HiddenField<String> hfUrl = new HiddenField<String>();
562
					hmIdentite.put("hfUrl", hfUrl);
563
					add(hfUrl);
564
 
376 gduche 565
						TextField tfUrl = new TextField();
566
						tfUrl.setValue("http://");
286 gduche 567
 
376 gduche 568
						lcUrl.add(tfUrl, new ColumnData(0.8));
569
						hmIdentite.put("tfUrl", tfUrl);
286 gduche 570
 
376 gduche 571
						IconButton ibAjouterUrl = new IconButton(ComposantClass.ICONE_AJOUTER);
488 gduche 572
						ibAjouterUrl.addSelectionListener(new SelectionListener<IconButtonEvent>() {
376 gduche 573
 
488 gduche 574
							public void componentSelected(IconButtonEvent ce) {
293 gduche 575
 
376 gduche 576
								TextField<String> tfUrl = (TextField) hmIdentite.get("tfUrl");
577
								String strUrl = tfUrl.getValue();
293 gduche 578
 
376 gduche 579
								if ((strUrl == null)||(strUrl.trim().equals("http://"))||(strUrl.trim().equals("")))	{
580
									MessageBox.alert("Erreur de saisie", "Vous devez saisir un URL", null);
581
								} else if(hmIdentite.get("url-" + strUrl) != null)	{
582
									MessageBox.alert("Erreur de saisie", "L'url est déjà présente dans la liste.", null);
583
								}	else	{
584
									tfUrl.setValue("");
439 gduche 585
										//if (!strUrl.matches("[a-z]{3,}://[a-z0-9-]+.[.a-z0-9-]+(?::[0-9]*)?"))	{
586
										if (!strUrl.startsWith("http://"))	{
376 gduche 587
											MessageBox.alert("Erreur de saisie", "L'adresse n'est pas au bon format (ex: http://www.domain.com)", null);
588
										} else if (strUrl.length()>255){
589
											MessageBox.alert("Erreur de saisie", "L'adresse ne peut dépasser 255 caractères", null);
590
										} else {
591
											ajouterUrl(strUrl);
592
										}
593
 
293 gduche 594
								}
595
 
596
							}
376 gduche 597
						});
286 gduche 598
 
376 gduche 599
						lcUrl.add(ibAjouterUrl, new ColumnData(0.15));
600
					fsContact.add(lcUrl);
286 gduche 601
 
376 gduche 602
					LayoutContainer lcUrlContainer = new LayoutContainer(new RowLayout());
603
 
604
					fsContact.add(lcUrlContainer);
605
					hmIdentite.put("lcUrlContainer", lcUrlContainer);
606
 
607
					FieldSet fsAutresInfos = new FieldSet();
608
					fsAutresInfos.setHeading("Autres informations");
286 gduche 609
 
376 gduche 610
					formLayout = new FormLayout();
611
					formLayout.setLabelAlign(LabelAlign.LEFT);
612
					fsAutresInfos.setLayout(formLayout);
286 gduche 613
 
376 gduche 614
 
386 gduche 615
			formLayout = new FormLayout();
616
			formLayout.setLabelAlign(LabelAlign.TOP);
617
			LayoutContainer lcAutreInformations1 = new LayoutContainer(formLayout);
618
 
619
			//Civilité
620
			ListStore<Valeur> storeSexe = new ListStore<Valeur>();
621
			ComboBox<Valeur> cbSexe = new ComboBox<Valeur>();
622
			cbSexe.setStore(storeSexe);
623
			cbSexe.setFieldLabel("Sexe");
624
			cbSexe.setDisplayField("nom");
625
			cbSexe.setEmptyText("Choisissez le sexe:");
626
 
627
			lcAutreInformations1.add(cbSexe, fd100);
628
			hmIdentite.put("cbSexe", cbSexe);
629
 
630
			mediateur.obtenirListeValeurEtRafraichir(this, "sexe");
356 gduche 631
 
293 gduche 632
			//Description
633
			TextArea taDescription = new TextArea();
634
			taDescription.setEmptyText("Saisissez une description");
635
			taDescription.setFieldLabel("Description");
319 gduche 636
			taDescription.setWidth("100%");
376 gduche 637
			taDescription.setName("description");
293 gduche 638
 
386 gduche 639
			lcAutreInformations1.add(taDescription, fd100);
293 gduche 640
			hmIdentite.put("taDescription", taDescription);
641
 
386 gduche 642
			fsAutresInfos.add(lcAutreInformations1);
376 gduche 643
 
293 gduche 644
			// Logo
386 gduche 645
			LayoutContainer lcAutreInformations2 = new LayoutContainer();
646
			hmIdentite.put("lcAutreInformations2", lcAutreInformations2);
647
 
648
			LabelField lfUrlLogo = new LabelField();
649
			lfUrlLogo.setText("<b>Logo:</b>");
650
			lcAutreInformations2.add(lfUrlLogo);
651
 
652
			LayoutContainer lcUrlLogo = new LayoutContainer(new ColumnLayout());
653
			hmIdentite.put("lcUrlLogo", lcUrlLogo);
654
 
655
				TextField tfUrlLogo = new TextField();
656
				tfUrlLogo.setValue("http://");
657
 
658
				HiddenField<String> hfUrlLogo = new HiddenField<String>();
659
				hmIdentite.put("hfUrlLogo", hfUrlLogo);
660
 
661
				lcUrlLogo.add(tfUrlLogo, new ColumnData(0.8));
662
				hmIdentite.put("tfUrlLogo", tfUrlLogo);
663
 
664
				IconButton ibAjouterUrlLogo = new IconButton(ComposantClass.ICONE_AJOUTER);
488 gduche 665
				ibAjouterUrlLogo.addSelectionListener(new SelectionListener<IconButtonEvent>() {
386 gduche 666
 
488 gduche 667
					public void componentSelected(IconButtonEvent ce) {
386 gduche 668
 
669
						TextField<String> tfUrlLogo = (TextField) hmIdentite.get("tfUrlLogo");
670
						String strUrl = tfUrlLogo.getValue();
671
 
672
						if ((strUrl == null)||(strUrl.trim().equals("http://"))||(strUrl.trim().equals("")))	{
673
							MessageBox.alert("Erreur de saisie", "Vous devez saisir un URL", null);
674
						} else if(hmIdentite.get("url-" + strUrl) != null)	{
675
							MessageBox.alert("Erreur de saisie", "L'url est déjà présente dans la liste.", null);
676
						}	else	{
677
							tfUrlLogo.setValue("");
439 gduche 678
							//if (!strUrl.matches("[a-z]{3,}://[a-z0-9-]+.[.a-z0-9-]+(?::[0-9]*)?"))	{
679
							if (!strUrl.startsWith("http://"))	{
386 gduche 680
									MessageBox.alert("Erreur de saisie", "L'adresse n'est pas au bon format (ex: http://www.domain.com)", null);
681
								} else if (strUrl.length()>255){
682
									MessageBox.alert("Erreur de saisie", "L'adresse ne peut dépasser 255 caractères", null);
683
								} else {
684
									ajouterUrlLogo(strUrl);
685
								}
686
 
687
						}
688
 
689
					}
690
				});
691
 
692
				lcUrlLogo.add(ibAjouterUrlLogo, new ColumnData(0.15));
693
				lcAutreInformations2.add(lcUrlLogo);
694
 
695
			fsAutresInfos.add(lcAutreInformations2);
696
 
293 gduche 697
			TextArea taLogo = new TextArea();
698
			taLogo.setFieldLabel("Logos");
319 gduche 699
			taLogo.setWidth("100%");
293 gduche 700
			taLogo.setEmptyText("Saisissez les adresses des logos séparées par un saut de ligne");
386 gduche 701
			//fsAutresInfos.add(taLogo, fd100);
293 gduche 702
 
703
			hmIdentite.put("taLogo", taLogo);
704
 
376 gduche 705
			right.add(fsAutresInfos);
293 gduche 706
 
276 gduche 707
			// Ajout des évènements saisi
708
			KeyListener klNoms = new KeyListener()	{
709
				public void componentKeyUp(ComponentEvent ev)	{
283 gduche 710
					rafraichir(null);
280 gduche 711
				}
276 gduche 712
			};
713
 
488 gduche 714
			SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
283 gduche 715
				public void selectionChanged(SelectionChangedEvent se) {
716
						rafraichir(null);
717
					}
718
			};
719
 
319 gduche 720
			cbPrefixe.addSelectionChangedListener(selectionChange);
721
			cbPrefixe.addKeyListener(klNoms);
276 gduche 722
			tfPrenom.addKeyListener(klNoms);
723
			tfNom.addKeyListener(klNoms);
283 gduche 724
			cbSuffixe.addSelectionChangedListener(selectionChange);
276 gduche 725
 
726
	}
727
 
293 gduche 728
	public void creerComposantsAdresse()	{
729
 
730
		// Gauche
731
		LayoutContainer left = new LayoutContainer();
732
		left.setLayout(new FormLayout());
733
 
734
		// Droite
735
		LayoutContainer right = new LayoutContainer();
736
		right.setLayout(new FormLayout());
737
 
738
		// Principal
739
		LayoutContainer main = new LayoutContainer();
740
		main.setLayout(new ColumnLayout());
741
 
742
		// Ajout au principal
743
		main.add(left, new ColumnData(.49));
744
		main.add(right, new ColumnData(.49));
745
 
746
		TextField<String> tfAdresse1 = new TextField();
747
		tfAdresse1.setFieldLabel("Adresse");
376 gduche 748
		tfAdresse1.setName("adresse_01");
319 gduche 749
		left.add(tfAdresse1, fd100);
293 gduche 750
		hmAdresse.put("tfAdresse1", tfAdresse1);
751
 
752
		TextField<String> tfAdresse2 = new TextField();
753
		tfAdresse2.setFieldLabel("Complément d'adresse");
376 gduche 754
		tfAdresse2.setName("adresse_02");
319 gduche 755
		left.add(tfAdresse2, fd100);
293 gduche 756
		hmAdresse.put("tfAdresse2", tfAdresse2);
757
 
758
		ComboBox<Valeur> cbPays = new ComboBox<Valeur>();
759
		cbPays.setFieldLabel("Pays");
760
		cbPays.setDisplayField("nom");
761
		cbPays.setEmptyText("Sélectionnez le pays:");
762
 
763
		ListStore<Valeur> storePays = new ListStore<Valeur>();
764
		cbPays.setStore(storePays);
765
 
319 gduche 766
		right.add(cbPays, fd100);
293 gduche 767
		hmAdresse.put("cbPays", cbPays);
768
 
769
		SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
770
			public void selectionChanged(SelectionChangedEvent se) {
771
					// Rafraichir avec le pays sélectionné
772
					obtenirListeRegionParPays(((Valeur) se.getSelectedItem()).getAbreviation().toString());
773
 
774
				}
775
		};
776
 
777
		cbPays.addSelectionChangedListener(selectionChange);
778
 
779
 
780
		ComboBox<Valeur> cbRegion = new ComboBox<Valeur>();
781
		cbRegion.setFieldLabel("Region");
782
		cbRegion.setDisplayField("nom");
783
		cbRegion.setEmptyText("Sélectionnez la région:");
784
		cbRegion.setVisible(false);
785
 
786
		ListStore<Valeur> storeRegion = new ListStore<Valeur>();
787
		cbRegion.setStore(storeRegion);
788
 
352 gduche 789
 
319 gduche 790
		right.add(cbRegion, fd100);
293 gduche 791
		hmAdresse.put("cbRegion", cbRegion);
792
 
793
		TextField<String> tfBoitePostale = new TextField<String>();
794
		tfBoitePostale.setFieldLabel("Boite postale");
376 gduche 795
		tfBoitePostale.setName("bp");
796
 
319 gduche 797
		left.add(tfBoitePostale, fd100);
293 gduche 798
		hmAdresse.put("tfBoitePostale", tfBoitePostale);
799
 
800
		TextField<Integer> tfCodePostal = new TextField<Integer>();
801
		tfCodePostal.setFieldLabel("Code postal");
376 gduche 802
		tfCodePostal.setName("code_postal");
803
 
319 gduche 804
		right.add(tfCodePostal, fd100);
293 gduche 805
		hmAdresse.put("tfCodePostal", tfCodePostal);
806
 
807
		TextField tfVille = new TextField();
808
		tfVille.setFieldLabel("Ville");
376 gduche 809
		tfVille.setName("ville");
293 gduche 810
 
319 gduche 811
		right.add(tfVille, fd100);
293 gduche 812
		hmAdresse.put("tfVille", tfVille);
813
 
814
		// MAJ ComboBox
815
		mediateur.obtenirListeValeurEtRafraichir(this, "pays");
816
 
304 gduche 817
		FieldSet fsAdresse = new FieldSet();
818
		fsAdresse.setHeading("Adresse personnelle");
819
		fsAdresse.add(main);
293 gduche 820
 
304 gduche 821
		tiAdresses.add(fsAdresse);
352 gduche 822
		((ComboBox) hmIdentite.get("cbPrefixe")).setRawValue("ljkhlkj");
293 gduche 823
	}
338 gduche 824
 
276 gduche 825
	/**
826
	 * Ajouter le bouton réinitialiser à la barre d'outils donnée
827
	 *
828
	 * @param barreOutils la barre d'outils à modifier
829
	 * */
376 gduche 830
	public void ajouterBoutonReinitialiser(ToolBar barreOutils)	{
276 gduche 831
 
832
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
488 gduche 833
		Button reinitialiser = new Button("Réinitialiser le formulaire");
519 gduche 834
		reinitialiser.setIcon(Images.ICONES.rafraichir());
488 gduche 835
		reinitialiser.addSelectionListener(new SelectionListener<ButtonEvent>() {
836
			public void componentSelected(ButtonEvent ce) {
376 gduche 837
				//((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicAjouterPersonne();
838
				reinitialiser();
276 gduche 839
			}
840
		});
841
		barreOutils.add(reinitialiser);
842
	}
843
 
844
	/**
338 gduche 845
	 * Ajouter le bouton Sauvegarder et revenir à la liste à la barre d'outils donnée
846
	 *
847
	 * @param barreOutils la barre d'outils à modifier
848
	 * */
456 gduche 849
	private void ajouterBoutonEnregistrerEtRevenir(ButtonBar barreOutils)	{
338 gduche 850
 
851
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
356 gduche 852
		Button enregistrer = new Button("Enregistrer et revenir à la liste");
519 gduche 853
		enregistrer.setIcon(Images.ICONES.scriptGo());
854
		enregistrer.setIconAlign(IconAlign.LEFT);
488 gduche 855
		enregistrer.addSelectionListener(new SelectionListener<ButtonEvent>() {
856
			public void componentSelected(ButtonEvent ce) {
473 gduche 857
 
338 gduche 858
			}
859
		});
456 gduche 860
		enregistrer.setEnabled(false);
861
 
862
		hmIdentite.put("btnEnregistrerRevenir", enregistrer);
338 gduche 863
		barreOutils.add(enregistrer);
456 gduche 864
 
338 gduche 865
	}
866
 
867
	/**
276 gduche 868
	 * Ajouter le bouton Sauvegarder à la barre d'outils donnée
869
	 *
870
	 * @param barreOutils la barre d'outils à modifier
871
	 * */
456 gduche 872
	private void ajouterBoutonEnregistrer(ButtonBar barreOutils)	{
276 gduche 873
 
874
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
356 gduche 875
		Button enregistrer = new Button("Enregistrer");
519 gduche 876
		enregistrer.setIcon(Images.ICONES.scriptSave());
877
		enregistrer.setIconAlign(IconAlign.LEFT);
352 gduche 878
		enregistrer.setId("main-button");
488 gduche 879
		enregistrer.addSelectionListener(new SelectionListener<ButtonEvent>() {
880
			public void componentSelected(ButtonEvent ce) {
376 gduche 881
				enregistrer();
276 gduche 882
			}
883
		});
456 gduche 884
		enregistrer.setEnabled(false);
885
 
886
		hmIdentite.put("btnEnregistrer", enregistrer);
286 gduche 887
		barreOutils.add(enregistrer);
276 gduche 888
	}
889
 
890
	/**
891
	 * Ajouter le bouton annuler à la barre d'outils donnée
892
	 *
893
	 * @param barreOutils la barre d'outils à modifier
894
	 * */
356 gduche 895
	public static void ajouterBoutonAnnuler(ButtonBar barreOutils)	{
276 gduche 896
 
897
		// Le bouton annuler ne sauvegarde pas les informations et renvoie vers la page précédente
356 gduche 898
		Button annuler = new Button("Revenir à la liste");
488 gduche 899
		annuler.addSelectionListener(new SelectionListener<ButtonEvent>() {
900
			public void componentSelected(ButtonEvent ce) {
276 gduche 901
				((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
902
			}
903
		});
904
		annuler.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
905
		barreOutils.add(annuler);
906
	}
907
 
293 gduche 908
	public void obtenirListeRegionParPays(String strPays)	{
909
		mediateur.obtenirListeRegionsEtRafraichir(this, "region", strPays);
910
	}
276 gduche 911
 
912
 
293 gduche 913
 
276 gduche 914
	/*---------------------------------------------------------------------------------------
915
	 * 		RAFRAICHISSEMENT DU PANNEAU
916
	 * --------------------------------------------------------------------------------------
917
	 */
283 gduche 918
	public void rafraichir(Object nouvellesDonnees) {
386 gduche 919
 
920
 
921
 
456 gduche 922
		if (nouvellesDonnees instanceof ValeurListe) {
283 gduche 923
 
924
 
925
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
926
 
927
			// Créer une liste de valeurs
928
			List<Valeur> liste = new ArrayList<Valeur>();
929
			for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
930
				liste.add(listeValeurs.get(it.next()));
931
			}
932
 
933
			if (listeValeurs.getId().equals(config.getListeId("prefixe")))	{
934
 
319 gduche 935
				remplirCombobox("cbPrefixe", liste, "hmIdentite");
293 gduche 936
 
937
			} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) {
938
 
939
				remplirCombobox("cbSuffixe", liste, "hmIdentite");
940
 
941
			} else if (listeValeurs.getId().equals(config.getListeId("sexe"))) {
942
 
943
				remplirCombobox("cbSexe", liste, "hmIdentite");
283 gduche 944
 
293 gduche 945
			} else if (listeValeurs.getId().equals(config.getListeId("tel"))) {
946
 
947
				remplirCombobox("cbTelephone", liste, "hmIdentite");
319 gduche 948
 
949
				//Préselection du tél
950
				ComboBox<Valeur> cbTelephone = (ComboBox<Valeur>) hmIdentite.get("cbTelephone");
951
				cbTelephone.setValue(liste.get(1));
293 gduche 952
 
953
			} else if (listeValeurs.getId().equals(config.getListeId("pays")))	{
283 gduche 954
 
293 gduche 955
				remplirCombobox("cbPays", liste, "hmAdresse");
283 gduche 956
 
293 gduche 957
			} else if (listeValeurs.getId().equals(config.getListeId("region")))	{
283 gduche 958
 
293 gduche 959
				remplirCombobox("cbRegion", liste, "hmAdresse");
283 gduche 960
 
293 gduche 961
				((ComboBox) hmAdresse.get("cbRegion")).setVisible(true);
283 gduche 962
			}
293 gduche 963
 
964
 
456 gduche 965
		} else if (nouvellesDonnees instanceof ProjetListe) {
966
 
967
			ProjetListe projets = (ProjetListe) nouvellesDonnees;
968
 
969
			List<Projet> liste = new ArrayList<Projet>();
970
			for (Iterator<String> it = projets.keySet().iterator(); it.hasNext();) {
971
				liste.add(projets.get(it.next()));
972
			}
973
			ComboBox cbProjets = (ComboBox) hmIdentite.get("cbProjets");
974
			ListStore<Projet> storeProjets= cbProjets.getStore();
975
			storeProjets.removeAll();
976
			storeProjets.add(liste);
977
			cbProjets.setStore(storeProjets);
978
 
352 gduche 979
		} else if (nouvellesDonnees instanceof Information)	{
286 gduche 980
 
352 gduche 981
			Information info = (Information) nouvellesDonnees;
386 gduche 982
			if (info.getType().equals("ajout_personne"))	{
352 gduche 983
 
386 gduche 984
				GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null);
461 gduche 985
				Info.display("Enregistrement", "La personne a été ajoutée (id: " + personneSelectionnee.getId() + ")");
376 gduche 986
 
461 gduche 987
				personneSelectionnee.set("id_personne", info.toString());
519 gduche 988
				this.mode = MODE_MODIFIER;
461 gduche 989
				this.setHeading(mediateur.i18nC.personneModeModifier());
519 gduche 990
				setIcon(Images.ICONES.formModifier());
376 gduche 991
 
433 gduche 992
			} else if (info.getType().equals("modification_personne"))	{
993
 
994
				Info.display("Enregistrement", "Les modifications apportées à la personne " + personneSelectionnee.getId() + " ont été correctement enregistrées.");
995
 
386 gduche 996
			} else if (info.getDonnee(0) instanceof PersonneListe)	{
997
 
998
 
999
					Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values();
1000
					Iterator itPersonneListe = colPersonneListe.iterator();
1001
					Personne personne = (Personne) itPersonneListe.next();
376 gduche 1002
 
386 gduche 1003
					personneSauvegarde = new Personne();
1004
					personneSauvegarde = (Personne) personne.cloner(personneSauvegarde);
376 gduche 1005
 
386 gduche 1006
					binderPersonne(personne);
1007
					//Mise à jour de la personne
1008
					//Personne personne = (Personne) nouvellesDonnees;
1009
 
456 gduche 1010
					ComboBox cbProjets = (ComboBox) hmIdentite.get("cbProjets");
1011
					cbProjets.setValue(cbProjets.getStore().findModel("id_projet", personne.get("ce_projet")));
386 gduche 1012
 
1013
					//Prefixe
1014
					String prefixe = personne.get("ce_truk_prefix");
1015
					ComboBox<Valeur> cbPrefixe = (ComboBox<Valeur>) hmIdentite.get("cbPrefixe");
1016
 
1017
 
1018
					String prefixeCourant = personne.get("ce_truk_prefix");
1019
					if (cbPrefixe.getStore().findModel("id_valeur", prefixeCourant) != null)	{
1020
						cbPrefixe.setValue(cbPrefixe.getStore().findModel("id_valeur", prefixeCourant));
1021
					}	else	{
1022
						cbPrefixe.setRawValue(prefixeCourant);
376 gduche 1023
					}
1024
 
1025
 
386 gduche 1026
					((TextField) hmIdentite.get("tfPrenom")).setValue(personne.get("prenom"));
1027
					((TextField) hmIdentite.get("tfNom")).setValue(personne.get("nom"));
1028
 
1029
					//Suffixe
1030
					String suffixe = personne.get("ce_truk_suffixe");
1031
					ComboBox<Valeur> cbSuffixe = (ComboBox<Valeur>) hmIdentite.get("cbSuffixe");
1032
 
1033
					String suffixeCourant = personne.get("ce_truk_suffix");
1034
					if (cbSuffixe.getStore().findModel("id_valeur", suffixeCourant) != null)	{
1035
						cbSuffixe.setValue(cbSuffixe.getStore().findModel("id_valeur", suffixeCourant));
1036
					}	else	{
1037
						cbSuffixe.setRawValue(suffixeCourant);
1038
					}
1039
 
1040
					((TextField) hmIdentite.get("tfNomAutre")).setValue(personne.get("truk_nom_autre"));
1041
					((TextField) hmIdentite.get("tfAbreviation")).setValue(personne.get("abreviation"));
1042
					((TextField) hmIdentite.get("tfAbreviationAutre")).setValue(personne.get("truk_abreviation_autre"));
1043
 
1044
 
1045
					(((DateField) hmIdentite.get("dfDateNaissance"))).setValue(personne.getDate("naissance_date"));
1046
					((TextField) hmIdentite.get("tfLieuNaissance")).setValue(personne.get("naissance_lieu"));
1047
 
1048
					(((DateField) hmIdentite.get("dfDateDeces"))).setValue(personne.getDate("deces_date"));
1049
					((TextField) hmIdentite.get("tfLieuDeces")).setValue(personne.get("deces_lieu"));
1050
 
473 gduche 1051
 
386 gduche 1052
					// Telephone
1053
					HashMap<String, String> hmTelephone = (HashMap<String, String>) personne.getChaineDenormaliseAsMapOrList("truk_telephone");
1054
					if (hmTelephone!=null)	{
1055
 
1056
						ListStore storeTelephone = ((ComboBox) hmIdentite.get("cbTelephone")).getStore();
1057
						List lstModelsTelephone = storeTelephone.getModels();
1058
						Iterator<Valeur> itStore = lstModelsTelephone.iterator();
1059
						HashMap<String, String> hmTel = new HashMap();
1060
						while (itStore.hasNext())	{
1061
							Valeur v = itStore.next();
1062
							hmTel.put(v.getAbreviation(), v.getNom());
376 gduche 1063
						}
1064
 
386 gduche 1065
						Collection<String> colTelephone = hmTelephone.keySet();
1066
						Iterator<String> itTelephone = colTelephone.iterator();
1067
 
1068
						while (itTelephone.hasNext())	{
473 gduche 1069
							String strTelephone = itTelephone.next();
1070
							String strTypeTelephone = hmTelephone.get(strTelephone);
386 gduche 1071
							String idTel = hmTel.get(strTypeTelephone);
1072
							if (idTel == null)	{
1073
								idTel = strTypeTelephone;
1074
							}
1075
 
1076
							ajouterTelephone(strTelephone, idTel, strTypeTelephone);
1077
						}
376 gduche 1078
					}
352 gduche 1079
 
386 gduche 1080
					//Courriel
1081
					LinkedList<String> lCourriels = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_courriel");
440 gduche 1082
					if (lCourriels != null) {
1083
						Iterator<String> itCourriels = lCourriels.iterator();
386 gduche 1084
 
440 gduche 1085
						while (itCourriels.hasNext())	{
1086
							String strEmail = itCourriels.next();
1087
							ajouterCourriel(strEmail);
1088
						}
386 gduche 1089
					}
1090
 
1091
					// Sites
1092
					LinkedList<String> lUrl = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_url");
433 gduche 1093
					if (lUrl!=null) {
1094
						Iterator<String> itUrl = lUrl.iterator();
1095
						while (itUrl.hasNext())	{
1096
							String strUrl = itUrl.next();
1097
							ajouterUrl(strUrl);
1098
						}
386 gduche 1099
					}
1100
 
1101
					// Sexe
1102
					String strSexe = personne.get("ce_sexe");
1103
					ComboBox<Valeur> cbSexe = (ComboBox<Valeur>) hmIdentite.get("cbSexe");
1104
 
1105
 
1106
					//FIXME : le lien avec la bdd ne peut pas se faire
1107
					if (cbSexe.getStore().findModel("abreviation", strSexe) != null)	{
1108
						cbSexe.setValue(cbSexe.getStore().findModel("abreviation", strSexe));
352 gduche 1109
					}	else	{
386 gduche 1110
						cbSexe.setRawValue(strSexe);
352 gduche 1111
					}
386 gduche 1112
 
1113
					((TextArea) hmIdentite.get("taDescription")).setRawValue((String) personne.get("description"));
1114
 
1115
					// Logos
1116
					TextArea taLogo = (TextArea) hmIdentite.get("taLogo");
1117
					LinkedList<String> lLogo = (LinkedList<String>) personne.getChaineDenormaliseAsMapOrList("truk_logo");
433 gduche 1118
					if (lLogo!=null)	{
1119
						Iterator<String> itLogo = lLogo.iterator();
1120
						String strValeurLogo = "";
1121
						while (itLogo.hasNext())	{
473 gduche 1122
							strValeurLogo += itLogo.next();
1123
							if (!strValeurLogo.trim().equals(""))	{
1124
								ajouterUrlLogo(strValeurLogo);
1125
							}
433 gduche 1126
						}
386 gduche 1127
					}
1128
 
1129
					/*--------------------------------------------------
1130
					                      Adresse
1131
					 ---------------------------------------------------*/
1132
 
1133
					// Adresse
1134
					((TextField<String>) hmAdresse.get("tfAdresse1")).setValue((String) personne.get("adresse_01"));
1135
 
1136
					// Complément
1137
					((TextField<String>) hmAdresse.get("tfAdresse2")).setValue((String) personne.get("adresse_02"));
1138
 
1139
					//Boite postale
1140
					((TextField<String>) hmAdresse.get("tfBoitePostale")).setValue((String) personne.get("bp"));
1141
 
1142
					//Pays
1143
					String strPays = personne.get("pays");
1144
					ComboBox<Valeur> cbPays = (ComboBox<Valeur>) hmAdresse.get("cbPays");
1145
 
1146
 
1147
					if (cbPays.getStore().findModel("nom", strPays) != null)	{
1148
						cbPays.setValue(cbPays.getStore().findModel("nom", strPays));
1149
					}	else	{
1150
						cbPays.setRawValue(strPays);
1151
					}
1152
 
1153
 
1154
					//Région
1155
					String strRegion = personne.get("region");
1156
					if ((strRegion!=null)&&(!strRegion.equals("")))	{
1157
						ComboBox<Valeur> cbRegion = (ComboBox<Valeur>) hmAdresse.get("cbRegion");
1158
						cbRegion.setVisible(true);
1159
 
1160
						if (cbRegion.getStore().findModel("nom", strRegion) != null)	{
1161
							cbRegion.setValue(cbRegion.getStore().findModel("nom", strRegion));
1162
						}	else	{
1163
							cbRegion.setRawValue(strRegion);
1164
						}
1165
					}
1166
 
1167
					//Cp
1168
					((TextField) hmAdresse.get("tfCodePostal")).setValue(personne.get("code_postal"));
1169
 
1170
					//Ville
1171
					((TextField) hmAdresse.get("tfVille")).setValue(personne.get("ville"));
1172
 
1173
 
456 gduche 1174
					((Button) hmIdentite.get("btnEnregistrerRevenir")).setEnabled(true);
1175
					((Button) hmIdentite.get("btnEnregistrer")).setEnabled(true);
1176
 
461 gduche 1177
					nouvellesDonnees = null;
386 gduche 1178
				} else {
1179
					Info.display("messages", info.getMessages().toString());
352 gduche 1180
				}
293 gduche 1181
		}
283 gduche 1182
 
1183
		if (nouvellesDonnees == null)
1184
		{
319 gduche 1185
			ComboBox cb= (ComboBox) hmIdentite.get("cbPrefixe");
293 gduche 1186
 
1187
			//Met à jour le nom Complet du formulaire
283 gduche 1188
			String valeurRetour = "";
1189
 
1190
			// Prefixe
1191
			String prefixe = "";
319 gduche 1192
			Valeur valPrefixe = (Valeur) ((ComboBox) hmIdentite.get("cbPrefixe")).getValue();
283 gduche 1193
 
1194
			if (valPrefixe != null)	{
1195
				prefixe = valPrefixe.getNom();
293 gduche 1196
			} else 	{
319 gduche 1197
				prefixe =  (String) ((ComboBox) hmIdentite.get("cbPrefixe")).getRawValue();
293 gduche 1198
			}
283 gduche 1199
 
293 gduche 1200
 
283 gduche 1201
			// Prénom
1202
			String prenom = (String) ((TextField) hmIdentite.get("tfPrenom")).getValue();
1203
 
1204
			// Nom
1205
			String nom = (String) ((TextField) hmIdentite.get("tfNom")).getValue();
1206
 
1207
			// Suffixe
1208
			String suffixe = "";
1209
			Valeur valSuffixe = (Valeur) ((ComboBox) hmIdentite.get("cbSuffixe")).getValue();
1210
 
1211
			if (valSuffixe != null)	{
1212
				suffixe = valSuffixe.getNom();
293 gduche 1213
			} else 	{
1214
				suffixe =  (String) ((ComboBox) hmIdentite.get("cbSuffixe")).getRawValue();
283 gduche 1215
			}
1216
 
1217
			// Mettre à jour la valeur
1218
			valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
1219
			valeurRetour = valeurRetour.replaceAll("null", "");
1220
 
1221
			((LabelField) hmIdentite.get("nomComplet")).setValue(valeurRetour);
1222
 
1223
			if (!valeurRetour.trim().equals(""))	{
1224
				((LabelField) hmIdentite.get("nomComplet")).show();
1225
			} else {
1226
				((LabelField) hmIdentite.get("nomComplet")).hide();
1227
			}
1228
		}
338 gduche 1229
 
1230
		mediateur.masquerPopinChargement();
456 gduche 1231
 
461 gduche 1232
		if (this.mode.equals(MODE_AJOUTER))	{
456 gduche 1233
			((Button) hmIdentite.get("btnEnregistrerRevenir")).setEnabled(true);
1234
			((Button) hmIdentite.get("btnEnregistrer")).setEnabled(true);
1235
		}
127 gduche 1236
	}
1237
 
352 gduche 1238
	private HashMap<String, Valeur> hmCbSelectionnee = new HashMap();
293 gduche 1239
	public void remplirCombobox(String idComboBox, List liste, String hashMapId)	{
352 gduche 1240
 
293 gduche 1241
		HashMap hm = null;
1242
		if (hashMapId.equals("hmIdentite"))	{
1243
			hm = hmIdentite;
1244
		} else if (hashMapId.equals("hmAdresse")){
1245
			hm = hmAdresse;
1246
		} else {
1247
			hm = hmInfosNat;
1248
		}
1249
 
1250
		ListStore<Valeur> store = ((ComboBox) hm.get(idComboBox)).getStore();
376 gduche 1251
 
293 gduche 1252
		store.removeAll();
1253
		store.add(liste);
1254
		((ComboBox) hm.get(idComboBox)).setStore(store);
376 gduche 1255
 
293 gduche 1256
	}
130 gduche 1257
 
352 gduche 1258
 
376 gduche 1259
	public void ajouterTelephone(String strTelephone, String strValeurTypeTel, String idTel) 	{
352 gduche 1260
 
1261
 
1262
				//Ajout d'un champ à la liste
376 gduche 1263
				String strIdTelephone =  idTel + "##" + strTelephone + ";;";
352 gduche 1264
 
1265
				FieldSet fsContactTel = (FieldSet) hmIdentite.get("fsContactTel");
1266
 
356 gduche 1267
				LayoutContainer lcTelephone = new LayoutContainer();
1268
				lcTelephone.setLayout(new ColumnLayout());
1269
 
352 gduche 1270
				Text tTypeTelephone = new Text();
1271
				tTypeTelephone.setText(strValeurTypeTel+":");
1272
 
376 gduche 1273
				hmIdentite.put("type-" + strIdTelephone, tTypeTelephone);
356 gduche 1274
				lcTelephone.add(tTypeTelephone, new ColumnData(0.40));
352 gduche 1275
 
1276
				Text tTelephone = new Text();
1277
				tTelephone.setText(strTelephone);
376 gduche 1278
				hmIdentite.put("tel-" + strIdTelephone, tTelephone);
356 gduche 1279
				lcTelephone.add(tTelephone, new ColumnData(0.40));
352 gduche 1280
 
1281
				IconButton bSupprimer = new IconButton(ComposantClass.ICONE_SUPPRIMER);
376 gduche 1282
				bSupprimer.setId(strIdTelephone);
352 gduche 1283
 
488 gduche 1284
				bSupprimer.addSelectionListener(new SelectionListener<IconButtonEvent>() {
1285
						public void componentSelected(IconButtonEvent ce) {
352 gduche 1286
 
488 gduche 1287
							String strIdTelephone = ce.getComponent().getId();
376 gduche 1288
							LayoutContainer lcContactTel = (LayoutContainer) hmIdentite.get("lc-"+strIdTelephone);
352 gduche 1289
 
376 gduche 1290
							lcContactTel.remove(hmIdentite.get("type-" + strIdTelephone));
1291
							hmIdentite.remove("type-" + strIdTelephone);
352 gduche 1292
 
376 gduche 1293
							lcContactTel.remove(hmIdentite.get("tel-" + strIdTelephone));
1294
							hmIdentite.remove("tel-" + strIdTelephone);
352 gduche 1295
 
488 gduche 1296
							lcContactTel.remove(ce.getComponent());
352 gduche 1297
 
356 gduche 1298
							FieldSet fsContactTel = (FieldSet) hmIdentite.get("fsContactTel");
1299
							fsContactTel.remove(lcContactTel);
1300
 
376 gduche 1301
							HiddenField<String> hfTelephone = (HiddenField) hmIdentite.get("hfTelephone");
1302
							String strValeurTelephone = hfTelephone.getValue();
1303
							strValeurTelephone = strValeurTelephone.replace(strIdTelephone, "");
1304
							hfTelephone.setValue(strValeurTelephone);
1305
 
352 gduche 1306
							layout();
1307
 
1308
						}
1309
				});
1310
 
356 gduche 1311
				lcTelephone.add(bSupprimer, new ColumnData(0.15));
352 gduche 1312
 
376 gduche 1313
				hmIdentite.put("lc-"+strIdTelephone, lcTelephone);
356 gduche 1314
				fsContactTel.add(lcTelephone);
1315
 
376 gduche 1316
				HiddenField<String> hfTelephone = (HiddenField) hmIdentite.get("hfTelephone");
1317
				String strValeurTelephone = hfTelephone.getValue();
1318
				if (strValeurTelephone==null)	{
1319
					strValeurTelephone = "";
1320
				}
1321
				strValeurTelephone += strIdTelephone;
1322
				hfTelephone.setValue(strValeurTelephone);
352 gduche 1323
 
1324
				layout();
1325
 
1326
 
1327
 
1328
 
1329
	}
1330
 
376 gduche 1331
	public void ajouterCourriel(String strEmail)	{
1332
 
1333
			TextField<String> tfCourriel = (TextField<String>) hmIdentite.get("tfCourriel");
1334
			tfCourriel.setValue("");
1335
 
1336
			//Ajouter adresse email
1337
			LayoutContainer lcCourrielContainer = (LayoutContainer) hmIdentite.get("lcCourrielContainer");
1338
 
1339
			LayoutContainer lcCourriel = new LayoutContainer();
1340
			lcCourriel.setLayout(new ColumnLayout());
1341
 
1342
			LabelField lfCourriel = new LabelField();
1343
			lfCourriel.setText(strEmail);
1344
 
1345
			lcCourriel.add(lfCourriel, new ColumnData(0.8));
1346
			hmIdentite.put("lc-" + strEmail, lcCourriel);
1347
 
1348
			//Bouton supprimer
1349
			IconButton btnSupprimerCourriel = new IconButton(ComposantClass.ICONE_SUPPRIMER);
1350
			btnSupprimerCourriel.setId(strEmail);
488 gduche 1351
			btnSupprimerCourriel.addSelectionListener(new SelectionListener<IconButtonEvent>() {
376 gduche 1352
 
488 gduche 1353
				public void componentSelected(IconButtonEvent ce) {
376 gduche 1354
					//Suppression de l'adresse email
488 gduche 1355
					String strEmail = ce.getComponent().getId();
376 gduche 1356
					LayoutContainer lcCourrielContainer = (LayoutContainer) hmIdentite.get("lcCourrielContainer");
1357
					LayoutContainer lcCourriel = (LayoutContainer) hmIdentite.get("lc-" + strEmail);
1358
					lcCourrielContainer.remove(lcCourriel);
1359
 
1360
					hmIdentite.remove("lc-" + strEmail);
1361
					hmIdentite.remove("email-" + strEmail);
1362
 
1363
						HiddenField<String> hfHiddenCourriel = (HiddenField) hmIdentite.get("hfHiddenCourriel");
1364
					String strValeurCourriel = hfHiddenCourriel.getValue();
1365
					strValeurCourriel = strValeurCourriel.replace(strEmail + ";;", "");
1366
					hfHiddenCourriel.setValue(strValeurCourriel);
1367
 
1368
				}
1369
 
1370
			});
1371
 
1372
			lcCourriel.add(btnSupprimerCourriel);
1373
 
1374
 
1375
 
1376
			lcCourrielContainer.add(lcCourriel);
1377
			hmIdentite.put("email-" + strEmail, lfCourriel);
1378
 
1379
			HiddenField<String> hfHiddenCourriel = (HiddenField) hmIdentite.get("hfHiddenCourriel");
1380
			String strHiddenCourrielValue = hfHiddenCourriel.getValue();
1381
			if (strHiddenCourrielValue == null) {
1382
				strHiddenCourrielValue = "";
1383
			}
1384
			hfHiddenCourriel.setRawValue(strHiddenCourrielValue + strEmail + ";;");
1385
 
1386
 
1387
			layout();
1388
 
1389
	}
1390
 
1391
	public void ajouterUrl(String strUrl)	{
1392
 
1393
		LayoutContainer lcUrlContainer  = (LayoutContainer) hmIdentite.get("lcUrlContainer");
1394
 
1395
		LayoutContainer lcUrl = new LayoutContainer();
1396
		lcUrl.setLayout(new ColumnLayout());
1397
		hmIdentite.put("lc-" + strUrl, lcUrl);
1398
 
1399
 
1400
		Text tUrl = new Text(strUrl);
1401
		hmIdentite.put("url-"+strUrl, tUrl);
1402
 
1403
		lcUrl.add(tUrl, new ColumnData(0.8));
1404
 
1405
		IconButton ibSupprimerUrl = new IconButton(ComposantClass.ICONE_SUPPRIMER);
1406
		ibSupprimerUrl.setId(strUrl);
488 gduche 1407
		ibSupprimerUrl.addSelectionListener(new SelectionListener<IconButtonEvent>() {
130 gduche 1408
 
488 gduche 1409
			public void componentSelected(IconButtonEvent ce) {
376 gduche 1410
 
1411
				//Suppression url
488 gduche 1412
				String strUrl = ce.getComponent().getId();
376 gduche 1413
				LayoutContainer lcUrl = (LayoutContainer) hmIdentite.get("lc-" + strUrl);
1414
				LayoutContainer lcUrlContainer  = (LayoutContainer) hmIdentite.get("lcUrlContainer");
1415
 
1416
				lcUrlContainer.remove(lcUrl);
1417
 
386 gduche 1418
 
1419
				HiddenField<String> hfUrl = (HiddenField<String>) hmIdentite.get("hfUrl");
1420
				String strValeurUrl = hfUrl.getValue();
1421
				strValeurUrl = strValeurUrl.replace(strUrl, "");
1422
				hfUrl.setValue(strValeurUrl);
1423
 
376 gduche 1424
			}
1425
		});
1426
 
1427
		lcUrl.add(ibSupprimerUrl, new ColumnData(0.15));
1428
		lcUrlContainer.add(lcUrl);
1429
 
386 gduche 1430
		HiddenField<String> hfUrl = (HiddenField<String>) hmIdentite.get("hfUrl");
1431
		String strValeurUrl = hfUrl.getValue();
1432
		if (strValeurUrl == null)	{
1433
			strValeurUrl = "";
1434
		}
1435
 
1436
		strValeurUrl += strUrl + ";;";
1437
		hfUrl.setValue(strValeurUrl);
1438
 
376 gduche 1439
		layout();
1440
 
1441
 
1442
 
1443
	}
1444
 
386 gduche 1445
	public void ajouterUrlLogo(String strUrl)	{
1446
 
1447
		LayoutContainer lcUrlContainer  = (LayoutContainer) hmIdentite.get("lcAutreInformations2");
1448
 
1449
		LayoutContainer lcUrl = new LayoutContainer();
1450
		lcUrl.setLayout(new ColumnLayout());
1451
		hmIdentite.put("lc-" + strUrl, lcUrl);
1452
 
1453
 
1454
		Text tUrl = new Text(strUrl);
1455
		hmIdentite.put("url-"+strUrl, tUrl);
1456
 
1457
		lcUrl.add(tUrl, new ColumnData(0.8));
1458
 
1459
		IconButton ibSupprimerUrl = new IconButton(ComposantClass.ICONE_SUPPRIMER);
1460
		ibSupprimerUrl.setId(strUrl);
488 gduche 1461
		ibSupprimerUrl.addSelectionListener(new SelectionListener<IconButtonEvent>() {
386 gduche 1462
 
488 gduche 1463
			public void componentSelected(IconButtonEvent ce) {
386 gduche 1464
 
1465
				//Suppression url
488 gduche 1466
				String strUrl = ce.getComponent().getId();
386 gduche 1467
				LayoutContainer lcUrl = (LayoutContainer) hmIdentite.get("lc-" + strUrl);
1468
				LayoutContainer lcUrlContainer  = (LayoutContainer) hmIdentite.get("lcAutreInformations2");
1469
 
1470
				lcUrlContainer.remove(lcUrl);
1471
 
1472
				HiddenField<String> hfUrlLogo = (HiddenField<String>) hmIdentite.get("hfUrlLogo");
1473
				String strValeurUrl = hfUrlLogo.getValue();
1474
				strValeurUrl = strUrl.replace(strUrl, "");
1475
 
1476
				hfUrlLogo.setValue(strValeurUrl);
1477
			}
1478
		});
1479
 
1480
		lcUrl.add(ibSupprimerUrl, new ColumnData(0.15));
1481
		lcUrlContainer.add(lcUrl);
1482
 
1483
		HiddenField<String> hfUrlLogo = (HiddenField<String>) hmIdentite.get("hfUrlLogo");
1484
		String strValeurUrl = hfUrlLogo.getValue();
1485
		if (strValeurUrl == null)	{
1486
			strValeurUrl = "";
1487
		}
1488
 
1489
		strValeurUrl += strUrl + ";;";
1490
 
1491
		hfUrlLogo.setValue(strValeurUrl);
1492
 
1493
		layout();
1494
	}
1495
 
376 gduche 1496
	public void reinitialiser()	{
1497
 
461 gduche 1498
		mediateur.afficherPopinChargement();
376 gduche 1499
 
1500
		binderPersonne(personneSauvegarde);
1501
		layout();
1502
 
1503
		mediateur.masquerPopinChargement();
1504
	}
1505
 
1506
 
1507
 
1508
	public void binderPersonne(Personne personne)	{
1509
 
1510
		binding = new FormBinding(this);
1511
 
1512
		personneSelectionnee = personne;
1513
		binding.autoBind();
1514
		binding.bind(personneSelectionnee);
1515
 
1516
		layout();
1517
	}
130 gduche 1518
 
376 gduche 1519
	/**
1520
	 * Enregistre les information de la personne en cours
1521
	 *
1522
	 */
1523
	public void enregistrer()	{
1524
 
1525
		LinkedList lstMessageErreur = new LinkedList<String>();
1526
 
456 gduche 1527
		ComboBox<Projet> cbProjets = (ComboBox<Projet>) hmIdentite.get("cbProjets");
1528
		Projet projet = cbProjets.getValue();
1529
		if (projet == null)	{
1530
			lstMessageErreur.add("Le projet n'a pas été renseigné");
1531
		}
461 gduche 1532
 
1533
		String strTfNom = ((TextField<String>) hmIdentite.get("tfNom")).getValue();
1534
		if ((strTfNom == null)||(strTfNom.trim().equals("")))	{
1535
			lstMessageErreur.add("Le nom n'a pas été saisi");
1536
		}
456 gduche 1537
 
1538
 
376 gduche 1539
		//Préparer les données
1540
		ComboBox combo = (ComboBox) hmIdentite.get("cbSexe");
1541
		Valeur valeur;
1542
		String strValeur = "";
1543
 
1544
		if (combo.getValue()!=null)	{
1545
			valeur = (Valeur) combo.getValue();
1546
			strValeur = valeur.getId();
1547
		}
1548
 
1549
		if (!strValeur.trim().equals(""))	{
1550
			personneSelectionnee.set("sexe", strValeur);
461 gduche 1551
		}
376 gduche 1552
 
1553
		strValeur = obtenirValeurCombo("cbPrefixe");
1554
		personneSelectionnee.set("ce_truk_prefix", strValeur);
1555
 
1556
		strValeur = obtenirValeurCombo("cbSuffixe");
1557
		personneSelectionnee.set("ce_truk_suffix", strValeur);
1558
 
1559
		personneSelectionnee.set("truk_courriel", ((HiddenField<String>) hmIdentite.get("hfHiddenCourriel")).getValue());
1560
 
386 gduche 1561
 
1562
		//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
1563
		String strPrefixe = "";
1564
		combo = (ComboBox) hmIdentite.get("cbPrefixe");
1565
		valeur = (Valeur) combo.getValue();
1566
		if (valeur != null)	{
1567
			strPrefixe = valeur.getNom();
1568
		} else {
1569
			strPrefixe = combo.getRawValue();
1570
		}
1571
 
1572
		String strSuffixe = "";
1573
		combo = (ComboBox) hmIdentite.get("cbSuffixe");
1574
		valeur = (Valeur) combo.getValue();
1575
		if (valeur != null)	{
456 gduche 1576
			strSuffixe = valeur.getNom() + " ";
386 gduche 1577
		} else {
456 gduche 1578
			strSuffixe = combo.getRawValue() +" ";
386 gduche 1579
		}
376 gduche 1580
 
456 gduche 1581
		personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe);
376 gduche 1582
 
1583
 
456 gduche 1584
		DateField dfDateNaissance = (DateField) hmIdentite.get("dfDateNaissance");
1585
		Date naissanceDate = dfDateNaissance.getValue();
1586
		personneSelectionnee.setNaissanceDate(naissanceDate);
376 gduche 1587
 
456 gduche 1588
		Radio rbEstDecedee = (Radio) hmIdentite.get("rbEstDecedee");
1589
		if (rbEstDecedee.getValue().equals(true))	{
1590
 
1591
			DateField dfDecesDate = (DateField) hmIdentite.get("dfDateDeces");
1592
			Date decesDate = dfDecesDate.getValue();
1593
			if (decesDate == null)	{
1594
				decesDate = new Date();
1595
			}
1596
			personneSelectionnee.setDecesDate(decesDate);
1597
			personneSelectionnee.set("deces_lieu", ((TextField<String>) hmIdentite.get("tfLieuDeces")).getValue());
1598
		}
1599
 
1600
		personneSelectionnee.setDecesDate(new Date());
1601
 
376 gduche 1602
		strValeur = obtenirValeurCombo("cbPays");
1603
		personneSelectionnee.set("pays", strValeur);
1604
 
1605
		strValeur = obtenirValeurCombo("cbRegion");
1606
		personneSelectionnee.set("region", strValeur);
1607
 
1608
		personneSelectionnee.set("truk_telephone", ((HiddenField<String>) hmIdentite.get("hfTelephone")).getValue());
1609
 
386 gduche 1610
		String logoUrls = ((HiddenField<String>) hmIdentite.get("hfUrlLogo")).getValue();
1611
		if (logoUrls == null)	{
1612
			logoUrls = "";
1613
		}
1614
		personneSelectionnee.set("truk_logo", logoUrls);
376 gduche 1615
 
386 gduche 1616
		personneSelectionnee.set("truk_url", ((HiddenField) hmIdentite.get("hfUrl")).getValue());
376 gduche 1617
 
461 gduche 1618
		if (lstMessageErreur.size() == 0)	{
386 gduche 1619
			mediateur.enregistrerPersonne(this, personneSelectionnee);
456 gduche 1620
		} else {
1621
			String strMessagesErreur = "<span><br />";
386 gduche 1622
			Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
1623
			while (itMessagesErreur.hasNext())	{
456 gduche 1624
				strMessagesErreur += "<br /> - " + itMessagesErreur.next();
386 gduche 1625
			}
456 gduche 1626
			strMessagesErreur += "</span>";
386 gduche 1627
 
1628
 			MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
456 gduche 1629
		}
376 gduche 1630
	}
1631
 
1632
	private String obtenirValeurCombo(String strComboName)	{
1633
 
1634
		String strValeur = "";
1635
		Valeur valeur;
1636
 
1637
		ComboBox combo = (ComboBox) hmIdentite.get(strComboName);
1638
		if (combo == null)	{
1639
			combo = (ComboBox) hmAdresse.get(strComboName);
1640
		}
1641
		if (combo.getValue()!=null)	{
1642
			valeur = (Valeur) combo.getValue();
1643
			strValeur = valeur.getId();
1644
		} else {
1645
			strValeur = combo.getRawValue();
1646
		}
1647
 
1648
		return strValeur;
1649
	}
127 gduche 1650
}