Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 293 Rev 304
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.Date;
4
import java.util.Date;
5
import java.util.HashMap;
5
import java.util.HashMap;
6
import java.util.Iterator;
6
import java.util.Iterator;
7
import java.util.List;
7
import java.util.List;
8
 
8
 
9
import org.tela_botanica.client.ComposantClass;
9
import org.tela_botanica.client.ComposantClass;
10
import org.tela_botanica.client.Mediateur;
10
import org.tela_botanica.client.Mediateur;
11
import org.tela_botanica.client.RegistreId;
11
import org.tela_botanica.client.RegistreId;
12
import org.tela_botanica.client.interfaces.Rafraichissable;
12
import org.tela_botanica.client.interfaces.Rafraichissable;
13
import org.tela_botanica.client.modeles.Configuration;
13
import org.tela_botanica.client.modeles.Configuration;
14
import org.tela_botanica.client.modeles.InterneValeur;
14
import org.tela_botanica.client.modeles.InterneValeur;
15
 
15
 
16
import org.tela_botanica.client.modeles.Personne;
16
import org.tela_botanica.client.modeles.Personne;
17
import org.tela_botanica.client.modeles.Valeur;
17
import org.tela_botanica.client.modeles.Valeur;
18
import org.tela_botanica.client.modeles.ValeurListe;
18
import org.tela_botanica.client.modeles.ValeurListe;
19
 
19
 
20
 
20
 
21
import com.extjs.gxt.ui.client.Registry;
21
import com.extjs.gxt.ui.client.Registry;
22
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
22
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
23
import com.extjs.gxt.ui.client.Style.Scroll;
23
import com.extjs.gxt.ui.client.Style.Scroll;
24
import com.extjs.gxt.ui.client.event.ComponentEvent;
24
import com.extjs.gxt.ui.client.event.ComponentEvent;
25
import com.extjs.gxt.ui.client.event.KeyListener;
25
import com.extjs.gxt.ui.client.event.KeyListener;
26
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
26
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
27
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
27
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
28
import com.extjs.gxt.ui.client.event.SelectionListener;
28
import com.extjs.gxt.ui.client.event.SelectionListener;
29
import com.extjs.gxt.ui.client.store.ListStore;
29
import com.extjs.gxt.ui.client.store.ListStore;
30
import com.extjs.gxt.ui.client.widget.ContentPanel;
30
import com.extjs.gxt.ui.client.widget.ContentPanel;
31
import com.extjs.gxt.ui.client.widget.LayoutContainer;
31
import com.extjs.gxt.ui.client.widget.LayoutContainer;
32
import com.extjs.gxt.ui.client.widget.TabItem;
32
import com.extjs.gxt.ui.client.widget.TabItem;
33
import com.extjs.gxt.ui.client.widget.TabPanel;
33
import com.extjs.gxt.ui.client.widget.TabPanel;
34
import com.extjs.gxt.ui.client.widget.Text;
34
import com.extjs.gxt.ui.client.widget.Text;
35
 
35
 
36
import com.extjs.gxt.ui.client.widget.button.Button;
36
import com.extjs.gxt.ui.client.widget.button.Button;
37
import com.extjs.gxt.ui.client.widget.form.ComboBox;
37
import com.extjs.gxt.ui.client.widget.form.ComboBox;
38
import com.extjs.gxt.ui.client.widget.form.DateField;
38
import com.extjs.gxt.ui.client.widget.form.DateField;
39
import com.extjs.gxt.ui.client.widget.form.FieldSet;
39
import com.extjs.gxt.ui.client.widget.form.FieldSet;
40
import com.extjs.gxt.ui.client.widget.form.HiddenField;
40
import com.extjs.gxt.ui.client.widget.form.HiddenField;
41
import com.extjs.gxt.ui.client.widget.form.LabelField;
41
import com.extjs.gxt.ui.client.widget.form.LabelField;
42
import com.extjs.gxt.ui.client.widget.form.TextArea;
42
import com.extjs.gxt.ui.client.widget.form.TextArea;
43
import com.extjs.gxt.ui.client.widget.form.TextField;
43
import com.extjs.gxt.ui.client.widget.form.TextField;
44
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
44
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
45
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
45
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
46
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
46
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
47
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
47
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
48
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
48
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
49
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
49
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
50
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
50
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
51
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
51
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
52
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
52
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
53
import com.google.gwt.user.client.Window;
53
import com.google.gwt.user.client.Window;
54
import com.google.gwt.user.client.ui.Widget;
54
import com.google.gwt.user.client.ui.Widget;
55
 
55
 
56
 
56
 
57
 
57
 
