Subversion Repositories eFlore/Applications.coel

Rev

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