Subversion Repositories eFlore/Applications.coel

Rev

Rev 668 | Rev 678 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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