58
public class FormPersonneVue extends ContentPanel implements Rafraichissable {
58
public class FormPersonneVue extends ContentPanel implements Rafraichissable {
59
	
59
	
60
	
60
	
61
	/*--------------------------------------------------------------------------------------
61
	/*--------------------------------------------------------------------------------------
62
	 * 		VARIABLES
62
	 * 		VARIABLES
63
	 * -------------------------------------------------------------------------------------
63
	 * -------------------------------------------------------------------------------------
64
	 */
64
	 */
65
	
65
	
66
	private TabItem tiIdentite, tiAdresses, tiInfosNat;
66
	private TabItem tiIdentite, tiAdresses, tiInfosNat;
67
	private Mediateur mediateur = Registry.get(RegistreId.MEDIATEUR);
67
	private Mediateur mediateur = Registry.get(RegistreId.MEDIATEUR);
68
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
68
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
69
	private Personne personneSelectionnee = null;
69
	private Personne personneSelectionnee = null;
70
	
70
	
71
	/*--------------------------------------------------------------------------------------
71
	/*--------------------------------------------------------------------------------------
72
	 * 		CONSTRUCTEUR 
72
	 * 		CONSTRUCTEUR 
73
	 * -------------------------------------------------------------------------------------
73
	 * -------------------------------------------------------------------------------------
74
	 */
74
	 */
75
	/**
75
	/**
76
	 * Constructeur du panneau
76
	 * Constructeur du panneau
77
	 * 
77
	 * 
78
	 * Initialise le panneau et ajoute une barre d'outils à deux boutons (réinitialiser le 
78
	 * Initialise le panneau et ajoute une barre d'outils à deux boutons (réinitialiser le 
79
	 * formulaire et annuler la saisie). 
79
	 * formulaire et annuler la saisie). 
80
	 * 
80
	 * 
81
	 * */
81
	 * */
82
	public FormPersonneVue() {
82
	public FormPersonneVue() {
83
		
83
		
84
		initialiserPanneau();
84
		initialiserPanneau();
85
		
85
		
86
		ToolBar barreOutils = new ToolBar();
86
		ToolBar barreOutils = new ToolBar();
87
		
87
		
88
		ajouterBoutonEnregistrer(barreOutils);
88
		ajouterBoutonEnregistrer(barreOutils);
89
		ajouterBoutonReinitialiser(barreOutils);
89
		ajouterBoutonReinitialiser(barreOutils);
90
		ajouterBoutonAnnuler(barreOutils);
90
		ajouterBoutonAnnuler(barreOutils);
91
		
91
		
92
		setTopComponent(barreOutils);
92
		setTopComponent(barreOutils);
93
		
93
		
94
		initialiserOnglets();	
94
		initialiserOnglets();	
95
		
95
		
96
		creerComposantsIdentite();
96
		creerComposantsIdentite();
97
		creerComposantsAdresse();
97
		creerComposantsAdresse();
98
		
98
		
99
	}
99
	}
100
	
100
	
101
	
101
	
102
	/*---------------------------------------------------------------------------------------
102
	/*---------------------------------------------------------------------------------------
103
	 * 		SOUS-METHODES
103
	 * 		SOUS-METHODES
104
	 * --------------------------------------------------------------------------------------
104
	 * --------------------------------------------------------------------------------------
105
	 */
105
	 */
106
	/**
106
	/**
107
	 * Inialise le panneau donné
107
	 * Inialise le panneau donné
108
	 * 
108
	 * 
109
	 * @param contentPanel le panneau à initialiser
109
	 * @param contentPanel le panneau à initialiser
110
	 * */
110
	 * */
111
	public void initialiserPanneau()	{
111
	public void initialiserPanneau()	{
112
		
112
		
113
		setLayout(new FitLayout());
113
		setLayout(new FitLayout());
114
		setIconStyle("icone-form-ajouter");  
114
		setIconStyle("icone-form-ajouter");  
115
		setCollapsible(false);  
115
		setCollapsible(false);  
116
		setHeading("Ajouter une personne");
116
		setHeading("Ajouter une personne");
117
		setButtonAlign(HorizontalAlignment.CENTER);  
117
		setButtonAlign(HorizontalAlignment.CENTER);  
118
		setLayout(new FormLayout());
118
		setLayout(new FormLayout());
119
	}
119
	}
120
	
120
	
121
	/**
121
	/**
122
	 * Crée les onglets identité, adresse et informations naturaliste
122
	 * Crée les onglets identité, adresse et informations naturaliste
123
	 * 
123
	 * 
124
	 * */
124
	 * */
125
	public void initialiserOnglets()	{
125
	public void initialiserOnglets()	{
126
		//TabPanel
126
		//TabPanel
127
		TabPanel formulaireOnglets = new TabPanel();
127
		TabPanel formulaireOnglets = new TabPanel();
128
		
128
		
129
		//Tab 1 : identite
129
		//Tab 1 : identite
130
		tiIdentite = new TabItem("Identité");
130
		tiIdentite = new TabItem("Identité");
131
		tiIdentite.setLayout(new FormLayout());
131
		tiIdentite.setLayout(new FormLayout());
132
		tiIdentite.setScrollMode(Scroll.AUTO);
132
		tiIdentite.setScrollMode(Scroll.AUTO);
133
		formulaireOnglets.add(tiIdentite);
133
		formulaireOnglets.add(tiIdentite);
134
		
134
		
135
		hmIdentite.put("tiIdentite", tiIdentite);
135
		hmIdentite.put("tiIdentite", tiIdentite);
136
		
136
		
137
		
137
		
138
		//Tab 2 : Adresse
138
		//Tab 2 : Adresse
139
		tiAdresses = new TabItem("Adresse");
139
		tiAdresses = new TabItem("Adresse");
140
		tiAdresses.setLayout(new FlowLayout());
140
		tiAdresses.setLayout(new FormLayout());
141
		tiAdresses.setScrollMode(Scroll.AUTO);
141
		tiAdresses.setScrollMode(Scroll.AUTO);
142
		formulaireOnglets.add(tiAdresses);
142
		formulaireOnglets.add(tiAdresses);
143
		
143
		
144
		//Tab 3 : Infos Naturalistes
144
		//Tab 3 : Infos Naturalistes
145
		tiInfosNat = new TabItem("Informations Naturalistes");
145
		tiInfosNat = new TabItem("Informations Naturalistes");
146
		tiInfosNat.setLayout(new FormLayout());
146
		tiInfosNat.setLayout(new FormLayout());
147
		tiInfosNat.setScrollMode(Scroll.AUTO);
147
		tiInfosNat.setScrollMode(Scroll.AUTO);
148
		formulaireOnglets.add(tiInfosNat);
148
		formulaireOnglets.add(tiInfosNat);
149
		
149
		
150
		add(formulaireOnglets);
150
		add(formulaireOnglets);
151
	}
151
	}
152
	
152
	
153
	/**
153
	/**
154
	 * Crée les widgets pour l'onglet identité
154
	 * Crée les widgets pour l'onglet identité
155
	 * 
155
	 * 
156
	 * */
156
	 * */
157
	
157
	
158
	//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
158
	//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
159
	private HashMap<String, Widget>hmIdentite = new HashMap<String, Widget>();
159
	private HashMap<String, Widget>hmIdentite = new HashMap<String, Widget>();
160
	private HashMap<String, Widget>hmAdresse = new HashMap<String, Widget>();
160
	private HashMap<String, Widget>hmAdresse = new HashMap<String, Widget>();
161
	private HashMap<String, Widget>hmInfosNat = new HashMap<String, Widget>();
161
	private HashMap<String, Widget>hmInfosNat = new HashMap<String, Widget>();
162
	
162
	
163
	public void creerComposantsIdentite()	{
163
	public void creerComposantsIdentite()	{
164
		
164
		
165
		// Gestion de l'affichage en colonnes
165
		// Gestion de l'affichage en colonnes
166
			// On crée 3 Layout container : un principal, un pour la colonne de gauche, un pour la colonne de droite
166
			// On crée 3 Layout container : un principal, un pour la colonne de gauche, un pour la colonne de droite
167
		
167
		
168
			// Gauche
168
			// Gauche
169
			LayoutContainer left = new LayoutContainer();
169
			LayoutContainer left = new LayoutContainer();
170
			left.setLayout(new FormLayout());
170
			left.setLayout(new FormLayout());
171
			
171
			
172
			// Droite
172
			// Droite
173
			LayoutContainer right = new LayoutContainer();
173
			LayoutContainer right = new LayoutContainer();
174
			right.setLayout(new FormLayout());
174
			right.setLayout(new FormLayout());
175
			
175
			
176
			// Principal
176
			// Principal
177
			LayoutContainer main = new LayoutContainer();
177
			LayoutContainer main = new LayoutContainer();
178
			main.setLayout(new ColumnLayout());
178
			main.setLayout(new ColumnLayout());
179
			
179
			
180
			// Ajout au principal
180
			// Ajout au principal
181
			main.add(left, new ColumnData(.49));
181
			main.add(left, new ColumnData(.49));
182
			main.add(right, new ColumnData(.49));			
182
			main.add(right, new ColumnData(.49));			
183
			
183
			
184
			// Création des champs
184
			// Création des champs
185
			
185
			
186
			//FormLayout sera utilisé à plusieurs reprises
186
			//FormLayout sera utilisé à plusieurs reprises
187
			FormLayout formLayout = new FormLayout();
187
			FormLayout formLayout = new FormLayout();
188
			
188
			
189
			FieldSet fsNoms = new FieldSet();
189
			FieldSet fsNoms = new FieldSet();
190
			fsNoms.setHeading("Noms");
190
			fsNoms.setHeading("Noms");
191
			
191
			
192
			formLayout.setLabelAlign(LabelAlign.LEFT);
192
			formLayout.setLabelAlign(LabelAlign.LEFT);
193
			fsNoms.setLayout(formLayout); 
193
			fsNoms.setLayout(formLayout); 
194
			
194
			
195
			// Nom complet
195
			// Nom complet
196
			// Affiché que si valeurs saisies
196
			// Affiché que si valeurs saisies
197
			LabelField nomComplet = new LabelField();
197
			LabelField nomComplet = new LabelField();
198
			nomComplet.setFieldLabel("Nom complet:");
198
			nomComplet.setFieldLabel("Nom complet:");
199
			nomComplet.hide();
199
			nomComplet.hide();
200
			fsNoms.add(nomComplet);
200
			fsNoms.add(nomComplet);
201
			
201
			
202
			hmIdentite.put("nomComplet", nomComplet);
202
			hmIdentite.put("nomComplet", nomComplet);
203
			
203
			
204
			//Préfixe
204
			//Préfixe
205
			ComboBox<Valeur> cbPrefix = new ComboBox<Valeur>();
205
			ComboBox<Valeur> cbPrefix = new ComboBox<Valeur>();
206
			ListStore<Valeur> storePrefixe = new ListStore<Valeur>();
206
			ListStore<Valeur> storePrefixe = new ListStore<Valeur>();
207
			cbPrefix.setStore(storePrefixe);
207
			cbPrefix.setStore(storePrefixe);
208
			cbPrefix.setDisplayField("nom");
208
			cbPrefix.setDisplayField("nom");
209
			cbPrefix.setEmptyText("Choisissez le préfixe:");
209
			cbPrefix.setEmptyText("Choisissez le préfixe:");
210
			cbPrefix.setFieldLabel("Prefix");
210
			cbPrefix.setFieldLabel("Prefix");
211
			fsNoms.add(cbPrefix);			
211
			fsNoms.add(cbPrefix);			
212
			
212
			
213
			hmIdentite.put("cbPrefix", cbPrefix);
213
			hmIdentite.put("cbPrefix", cbPrefix);
214
			
214
			
215
			// Remplir la liste des préfixe
215
			// Remplir la liste des préfixe
216
			mediateur.obtenirListeValeurEtRafraichir(this, "prefixe");
216
			mediateur.obtenirListeValeurEtRafraichir(this, "prefixe");
217
			
217
			
218
			//Prénom
218
			//Prénom
219
			TextField<String> tfPrenom = new TextField<String>();
219
			TextField<String> tfPrenom = new TextField<String>();
220
			tfPrenom.setFieldLabel("Prénom");
220
			tfPrenom.setFieldLabel("Prénom");
221
			fsNoms.add(tfPrenom);
221
			fsNoms.add(tfPrenom);
222
			
222
			
223
			hmIdentite.put("tfPrenom", tfPrenom);
223
			hmIdentite.put("tfPrenom", tfPrenom);
224
			
224
			
225
			//Nom
225
			//Nom
226
			TextField<String> tfNom = new TextField<String>();
226
			TextField<String> tfNom = new TextField<String>();
227
			tfNom.setFieldLabel("Nom");
227
			tfNom.setFieldLabel("Nom");
228
			fsNoms.add(tfNom);
228
			fsNoms.add(tfNom);
229
			
229
			
230
			hmIdentite.put("tfNom", tfNom);
230
			hmIdentite.put("tfNom", tfNom);
231
			
231
			
232
			//Suffixe
232
			//Suffixe
233
			ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();
233
			ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();
234
			ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();
234
			ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();
235
			cbSuffixe.setStore(storeSuffixe);
235
			cbSuffixe.setStore(storeSuffixe);
236
			cbSuffixe.setFieldLabel("Suffixe");
236
			cbSuffixe.setFieldLabel("Suffixe");
237
			cbSuffixe.setDisplayField("nom");
237
			cbSuffixe.setDisplayField("nom");
238
			cbSuffixe.setEmptyText("Choisissez un suffixe:");
238
			cbSuffixe.setEmptyText("Choisissez un suffixe:");
239
			fsNoms.add(cbSuffixe);			
239
			fsNoms.add(cbSuffixe);			
240
			
240
			
241
			hmIdentite.put("cbSuffixe", cbSuffixe);
241
			hmIdentite.put("cbSuffixe", cbSuffixe);
242
			
242
			
243
			// Remplir la liste des suffixes:
243
			// Remplir la liste des suffixes:
244
			mediateur.obtenirListeValeurEtRafraichir(this, "suffixes");
244
			mediateur.obtenirListeValeurEtRafraichir(this, "suffixes");
245
			
245
			
246
			// Nom : autre
246
			// Nom : autre
247
			TextField<String> tfNomAutre = new TextField();
247
			TextField<String> tfNomAutre = new TextField();
248
			tfNomAutre.setFieldLabel("Autres noms");
248
			tfNomAutre.setFieldLabel("Autres noms");
249
			fsNoms.add(tfNomAutre);
249
			fsNoms.add(tfNomAutre);
250
			
250
			
251
			hmIdentite.put("tfNomAutre", tfNomAutre);
251
			hmIdentite.put("tfNomAutre", tfNomAutre);
252
			
252
			
253
			//Abréviation
253
			//Abréviation
254
			TextField<String> tfAbreviation = new TextField<String>();
254
			TextField<String> tfAbreviation = new TextField<String>();
255
			tfAbreviation.setFieldLabel("Abréviation");
255
			tfAbreviation.setFieldLabel("Abréviation");
256
			fsNoms.add(tfAbreviation);
256
			fsNoms.add(tfAbreviation);
257
			
257
			
258
			hmIdentite.put("tfAbreviation", tfAbreviation);
258
			hmIdentite.put("tfAbreviation", tfAbreviation);
259
			
259
			
260
			//Abréviation autres
260
			//Abréviation autres
261
			TextField<String> tfAbreviationAutre = new TextField<String>();
261
			TextField<String> tfAbreviationAutre = new TextField<String>();
262
			tfAbreviationAutre.setFieldLabel("Autres Abrév.");
262
			tfAbreviationAutre.setFieldLabel("Autres Abrév.");
263
			fsNoms.add(tfAbreviationAutre);
263
			fsNoms.add(tfAbreviationAutre);
264
			
264
			
265
			hmIdentite.put("tfAbreviationAutre", tfAbreviationAutre);
265
			hmIdentite.put("tfAbreviationAutre", tfAbreviationAutre);
266
			
266
			
267
			
267
			
268
			left.add(fsNoms);
268
			left.add(fsNoms);
269
			
269
			
270
			// Naissance
270
			// Naissance
271
			FieldSet fsNaissance = new FieldSet();
271
			FieldSet fsNaissance = new FieldSet();
272
			fsNaissance.setHeading("Naissance");
272
			fsNaissance.setHeading("Naissance");
273
			
273
			
274
			formLayout = new FormLayout();
274
			formLayout = new FormLayout();
275
			formLayout.setLabelAlign(LabelAlign.LEFT);
275
			formLayout.setLabelAlign(LabelAlign.LEFT);
276
			fsNaissance.setLayout(formLayout); 
276
			fsNaissance.setLayout(formLayout); 
277
			
277
			
278
			// Date naissance
278
			// Date naissance
279
			DateField dfDateNaissance = new DateField();
279
			DateField dfDateNaissance = new DateField();
280
			
280
			
281
			dfDateNaissance.setFieldLabel("Date");
281
			dfDateNaissance.setFieldLabel("Date");
282
			fsNaissance.add(dfDateNaissance);
282
			fsNaissance.add(dfDateNaissance);
283
			
283
			
284
			hmIdentite.put("dfDateNaissance", dfDateNaissance);
284
			hmIdentite.put("dfDateNaissance", dfDateNaissance);
285
			
285
			
286
			// Lieu naissance
286
			// Lieu naissance
287
			TextField<String> tfLieuNaissance = new TextField();
287
			TextField<String> tfLieuNaissance = new TextField();
288
			tfLieuNaissance.setFieldLabel("Lieu");
288
			tfLieuNaissance.setFieldLabel("Lieu");
289
			fsNaissance.add(tfLieuNaissance);
289
			fsNaissance.add(tfLieuNaissance);
290
			
290
			
291
			hmIdentite.put("tfLieuNaissance", tfLieuNaissance);
291
			hmIdentite.put("tfLieuNaissance", tfLieuNaissance);
292
			
292
			
293
			left.add(fsNaissance);
293
			left.add(fsNaissance);
294
			
294
			
295
			// Deces
295
			// Deces
296
			FieldSet fsDeces = new FieldSet();
296
			FieldSet fsDeces = new FieldSet();
297
			fsDeces.setHeading("Décès");
297
			fsDeces.setHeading("Décès");
298
			
298
			
299
			formLayout = new FormLayout();
299
			formLayout = new FormLayout();
300
			formLayout.setLabelAlign(LabelAlign.LEFT);
300
			formLayout.setLabelAlign(LabelAlign.LEFT);
301
			fsDeces.setLayout(formLayout); 
301
			fsDeces.setLayout(formLayout); 
302
			
302
			
303
			// Date décès
303
			// Date décès
304
			DateField dfDateDeces = new DateField();
304
			DateField dfDateDeces = new DateField();
305
			dfDateDeces.setFieldLabel("Date");
305
			dfDateDeces.setFieldLabel("Date");
306
			fsDeces.add(dfDateDeces);
306
			fsDeces.add(dfDateDeces);
307
			
307
			
308
			hmIdentite.put("dfDateDeces", dfDateDeces);
308
			hmIdentite.put("dfDateDeces", dfDateDeces);
309
			
309
			
310
			// Lieu décès
310
			// Lieu décès
311
			TextField<String> tfLieuDeces = new TextField();
311
			TextField<String> tfLieuDeces = new TextField();
312
			tfLieuDeces.setFieldLabel("Lieu");
312
			tfLieuDeces.setFieldLabel("Lieu");
313
			fsDeces.add(tfLieuDeces);
313
			fsDeces.add(tfLieuDeces);
314
			
314
			
315
			hmIdentite.put("tfLieuDeces", tfLieuDeces);
315
			hmIdentite.put("tfLieuDeces", tfLieuDeces);
316
			
316
			
317
			left.add(fsDeces);
317
			left.add(fsDeces);
318
			
318
			
319
			tiIdentite.add(main);
319
			tiIdentite.add(main);
320
			
320
			
321
			// Contact - Téléphone
321
			// Contact - Téléphone
322
			FieldSet fsContactTel = new FieldSet();
322
			FieldSet fsContactTel = new FieldSet();
323
			fsContactTel.setHeading("Contact - Téléphones");
323
			fsContactTel.setHeading("Contact - Téléphones");
324
			fsContactTel.setLayout(new TableLayout(3));
324
			fsContactTel.setLayout(new TableLayout(3));
325
			hmIdentite.put("fsContactTel", fsContactTel);
325
			hmIdentite.put("fsContactTel", fsContactTel);
326
			
326
			
327
			right.add(fsContactTel);
327
			right.add(fsContactTel);
328
			
328
			
329
			//Téléphone
329
			//Téléphone
330
			TextField tfTelephone = new TextField();
330
			TextField tfTelephone = new TextField();
331
			tfTelephone.setFieldLabel("tel");
331
			tfTelephone.setFieldLabel("tel");
332
			fsContactTel.add(tfTelephone);
332
			fsContactTel.add(tfTelephone);
333
			
333
			
334
			hmIdentite.put("tfTelephone", tfTelephone);
334
			hmIdentite.put("tfTelephone", tfTelephone);
335
			
335
			
336
			//Type de téléphone
336
			//Type de téléphone
337
			ComboBox<Valeur> cbTelephone = new ComboBox<Valeur>();
337
			ComboBox<Valeur> cbTelephone = new ComboBox<Valeur>();
338
			
338
			
339
			cbTelephone.setDisplayField("nom");
339
			cbTelephone.setDisplayField("nom");
340
			cbTelephone.setEmptyText("Choisissez:");
340
			cbTelephone.setEmptyText("Choisissez:");
341
			ListStore<Valeur> storeTel = new ListStore<Valeur>();
341
			ListStore<Valeur> storeTel = new ListStore<Valeur>();
342
			cbTelephone.setStore(storeTel);
342
			cbTelephone.setStore(storeTel);
343
			
343
			
344
			fsContactTel.add(cbTelephone);
344
			fsContactTel.add(cbTelephone);
345
			
345
			
346
			hmIdentite.put("cbTelephone", cbTelephone);
346
			hmIdentite.put("cbTelephone", cbTelephone);
347
			
347
			
348
			mediateur.obtenirListeValeurEtRafraichir(this, "tel");
348
			mediateur.obtenirListeValeurEtRafraichir(this, "tel");
349
			
349
			
350
			// Bouton ajouter
350
			// Bouton ajouter
351
			Button bAjouter = new Button();
351
			Button bAjouter = new Button();
352
			bAjouter.setText("+");
352
			bAjouter.setText("+");
353
			
353
			
354
			// Evenement bouton
354
			// Evenement bouton
355
			bAjouter.addSelectionListener(
355
			bAjouter.addSelectionListener(
356
					new SelectionListener<ComponentEvent>() {
356
					new SelectionListener<ComponentEvent>() {
357
						
357
						
358
						public void componentSelected(ComponentEvent ce) {
358
						public void componentSelected(ComponentEvent ce) {
359
								
359
								
360
							String strTelephone = ((TextField<String>) hmIdentite.get("tfTelephone")).getValue();
360
							String strTelephone = ((TextField<String>) hmIdentite.get("tfTelephone")).getValue();
361
							if ((strTelephone==null)||(strTelephone.trim().equals("")))	{
361
							if ((strTelephone==null)||(strTelephone.trim().equals("")))	{
362
								Window.alert("Vous devez saisir un numéro de téléphone");
362
								Window.alert("Vous devez saisir un numéro de téléphone");
363
							} else if (hmIdentite.get("tel-" + strTelephone) != null){
363
							} else if (hmIdentite.get("tel-" + strTelephone) != null){
364
								Window.alert("Le numéro saisi est déjà présent dans la liste");							
364
								Window.alert("Le numéro saisi est déjà présent dans la liste");							
365
							} else {
365
							} else {
366
								
366
								
367
								String strValeurTypeTel = "";
367
								String strValeurTypeTel = "";
368
								Valeur valeurTypeTel = ((ComboBox<Valeur>) hmIdentite.get("cbTelephone")).getValue();
368
								Valeur valeurTypeTel = ((ComboBox<Valeur>) hmIdentite.get("cbTelephone")).getValue();
369
								
369
								
370
								if (valeurTypeTel != null)	{
370
								if (valeurTypeTel != null)	{
371
									strValeurTypeTel = valeurTypeTel.getNom();									
371
									strValeurTypeTel = valeurTypeTel.getNom();									
372
								}	else {
372
								}	else {
373
									strValeurTypeTel = ((ComboBox<Valeur>) hmIdentite.get("cbTelephone")).getRawValue();
373
									strValeurTypeTel = ((ComboBox<Valeur>) hmIdentite.get("cbTelephone")).getRawValue();
374
								}
374
								}
375
								
375
								
376
								
376
								
377
								if (strValeurTypeTel.trim().equals(""))	{
377
								if (strValeurTypeTel.trim().equals(""))	{
378
									Window.alert("Vous devez saisir un type de téléphone");
378
									Window.alert("Vous devez saisir un type de téléphone");
379
								}	else {
379
								}	else {
380
									
380
									
381
									//Ajout d'un champ à la liste
381
									//Ajout d'un champ à la liste
382
									HiddenField<String> hfTelephone = new HiddenField<String>();
382
									HiddenField<String> hfTelephone = new HiddenField<String>();
383
									hfTelephone.setId("hidden-" + strTelephone);
383
									hfTelephone.setId("hidden-" + strTelephone);
384
									hfTelephone.setFieldLabel(strValeurTypeTel);
384
									hfTelephone.setFieldLabel(strValeurTypeTel);
385
									hfTelephone.setValue(strTelephone);
385
									hfTelephone.setValue(strTelephone);
386
									hmIdentite.put("hidden-" + strTelephone, hfTelephone);
386
									hmIdentite.put("hidden-" + strTelephone, hfTelephone);
387
									
387
									
388
									FieldSet fsContactTel = (FieldSet) hmIdentite.get("fsContactTel");
388
									FieldSet fsContactTel = (FieldSet) hmIdentite.get("fsContactTel");
389
									
389
									
390
									Text tTypeTelephone = new Text();
390
									Text tTypeTelephone = new Text();
391
									tTypeTelephone.setText(strValeurTypeTel+":");
391
									tTypeTelephone.setText(strValeurTypeTel+":");
392
									
392
									
393
									hmIdentite.put("type-" + strTelephone, tTypeTelephone);
393
									hmIdentite.put("type-" + strTelephone, tTypeTelephone);
394
									fsContactTel.add(tTypeTelephone);
394
									fsContactTel.add(tTypeTelephone);
395
									
395
									
396
									Text tTelephone = new Text();
396
									Text tTelephone = new Text();
397
									tTelephone.setText(strTelephone);
397
									tTelephone.setText(strTelephone);
398
									hmIdentite.put("tel-" + strTelephone, tTelephone);
398
									hmIdentite.put("tel-" + strTelephone, tTelephone);
399
									fsContactTel.add(tTelephone);
399
									fsContactTel.add(tTelephone);
400
									
400
									
401
									Button bSupprimer = new Button();
401
									Button bSupprimer = new Button();
402
									bSupprimer.setId(strTelephone);
402
									bSupprimer.setId(strTelephone);
403
									bSupprimer.setText("-");
403
									bSupprimer.setText("-");
404
									
404
									
405
									bSupprimer.addSelectionListener(new SelectionListener<ComponentEvent>() {
405
									bSupprimer.addSelectionListener(new SelectionListener<ComponentEvent>() {
406
											public void componentSelected(ComponentEvent ce) {
406
											public void componentSelected(ComponentEvent ce) {
407
												
407
												
408
												String strTelephone = ce.component.getId();
408
												String strTelephone = ce.component.getId();
409
												FieldSet fsContactTel = (FieldSet) hmIdentite.get("fsContactTel");
409
												FieldSet fsContactTel = (FieldSet) hmIdentite.get("fsContactTel");
410
												
410
												
411
												fsContactTel.remove(hmIdentite.get("type-" + strTelephone));
411
												fsContactTel.remove(hmIdentite.get("type-" + strTelephone));
412
												hmIdentite.remove("type-" + strTelephone);
412
												hmIdentite.remove("type-" + strTelephone);
413
												
413
												
414
												fsContactTel.remove(hmIdentite.get("tel-" + strTelephone));
414
												fsContactTel.remove(hmIdentite.get("tel-" + strTelephone));
415
												hmIdentite.remove("tel-" + strTelephone);
415
												hmIdentite.remove("tel-" + strTelephone);
416
												
416
												
417
												((TabItem) hmIdentite.get("tiIdentite")).remove(hmIdentite.get("hidden-" + strTelephone));
417
												((TabItem) hmIdentite.get("tiIdentite")).remove(hmIdentite.get("hidden-" + strTelephone));
418
												hmIdentite.remove("hidden-" + strTelephone);
418
												hmIdentite.remove("hidden-" + strTelephone);
419
												
419
												
420
												fsContactTel.remove(ce.component);
420
												fsContactTel.remove(ce.component);
421
												
421
												
422
												layout();
422
												layout();
423
											}
423
											}
424
									});
424
									});
425
									
425
									
426
									fsContactTel.add(bSupprimer);
426
									fsContactTel.add(bSupprimer);
427
									
427
									
428
									((TabItem) hmIdentite.get("tiIdentite")).add(hfTelephone);
428
									((TabItem) hmIdentite.get("tiIdentite")).add(hfTelephone);
429
									
429
									
430
									layout();
430
									layout();
431
								}
431
								}
432
								
432
								
433
							}
433
							}
434
							
434
							
435
							
435
							
436
						}
436
						}
437
					}			
437
					}			
438
			);
438
			);
439
			
439
			
440
			fsContactTel.add(bAjouter);
440
			fsContactTel.add(bAjouter);
441
			
441
			
442
			//Contact - autres
442
			//Contact - autres
443
			FieldSet fsContact = new FieldSet();
443
			FieldSet fsContact = new FieldSet();
444
			fsContact.setHeading("Contact - Autres");
444
			fsContact.setHeading("Contact - Autres");
445
			
445
			
446
			formLayout = new FormLayout();
446
			formLayout = new FormLayout();
447
			formLayout.setLabelAlign(LabelAlign.LEFT);
447
			formLayout.setLabelAlign(LabelAlign.LEFT);
448
			fsContact.setLayout(formLayout);
448
			fsContact.setLayout(formLayout);
449
			
449
			
450
			right.add(fsContact);
450
			right.add(fsContact);
451
			
451
			
452
			// Courriels
452
			// Courriels
453
			TextArea taCourriel = new TextArea();
453
			TextArea taCourriel = new TextArea();
454
			taCourriel.setFieldLabel("Courriels");
454
			taCourriel.setFieldLabel("Courriels");
455
			taCourriel.setEmptyText("Saisissez les adresses courriels séparées par un saut de ligne");
455
			taCourriel.setEmptyText("Saisissez les adresses courriels séparées par un saut de ligne");
456
			fsContact.add(taCourriel);
456
			fsContact.add(taCourriel);
457
			
457
			
458
			hmIdentite.put("taCourriel", taCourriel);
458
			hmIdentite.put("taCourriel", taCourriel);
459
			
459
			
460
			// URLS
460
			// URLS
461
			TextArea taUrl = new TextArea();
461
			TextArea taUrl = new TextArea();
462
			taUrl.setFieldLabel("Sites");
462
			taUrl.setFieldLabel("Sites");
463
			taUrl.setEmptyText("Saisissez les adresses des sites séparées par un saut de ligne");
463
			taUrl.setEmptyText("Saisissez les adresses des sites séparées par un saut de ligne");
464
			fsContact.add(taUrl);
464
			fsContact.add(taUrl);
465
			
465
			
466
			hmIdentite.put("taUrl", taUrl);
466
			hmIdentite.put("taUrl", taUrl);
467
			
467
			
468
			
468
			
469
			// Autres informations
469
			// Autres informations
470
			FieldSet fsAutresInfos = new FieldSet();
470
			FieldSet fsAutresInfos = new FieldSet();
471
			fsAutresInfos.setHeading("Autres informations");
471
			fsAutresInfos.setHeading("Autres informations");
472
			
472
			
473
			formLayout = new FormLayout();
473
			formLayout = new FormLayout();
474
			formLayout.setLabelAlign(LabelAlign.LEFT);
474
			formLayout.setLabelAlign(LabelAlign.LEFT);
475
			fsAutresInfos.setLayout(formLayout); 
475
			fsAutresInfos.setLayout(formLayout); 
476
			
476
			
477
			right.add(fsAutresInfos);
477
			right.add(fsAutresInfos);
478
			
478
			
479
			//Civilité
479
			//Civilité
480
			
480
			
481
			ComboBox<Valeur> cbSexe = new ComboBox<Valeur>();
481
			ComboBox<Valeur> cbSexe = new ComboBox<Valeur>();
482
			ListStore<Valeur> storeSexe = new ListStore<Valeur>();
482
			ListStore<Valeur> storeSexe = new ListStore<Valeur>();
483
			cbSexe.setStore(storeSexe);
483
			cbSexe.setStore(storeSexe);
484
			cbSexe.setFieldLabel("Sexe");
484
			cbSexe.setFieldLabel("Sexe");
485
			cbSexe.setDisplayField("nom");
485
			cbSexe.setDisplayField("nom");
486
			cbSexe.setEmptyText("Choisissez le sexe:");
486
			cbSexe.setEmptyText("Choisissez le sexe:");
487
			
487
			
488
			fsAutresInfos.add(cbSexe);			
488
			fsAutresInfos.add(cbSexe);			
489
			
489
			
490
			hmIdentite.put("cbSexe", cbSexe);
490
			hmIdentite.put("cbSexe", cbSexe);
491
			
491
			
492
			mediateur.obtenirListeValeurEtRafraichir(this, "sexe");			
492
			mediateur.obtenirListeValeurEtRafraichir(this, "sexe");			
493
			
493
			
494
			//Description
494
			//Description
495
			TextArea taDescription = new TextArea();
495
			TextArea taDescription = new TextArea();
496
			taDescription.setEmptyText("Saisissez une description");
496
			taDescription.setEmptyText("Saisissez une description");
497
			taDescription.setFieldLabel("Description");
497
			taDescription.setFieldLabel("Description");
498
			fsAutresInfos.add(taDescription);
498
			fsAutresInfos.add(taDescription);
499
			
499
			
500
			hmIdentite.put("taDescription", taDescription);
500
			hmIdentite.put("taDescription", taDescription);
501
			
501
			
502
			// Logo
502
			// Logo
503
			TextArea taLogo = new TextArea();
503
			TextArea taLogo = new TextArea();
504
			taLogo.setFieldLabel("Logos");
504
			taLogo.setFieldLabel("Logos");
505
			taLogo.setEmptyText("Saisissez les adresses des logos séparées par un saut de ligne");
505
			taLogo.setEmptyText("Saisissez les adresses des logos séparées par un saut de ligne");
506
			fsAutresInfos.add(taLogo);
506
			fsAutresInfos.add(taLogo);
507
			
507
			
508
			hmIdentite.put("taLogo", taLogo);
508
			hmIdentite.put("taLogo", taLogo);
509
			
509
			
510
			
510
			
511
			
511
			
512
			// Ajout des évènements saisi
512
			// Ajout des évènements saisi
513
			KeyListener klNoms = new KeyListener()	{
513
			KeyListener klNoms = new KeyListener()	{
514
				public void componentKeyUp(ComponentEvent ev)	{
514
				public void componentKeyUp(ComponentEvent ev)	{
515
					rafraichir(null);	
515
					rafraichir(null);	
516
				}				
516
				}				
517
			};
517
			};
518
			
518
			
519
			SelectionChangedListener<InterneValeur> selectionChange = new SelectionChangedListener<InterneValeur>() {
519
			SelectionChangedListener<InterneValeur> selectionChange = new SelectionChangedListener<InterneValeur>() {
520
				public void selectionChanged(SelectionChangedEvent se) {
520
				public void selectionChanged(SelectionChangedEvent se) {
521
						rafraichir(null);
521
						rafraichir(null);
522
					}
522
					}
523
			};
523
			};
524
						
524
						
525
			cbPrefix.addSelectionChangedListener(selectionChange);
525
			cbPrefix.addSelectionChangedListener(selectionChange);
526
			cbPrefix.addKeyListener(klNoms);
526
			cbPrefix.addKeyListener(klNoms);
527
			tfPrenom.addKeyListener(klNoms);
527
			tfPrenom.addKeyListener(klNoms);
528
			tfNom.addKeyListener(klNoms);
528
			tfNom.addKeyListener(klNoms);
529
			cbSuffixe.addSelectionChangedListener(selectionChange);		
529
			cbSuffixe.addSelectionChangedListener(selectionChange);		
530
			
530
			
531
	}
531
	}
532
	
532
	
533
	public void creerComposantsAdresse()	{
533
	public void creerComposantsAdresse()	{
534
		
534
		
535
		// Gauche
535
		// Gauche
536
		LayoutContainer left = new LayoutContainer();
536
		LayoutContainer left = new LayoutContainer();
537
		left.setLayout(new FormLayout());
537
		left.setLayout(new FormLayout());
538
		
538
		
539
		// Droite
539
		// Droite
540
		LayoutContainer right = new LayoutContainer();
540
		LayoutContainer right = new LayoutContainer();
541
		right.setLayout(new FormLayout());
541
		right.setLayout(new FormLayout());
542
		
542
		
543
		// Principal
543
		// Principal
544
		LayoutContainer main = new LayoutContainer();
544
		LayoutContainer main = new LayoutContainer();
545
		main.setLayout(new ColumnLayout());
545
		main.setLayout(new ColumnLayout());
546
		
546
		
547
		// Ajout au principal
547
		// Ajout au principal
548
		main.add(left, new ColumnData(.49));
548
		main.add(left, new ColumnData(.49));
549
		main.add(right, new ColumnData(.49));	
549
		main.add(right, new ColumnData(.49));	
550
		
550
		
551
		TextField<String> tfAdresse1 = new TextField();
551
		TextField<String> tfAdresse1 = new TextField();
552
		tfAdresse1.setFieldLabel("Adresse");
552
		tfAdresse1.setFieldLabel("Adresse");
553
		left.add(tfAdresse1);
553
		left.add(tfAdresse1);
554
		hmAdresse.put("tfAdresse1", tfAdresse1);
554
		hmAdresse.put("tfAdresse1", tfAdresse1);
555
		
555
		
556
		TextField<String> tfAdresse2 = new TextField();
556
		TextField<String> tfAdresse2 = new TextField();
557
		tfAdresse2.setFieldLabel("Complément d'adresse");
557
		tfAdresse2.setFieldLabel("Complément d'adresse");
558
		left.add(tfAdresse2);
558
		left.add(tfAdresse2);
559
		hmAdresse.put("tfAdresse2", tfAdresse2);
559
		hmAdresse.put("tfAdresse2", tfAdresse2);
560
		
560
		
561
		ComboBox<Valeur> cbPays = new ComboBox<Valeur>();
561
		ComboBox<Valeur> cbPays = new ComboBox<Valeur>();
562
		cbPays.setFieldLabel("Pays");
562
		cbPays.setFieldLabel("Pays");
563
		cbPays.setDisplayField("nom");
563
		cbPays.setDisplayField("nom");
564
		cbPays.setEmptyText("Sélectionnez le pays:");
564
		cbPays.setEmptyText("Sélectionnez le pays:");
565
		
565
		
566
		ListStore<Valeur> storePays = new ListStore<Valeur>();
566
		ListStore<Valeur> storePays = new ListStore<Valeur>();
567
		cbPays.setStore(storePays);
567
		cbPays.setStore(storePays);
568
		
568
		
569
		right.add(cbPays);
569
		right.add(cbPays);
570
		hmAdresse.put("cbPays", cbPays);
570
		hmAdresse.put("cbPays", cbPays);
571
		
571
		
572
		SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
572
		SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
573
			public void selectionChanged(SelectionChangedEvent se) {
573
			public void selectionChanged(SelectionChangedEvent se) {
574
					// Rafraichir avec le pays sélectionné
574
					// Rafraichir avec le pays sélectionné
575
					obtenirListeRegionParPays(((Valeur) se.getSelectedItem()).getAbreviation().toString());
575
					obtenirListeRegionParPays(((Valeur) se.getSelectedItem()).getAbreviation().toString());
576
					
576
					
577
				}
577
				}
578
		};
578
		};
579
					
579
					
580
		cbPays.addSelectionChangedListener(selectionChange);
580
		cbPays.addSelectionChangedListener(selectionChange);
581
		
581
		
582
		
582
		
583
		ComboBox<Valeur> cbRegion = new ComboBox<Valeur>();
583
		ComboBox<Valeur> cbRegion = new ComboBox<Valeur>();
584
		cbRegion.setFieldLabel("Region");
584
		cbRegion.setFieldLabel("Region");
585
		cbRegion.setDisplayField("nom");
585
		cbRegion.setDisplayField("nom");
586
		cbRegion.setEmptyText("Sélectionnez la région:");
586
		cbRegion.setEmptyText("Sélectionnez la région:");
587
		cbRegion.setVisible(false);
587
		cbRegion.setVisible(false);
588
		
588
		
589
		ListStore<Valeur> storeRegion = new ListStore<Valeur>();
589
		ListStore<Valeur> storeRegion = new ListStore<Valeur>();
590
		cbRegion.setStore(storeRegion);
590
		cbRegion.setStore(storeRegion);
591
		
591
		
592
		right.add(cbRegion);
592
		right.add(cbRegion);
593
		hmAdresse.put("cbRegion", cbRegion);
593
		hmAdresse.put("cbRegion", cbRegion);
594
		
594
		
595
		TextField<String> tfBoitePostale = new TextField<String>();
595
		TextField<String> tfBoitePostale = new TextField<String>();
596
		tfBoitePostale.setFieldLabel("Boite postale");
596
		tfBoitePostale.setFieldLabel("Boite postale");
597
		left.add(tfBoitePostale);
597
		left.add(tfBoitePostale);
598
		hmAdresse.put("tfBoitePostale", tfBoitePostale);
598
		hmAdresse.put("tfBoitePostale", tfBoitePostale);
599
		
599
		
600
		TextField<Integer> tfCodePostal = new TextField<Integer>();
600
		TextField<Integer> tfCodePostal = new TextField<Integer>();
601
		tfCodePostal.setFieldLabel("Code postal");
601
		tfCodePostal.setFieldLabel("Code postal");
602
		right.add(tfCodePostal);
602
		right.add(tfCodePostal);
603
		hmAdresse.put("tfCodePostal", tfCodePostal);
603
		hmAdresse.put("tfCodePostal", tfCodePostal);
604
		
604
		
605
		TextField tfVille = new TextField();
605
		TextField tfVille = new TextField();
606
		tfVille.setFieldLabel("Ville");
606
		tfVille.setFieldLabel("Ville");
607
		
607
		
608
		right.add(tfVille);
608
		right.add(tfVille);
609
		hmAdresse.put("tfVille", tfVille);
609
		hmAdresse.put("tfVille", tfVille);
610
		
610
		
611
		// MAJ ComboBox
611
		// MAJ ComboBox
612
		mediateur.obtenirListeValeurEtRafraichir(this, "pays");
612
		mediateur.obtenirListeValeurEtRafraichir(this, "pays");
-
 
613
		
-
 
614
		FieldSet fsAdresse = new FieldSet();
613
		
615
		fsAdresse.setHeading("Adresse personnelle");
-
 
616
		fsAdresse.add(main);
-
 
617
		
614
		tiAdresses.add(main);
618
		tiAdresses.add(fsAdresse);
615
		
619
		
616
	}
620
	}
617
	
621
	
618
	/**
622
	/**
619
	 * Ajouter le bouton réinitialiser à la barre d'outils donnée
623
	 * Ajouter le bouton réinitialiser à la barre d'outils donnée
620
	 * 
624
	 * 
621
	 * @param barreOutils la barre d'outils à modifier
625
	 * @param barreOutils la barre d'outils à modifier
622
	 * */
626
	 * */
623
	public static void ajouterBoutonReinitialiser(ToolBar barreOutils)	{
627
	public static void ajouterBoutonReinitialiser(ToolBar barreOutils)	{
624
		
628
		
625
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
629
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
626
		TextToolItem reinitialiser = new TextToolItem("Réinitialiser");
630
		TextToolItem reinitialiser = new TextToolItem("Réinitialiser");
627
		reinitialiser.setIconStyle(ComposantClass.ICONE_RAFRAICHIR);
631
		reinitialiser.setIconStyle(ComposantClass.ICONE_RAFRAICHIR);
628
		reinitialiser.addSelectionListener(new SelectionListener<ComponentEvent>() {  
632
		reinitialiser.addSelectionListener(new SelectionListener<ComponentEvent>() {  
629
			public void componentSelected(ComponentEvent ce) {  
633
			public void componentSelected(ComponentEvent ce) {  
630
				((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicAjouterPersonne();
634
				((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicAjouterPersonne();
631
			}  
635
			}  
632
		});
636
		});
633
		barreOutils.add(reinitialiser);
637
		barreOutils.add(reinitialiser);
634
	}
638
	}
635
	
639
	
636
	/**
640
	/**
637
	 * Ajouter le bouton Sauvegarder à la barre d'outils donnée
641
	 * Ajouter le bouton Sauvegarder à la barre d'outils donnée
638
	 * 
642
	 * 
639
	 * @param barreOutils la barre d'outils à modifier
643
	 * @param barreOutils la barre d'outils à modifier
640
	 * */
644
	 * */
641
	public static void ajouterBoutonEnregistrer(ToolBar barreOutils)	{
645
	public static void ajouterBoutonEnregistrer(ToolBar barreOutils)	{
642
		
646
		
643
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
647
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
644
		TextToolItem enregistrer = new TextToolItem("Enregistrer");
648
		TextToolItem enregistrer = new TextToolItem("Enregistrer");
645
		enregistrer.setIconStyle(ComposantClass.ICONE_PREFERENCE);
649
		enregistrer.setIconStyle(ComposantClass.ICONE_PREFERENCE);
646
		enregistrer.addSelectionListener(new SelectionListener<ComponentEvent>() {  
650
		enregistrer.addSelectionListener(new SelectionListener<ComponentEvent>() {  
647
			public void componentSelected(ComponentEvent ce) {  
651
			public void componentSelected(ComponentEvent ce) {  
648
				// TODO : Enregistrer le formulaire
652
				// TODO : Enregistrer le formulaire
649
			}  
653
			}  
650
		});
654
		});
651
		barreOutils.add(enregistrer);
655
		barreOutils.add(enregistrer);
652
	}
656
	}
653
	
657
	
654
	/**
658
	/**
655
	 * Ajouter le bouton annuler à la barre d'outils donnée
659
	 * Ajouter le bouton annuler à la barre d'outils donnée
656
	 * 
660
	 * 
657
	 * @param barreOutils la barre d'outils à modifier
661
	 * @param barreOutils la barre d'outils à modifier
658
	 * */
662
	 * */
659
	public static void ajouterBoutonAnnuler(ToolBar barreOutils)	{
663
	public static void ajouterBoutonAnnuler(ToolBar barreOutils)	{
660
		
664
		
661
		// Le bouton annuler ne sauvegarde pas les informations et renvoie vers la page précédente
665
		// Le bouton annuler ne sauvegarde pas les informations et renvoie vers la page précédente
662
		TextToolItem annuler = new TextToolItem("Annuler");
666
		TextToolItem annuler = new TextToolItem("Annuler");
663
		annuler.addSelectionListener(new SelectionListener<ComponentEvent>() {  
667
		annuler.addSelectionListener(new SelectionListener<ComponentEvent>() {  
664
			public void componentSelected(ComponentEvent ce) {  
668
			public void componentSelected(ComponentEvent ce) {  
665
				((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
669
				((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
666
			}  
670
			}  
667
		});
671
		});
668
		annuler.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
672
		annuler.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
669
		barreOutils.add(annuler);
673
		barreOutils.add(annuler);
670
	}
674
	}
671
	
675
	
672
	public void obtenirListeRegionParPays(String strPays)	{
676
	public void obtenirListeRegionParPays(String strPays)	{
673
		mediateur.obtenirListeRegionsEtRafraichir(this, "region", strPays);
677
		mediateur.obtenirListeRegionsEtRafraichir(this, "region", strPays);
674
	}
678
	}
675
	
679
	
676
	
680
	
677
	
681
	
678
	/*---------------------------------------------------------------------------------------
682
	/*---------------------------------------------------------------------------------------
679
	 * 		RAFRAICHISSEMENT DU PANNEAU
683
	 * 		RAFRAICHISSEMENT DU PANNEAU
680
	 * --------------------------------------------------------------------------------------
684
	 * --------------------------------------------------------------------------------------
681
	 */	
685
	 */	
682
	public void rafraichir(Object nouvellesDonnees) {
686
	public void rafraichir(Object nouvellesDonnees) {
683
		if (nouvellesDonnees instanceof ValeurListe){
687
		if (nouvellesDonnees instanceof ValeurListe){
684
			
688
			
685
			
689
			
686
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
690
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
687
			
691
			
688
			// Créer une liste de valeurs
692
			// Créer une liste de valeurs
689
			List<Valeur> liste = new ArrayList<Valeur>();
693
			List<Valeur> liste = new ArrayList<Valeur>();
690
			for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
694
			for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
691
				liste.add(listeValeurs.get(it.next()));
695
				liste.add(listeValeurs.get(it.next()));
692
			}
696
			}
693
			
697
			
694
			if (listeValeurs.getId().equals(config.getListeId("prefixe")))	{
698
			if (listeValeurs.getId().equals(config.getListeId("prefixe")))	{
695
 
699
 
696
				remplirCombobox("cbPrefix", liste, "hmIdentite");
700
				remplirCombobox("cbPrefix", liste, "hmIdentite");
697
								
701
								
698
			} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) {
702
			} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) {
699
			
703
			
700
				remplirCombobox("cbSuffixe", liste, "hmIdentite");
704
				remplirCombobox("cbSuffixe", liste, "hmIdentite");
701
								
705
								
702
			} else if (listeValeurs.getId().equals(config.getListeId("sexe"))) {
706
			} else if (listeValeurs.getId().equals(config.getListeId("sexe"))) {
703
 
707
 
704
				remplirCombobox("cbSexe", liste, "hmIdentite");
708
				remplirCombobox("cbSexe", liste, "hmIdentite");
705
				
709
				
706
			} else if (listeValeurs.getId().equals(config.getListeId("tel"))) {
710
			} else if (listeValeurs.getId().equals(config.getListeId("tel"))) {
707
			
711
			
708
				remplirCombobox("cbTelephone", liste, "hmIdentite");
712
				remplirCombobox("cbTelephone", liste, "hmIdentite");
709
			
713
			
710
			} else if (listeValeurs.getId().equals(config.getListeId("pays")))	{
714
			} else if (listeValeurs.getId().equals(config.getListeId("pays")))	{
711
				
715
				
712
				remplirCombobox("cbPays", liste, "hmAdresse");
716
				remplirCombobox("cbPays", liste, "hmAdresse");
713
				
717
				
714
			} else if (listeValeurs.getId().equals(config.getListeId("region")))	{
718
			} else if (listeValeurs.getId().equals(config.getListeId("region")))	{
715
				
719
				
716
				remplirCombobox("cbRegion", liste, "hmAdresse");
720
				remplirCombobox("cbRegion", liste, "hmAdresse");
717
				
721
				
718
				((ComboBox) hmAdresse.get("cbRegion")).setVisible(true);
722
				((ComboBox) hmAdresse.get("cbRegion")).setVisible(true);
719
			}
723
			}
720
			
724
			
721
			
725
			
722
		} else if (nouvellesDonnees instanceof Personne)	{
726
		} else if (nouvellesDonnees instanceof Personne)	{
723
		
727
		
724
			
728
			
725
			
729
			
726
			//Mise à jour de la personne		
730
			//Mise à jour de la personne		
727
			Personne personne = (Personne) nouvellesDonnees;
731
			Personne personne = (Personne) nouvellesDonnees;
728
			personneSelectionnee = personne;
732
			personneSelectionnee = personne;
729
			
733
			
730
			
734
			
731
			((TextField) hmIdentite.get("tfPrenom")).setValue(personne.get("prenom"));
735
			((TextField) hmIdentite.get("tfPrenom")).setValue(personne.get("prenom"));
732
			((TextField) hmIdentite.get("tfNom")).setValue(personne.get("nom"));
736
			((TextField) hmIdentite.get("tfNom")).setValue(personne.get("nom"));
733
			((TextField) hmIdentite.get("tfNomAutre")).setValue(personne.get("truk_nom_autre"));
737
			((TextField) hmIdentite.get("tfNomAutre")).setValue(personne.get("truk_nom_autre"));
734
			((TextField) hmIdentite.get("tfAbreviation")).setValue(personne.get("abreviation"));
738
			((TextField) hmIdentite.get("tfAbreviation")).setValue(personne.get("abreviation"));
735
			((TextField) hmIdentite.get("tfAbreviationAutre")).setValue(personne.get("truk_abreviation_autre"));
739
			((TextField) hmIdentite.get("tfAbreviationAutre")).setValue(personne.get("truk_abreviation_autre"));
736
			
740
			
737
			//FIXME : DATES
741
			//FIXME : DATES
738
			//((DateField) hmIdentite.get("dfDateNaissance")).setValue(new Date((String) personne.get("naissance_date")));
742
			//((DateField) hmIdentite.get("dfDateNaissance")).setValue(new Date((String) personne.get("naissance_date")));
739
			((TextField) hmIdentite.get("tfLieuNaissance")).setValue(personne.get("naissance_lieu"));
743
			((TextField) hmIdentite.get("tfLieuNaissance")).setValue(personne.get("naissance_lieu"));
740
			//((DateField) hmIdentite.get("dfDateDeces")).setValue(new Date((String) personne.get("deces_date")));
744
			//((DateField) hmIdentite.get("dfDateDeces")).setValue(new Date((String) personne.get("deces_date")));
741
			((TextField) hmIdentite.get("tfLieuDeces")).setValue(personne.get("deces_lieu"));
745
			((TextField) hmIdentite.get("tfLieuDeces")).setValue(personne.get("deces_lieu"));
742
			
746
			
743
		} 
747
		} 
744
		
748
		
745
		if (nouvellesDonnees == null)
749
		if (nouvellesDonnees == null)
746
		{
750
		{
747
			ComboBox cb= (ComboBox) hmIdentite.get("cbPrefix");
751
			ComboBox cb= (ComboBox) hmIdentite.get("cbPrefix");
748
			
752
			
749
			//Met à jour le nom Complet du formulaire
753
			//Met à jour le nom Complet du formulaire
750
			String valeurRetour = "";
754
			String valeurRetour = "";
751
			
755
			
752
			// Prefixe
756
			// Prefixe
753
			String prefixe = "";
757
			String prefixe = "";
754
			Valeur valPrefixe = (Valeur) ((ComboBox) hmIdentite.get("cbPrefix")).getValue();
758
			Valeur valPrefixe = (Valeur) ((ComboBox) hmIdentite.get("cbPrefix")).getValue();
755
			
759
			
756
			if (valPrefixe != null)	{
760
			if (valPrefixe != null)	{
757
				prefixe = valPrefixe.getNom();
761
				prefixe = valPrefixe.getNom();
758
			} else 	{
762
			} else 	{
759
				prefixe =  (String) ((ComboBox) hmIdentite.get("cbPrefix")).getRawValue();
763
				prefixe =  (String) ((ComboBox) hmIdentite.get("cbPrefix")).getRawValue();
760
			}		
764
			}		
761
			
765
			
762
			
766
			
763
			// Prénom
767
			// Prénom
764
			String prenom = (String) ((TextField) hmIdentite.get("tfPrenom")).getValue();
768
			String prenom = (String) ((TextField) hmIdentite.get("tfPrenom")).getValue();
765
			
769
			
766
			// Nom
770
			// Nom
767
			String nom = (String) ((TextField) hmIdentite.get("tfNom")).getValue();
771
			String nom = (String) ((TextField) hmIdentite.get("tfNom")).getValue();
768
			
772
			
769
			// Suffixe
773
			// Suffixe
770
			String suffixe = "";
774
			String suffixe = "";
771
			Valeur valSuffixe = (Valeur) ((ComboBox) hmIdentite.get("cbSuffixe")).getValue();
775
			Valeur valSuffixe = (Valeur) ((ComboBox) hmIdentite.get("cbSuffixe")).getValue();
772
			
776
			
773
			if (valSuffixe != null)	{
777
			if (valSuffixe != null)	{
774
				suffixe = valSuffixe.getNom();
778
				suffixe = valSuffixe.getNom();
775
			} else 	{
779
			} else 	{
776
				suffixe =  (String) ((ComboBox) hmIdentite.get("cbSuffixe")).getRawValue();
780
				suffixe =  (String) ((ComboBox) hmIdentite.get("cbSuffixe")).getRawValue();
777
			}
781
			}
778
			
782
			
779
			// Mettre à jour la valeur
783
			// Mettre à jour la valeur
780
			valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
784
			valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
781
			valeurRetour = valeurRetour.replaceAll("null", "");
785
			valeurRetour = valeurRetour.replaceAll("null", "");
782
			
786
			
783
			((LabelField) hmIdentite.get("nomComplet")).setValue(valeurRetour);
787
			((LabelField) hmIdentite.get("nomComplet")).setValue(valeurRetour);
784
			
788
			
785
			if (!valeurRetour.trim().equals(""))	{
789
			if (!valeurRetour.trim().equals(""))	{
786
				((LabelField) hmIdentite.get("nomComplet")).show();
790
				((LabelField) hmIdentite.get("nomComplet")).show();
787
			} else {
791
			} else {
788
				((LabelField) hmIdentite.get("nomComplet")).hide();
792
				((LabelField) hmIdentite.get("nomComplet")).hide();
789
			}
793
			}
790
		}
794
		}
791
	}
795
	}
792
 
796
 
793
	public void remplirCombobox(String idComboBox, List liste, String hashMapId)	{
797
	public void remplirCombobox(String idComboBox, List liste, String hashMapId)	{
794
		
798
		
795
		HashMap hm = null;
799
		HashMap hm = null;
796
		if (hashMapId.equals("hmIdentite"))	{
800
		if (hashMapId.equals("hmIdentite"))	{
797
			hm = hmIdentite;
801
			hm = hmIdentite;
798
		} else if (hashMapId.equals("hmAdresse")){
802
		} else if (hashMapId.equals("hmAdresse")){
799
			hm = hmAdresse;
803
			hm = hmAdresse;
800
		} else {
804
		} else {
801
			hm = hmInfosNat;
805
			hm = hmInfosNat;
802
		}
806
		}
803
		
807
		
804
		ListStore<Valeur> store = ((ComboBox) hm.get(idComboBox)).getStore();
808
		ListStore<Valeur> store = ((ComboBox) hm.get(idComboBox)).getStore();
805
		store.removeAll();
809
		store.removeAll();
806
		store.add(liste);
810
		store.add(liste);
807
		((ComboBox) hm.get(idComboBox)).setStore(store);
811
		((ComboBox) hm.get(idComboBox)).setStore(store);
808
	}
812
	}
809
	
813
	
810
 
814
 
811
 
815
 
812
}
816
}