Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 935 Rev 973
1
package org.tela_botanica.client.vues.personne;
1
package org.tela_botanica.client.vues.personne;
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.composants.ChampMultiValeurs;
14
import org.tela_botanica.client.composants.ChampMultiValeurs;
15
import org.tela_botanica.client.composants.ChampMultiValeursImage;
15
import org.tela_botanica.client.composants.ChampMultiValeursImage;
16
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes;
16
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypes;
-
 
17
import org.tela_botanica.client.composants.HashMapComposants;
17
import org.tela_botanica.client.configuration.Configuration;
18
import org.tela_botanica.client.configuration.Configuration;
18
import org.tela_botanica.client.images.Images;
19
import org.tela_botanica.client.images.Images;
19
import org.tela_botanica.client.interfaces.Rafraichissable;
20
import org.tela_botanica.client.interfaces.Rafraichissable;
20
 
21
 
21
import org.tela_botanica.client.modeles.Information;
22
import org.tela_botanica.client.modeles.Information;
22
import org.tela_botanica.client.modeles.MenuApplicationId;
23
import org.tela_botanica.client.modeles.MenuApplicationId;
23
import org.tela_botanica.client.modeles.Valeur;
24
import org.tela_botanica.client.modeles.Valeur;
24
import org.tela_botanica.client.modeles.ValeurListe;
25
import org.tela_botanica.client.modeles.ValeurListe;
25
import org.tela_botanica.client.modeles.personne.Personne;
26
import org.tela_botanica.client.modeles.personne.Personne;
26
import org.tela_botanica.client.modeles.personne.PersonneListe;
27
import org.tela_botanica.client.modeles.personne.PersonneListe;
27
import org.tela_botanica.client.modeles.projet.Projet;
28
import org.tela_botanica.client.modeles.projet.Projet;
28
import org.tela_botanica.client.modeles.projet.ProjetListe;
29
import org.tela_botanica.client.modeles.projet.ProjetListe;
29
import org.tela_botanica.client.util.Pattern;
30
import org.tela_botanica.client.util.Pattern;
30
import org.tela_botanica.client.util.UtilString;
31
import org.tela_botanica.client.util.UtilString;
31
import org.tela_botanica.client.vues.Formulaire;
32
import org.tela_botanica.client.vues.Formulaire;
32
 
33
 
33
import com.extjs.gxt.ui.client.event.Events;
34
import com.extjs.gxt.ui.client.event.Events;
34
import com.extjs.gxt.ui.client.Registry;
35
import com.extjs.gxt.ui.client.Registry;
35
import com.extjs.gxt.ui.client.Style.IconAlign;
36
import com.extjs.gxt.ui.client.Style.IconAlign;
36
import com.extjs.gxt.ui.client.Style.Scroll;
37
import com.extjs.gxt.ui.client.Style.Scroll;
37
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
38
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
-
 
39
 
38
 
40
import com.extjs.gxt.ui.client.binding.FieldBinding;
39
import com.extjs.gxt.ui.client.binding.FormBinding;
41
import com.extjs.gxt.ui.client.binding.FormBinding;
40
 
42
 
41
import com.extjs.gxt.ui.client.event.ButtonEvent;
43
import com.extjs.gxt.ui.client.event.ButtonEvent;
42
import com.extjs.gxt.ui.client.event.ComponentEvent;
44
import com.extjs.gxt.ui.client.event.ComponentEvent;
43
import com.extjs.gxt.ui.client.event.KeyListener;
45
import com.extjs.gxt.ui.client.event.KeyListener;
44
import com.extjs.gxt.ui.client.event.Listener;
46
import com.extjs.gxt.ui.client.event.Listener;
45
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
47
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
46
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
48
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
47
import com.extjs.gxt.ui.client.event.SelectionListener;
49
import com.extjs.gxt.ui.client.event.SelectionListener;
48
import com.extjs.gxt.ui.client.store.ListStore;
50
import com.extjs.gxt.ui.client.store.ListStore;
49
import com.extjs.gxt.ui.client.widget.LayoutContainer;
51
import com.extjs.gxt.ui.client.widget.LayoutContainer;
50
import com.extjs.gxt.ui.client.widget.MessageBox;
52
import com.extjs.gxt.ui.client.widget.MessageBox;
51
 
53
 
52
import com.extjs.gxt.ui.client.widget.Info;
54
import com.extjs.gxt.ui.client.widget.Info;
53
import com.extjs.gxt.ui.client.widget.TabItem;
55
import com.extjs.gxt.ui.client.widget.TabItem;
54
import com.extjs.gxt.ui.client.widget.TabPanel;
56
import com.extjs.gxt.ui.client.widget.TabPanel;
-
 
57
import com.extjs.gxt.ui.client.widget.Text;
55
 
58
 
56
import com.extjs.gxt.ui.client.widget.button.Button;
59
import com.extjs.gxt.ui.client.widget.button.Button;
57
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
60
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
58
import com.extjs.gxt.ui.client.widget.form.ComboBox;
61
import com.extjs.gxt.ui.client.widget.form.ComboBox;
59
import com.extjs.gxt.ui.client.widget.form.DateField;
62
import com.extjs.gxt.ui.client.widget.form.DateField;
60
import com.extjs.gxt.ui.client.widget.form.FieldSet;
63
import com.extjs.gxt.ui.client.widget.form.FieldSet;
61
import com.extjs.gxt.ui.client.widget.form.LabelField;
64
import com.extjs.gxt.ui.client.widget.form.LabelField;
62
import com.extjs.gxt.ui.client.widget.form.Radio;
65
import com.extjs.gxt.ui.client.widget.form.Radio;
63
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
66
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
64
import com.extjs.gxt.ui.client.widget.form.TextArea;
67
import com.extjs.gxt.ui.client.widget.form.TextArea;
65
import com.extjs.gxt.ui.client.widget.form.TextField;
68
import com.extjs.gxt.ui.client.widget.form.TextField;
66
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
69
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
67
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
70
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
68
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
71
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
69
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
72
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
70
import com.extjs.gxt.ui.client.widget.layout.FormData;
73
import com.extjs.gxt.ui.client.widget.layout.FormData;
71
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
74
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
72
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
75
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
73
import com.extjs.gxt.ui.client.widget.layout.TableData;
76
import com.extjs.gxt.ui.client.widget.layout.TableData;
74
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
77
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
75
import com.google.gwt.core.client.GWT;
78
import com.google.gwt.core.client.GWT;
76
import com.google.gwt.i18n.client.DateTimeFormat;
79
import com.google.gwt.i18n.client.DateTimeFormat;
77
import com.google.gwt.user.client.Window;
80
import com.google.gwt.user.client.Window;
78
import com.google.gwt.user.client.ui.Widget;
81
import com.google.gwt.user.client.ui.Widget;
79
 
82
 
80
public class PersonneForm extends Formulaire implements Rafraichissable {
83
public class PersonneForm extends Formulaire implements Rafraichissable {
81
 
84
 
82
	// VARIABLES
85
	// VARIABLES
83
	private TabItem tiIdentite, tiAdresses, tiInfosNat;
86
	private TabItem tiIdentite, tiAdresses, tiInfosNat;
84
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
87
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
85
	private Personne personneSelectionnee, personneSauvegarde = null;
88
	private Personne personneSelectionnee, personneSauvegarde = null;
86
	
89
	
87
	//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
90
	//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
88
	private HashMap<String, Widget>hmIdentite = new HashMap<String, Widget>();
91
	private HashMapComposants hmIdentite = new HashMapComposants();
89
	private HashMap<String, Widget>hmAdresse = new HashMap<String, Widget>();
92
	private HashMap<String, Widget>hmAdresse = new HashMap<String, Widget>();
90
	private HashMap<String, Widget>hmInfosNat = new HashMap<String, Widget>();
93
	private HashMap<String, Widget>hmInfosNat = new HashMap<String, Widget>();
91
	private HashMap<String, Valeur> hmCbSelectionnee = new HashMap();
94
	private HashMap<String, Valeur> hmCbSelectionnee = new HashMap();
92
	private FormData fd100 = new FormData("95%");
95
	private FormData fd100 = new FormData("95%");
93
	
96
	
94
	private Button enregistrer, enregistrerEtRevenir;
97
	private Button enregistrer, enregistrerEtRevenir;
95
	
98
	
96
	private Personne personne = null;
99
	private Personne personne = null;
97
	private String personneId = null;
100
	private String personneId = null;
98
	private FormBinding binding = null;
101
	private FormBinding binding = null;
99
	
102
	
100
	// CONSTRUCTEUR 
103
	// CONSTRUCTEUR 
101
	public PersonneForm(Mediateur mediateurCourrant, String personneId) {
104
	public PersonneForm(Mediateur mediateurCourrant, String personneId) {
102
		initialiserPersonneForm(mediateurCourrant, personneId);
105
		initialiserPersonneForm(mediateurCourrant, personneId);
103
	}
106
	}
104
	
107
	
105
	public PersonneForm(Mediateur mediateurCourrant, String personneId, Rafraichissable vueARafraichirApresValidation) {
108
	public PersonneForm(Mediateur mediateurCourrant, String personneId, Rafraichissable vueARafraichirApresValidation) {
106
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
109
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
107
		initialiserPersonneForm(mediateurCourrant, personneId);
110
		initialiserPersonneForm(mediateurCourrant, personneId);
108
	}
111
	}
109
	
112
	
110
	private void initialiserPersonneForm(Mediateur mediateurCourrant, String personneIdCourrant) {
113
	private void initialiserPersonneForm(Mediateur mediateurCourrant, String personneIdCourrant) {
111
		personne = new Personne();
114
		personne = new Personne();
112
		personne.setId(personneIdCourrant);
115
		personne.setId(personneIdCourrant);
113
		personneId = personneIdCourrant;
116
		personneId = personneIdCourrant;
114
		
117
		
115
		String modeDeCreation = (UtilString.isEmpty(personneId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
118
		String modeDeCreation = (UtilString.isEmpty(personneId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
116
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PERSONNE);
119
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PERSONNE);
117
 
120
 
118
		initialiserComposants();
121
		initialiserComposants();
119
		genererTitreFormulaire();
122
		genererTitreFormulaire();
120
		
123
		
121
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
124
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
122
			mediateur.selectionnerPersonne(this, personne, null);
125
			mediateur.selectionnerPersonne(this, personne, null);
123
		}
126
		}
124
	}
127
	}
125
	
128
	
126
	private void genererTitreFormulaire() {
129
	private void genererTitreFormulaire() {
127
		String titre = i18nC.personneModeAjout();
130
		String titre = i18nC.personneModeAjout();
128
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
131
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
129
			 titre = i18nC.personneModeModifier()+" - "+i18nC.id()+": "+personneId;
132
			 titre = i18nC.personneModeModifier()+" - "+i18nC.id()+": "+personneId;
130
		}
133
		}
131
		panneauFormulaire.setHeading(titre);
134
		panneauFormulaire.setHeading(titre);
132
	}
135
	}
133
	
136
	
134
	public void initialiserComposants()	{
137
	public void initialiserComposants()	{
135
		personneSelectionnee = new Personne();
138
		personneSelectionnee = new Personne();
136
		personneSauvegarde = new Personne();
139
		personneSauvegarde = new Personne();
137
		
140
		
138
		initialiserOnglets();	
141
		initialiserOnglets();	
139
		
142
		
140
		creerComposantsIdentite();
143
		creerComposantsIdentite();
141
		creerComposantsAdresse();
144
		creerComposantsAdresse();
142
		creerComposantsInfosNat();
145
		creerComposantsInfosNat();
143
		
146
		
144
		binderPersonne(personneSelectionnee);
147
		binderPersonne(personneSelectionnee);
145
	}
148
	}
146
	
149
	
147
	/**
150
	/**
148
	 * Crée les onglets identité, adresse et informations naturaliste
151
	 * Crée les onglets identité, adresse et informations naturaliste
149
	 * 
152
	 * 
150
	 * */
153
	 * */
151
	public void initialiserOnglets()	{
154
	public void initialiserOnglets()	{
152
		//TabPanel
155
		//TabPanel
153
		TabPanel formulaireOnglets = new TabPanel();
156
		TabPanel formulaireOnglets = new TabPanel();
154
		
157
		
155
		//Tab 1 : identite
158
		//Tab 1 : identite
156
		tiIdentite = new TabItem(i18nC.personneIdentite());
159
		tiIdentite = new TabItem(i18nC.personneIdentite());
157
		tiIdentite.setLayout(new FormLayout());
160
		tiIdentite.setLayout(new FormLayout());
158
		tiIdentite.setScrollMode(Scroll.AUTO);
161
		tiIdentite.setScrollMode(Scroll.AUTO);
159
		
162
		
160
		formulaireOnglets.add(tiIdentite);
163
		formulaireOnglets.add(tiIdentite);
161
		hmIdentite.put("tiIdentite", tiIdentite);
164
		hmIdentite.put("tiIdentite", tiIdentite);
162
		
165
		
163
		//Tab 2 : Adresse
166
		//Tab 2 : Adresse
164
		tiAdresses = new TabItem(i18nC.adresse());
167
		tiAdresses = new TabItem(i18nC.adresse());
165
		tiAdresses.setLayout(new FormLayout());
168
		tiAdresses.setLayout(new FormLayout());
166
		tiAdresses.setScrollMode(Scroll.AUTO);
169
		tiAdresses.setScrollMode(Scroll.AUTO);
167
		formulaireOnglets.add(tiAdresses);
170
		formulaireOnglets.add(tiAdresses);
168
		
171
		
169
		//Tab 3 : Infos Naturalistes
172
		//Tab 3 : Infos Naturalistes
170
		tiInfosNat = new TabItem(i18nC.personneInfoNat());
173
		tiInfosNat = new TabItem(i18nC.personneInfoNat());
171
		tiInfosNat.setLayout(new FormLayout());
174
		tiInfosNat.setLayout(new FormLayout());
172
		tiInfosNat.setScrollMode(Scroll.AUTO);
175
		tiInfosNat.setScrollMode(Scroll.AUTO);
173
		
176
		
174
		formulaireOnglets.add(tiInfosNat);
177
		formulaireOnglets.add(tiInfosNat);
175
		getFormulaire().add(formulaireOnglets);
178
		getFormulaire().add(formulaireOnglets);
176
	}
179
	}
177
	
180
	
178
	/**
181
	/**
179
	 * Crée les widgets pour l'onglet identité
182
	 * Crée les widgets pour l'onglet identité
180
	 * 
183
	 * 
181
	 * */
184
	 * */
182
	
185
	
183
	
186
	
184
	public void creerComposantsIdentite()	{
187
	public void creerComposantsIdentite()	{
185
		// Gestion de l'affichage en colonnes : 3 Layout container : principal, gauche & droite
188
		// Gestion de l'affichage en colonnes : 3 Layout container : principal, gauche & droite
186
		LayoutContainer left = new LayoutContainer();
189
		LayoutContainer left = new LayoutContainer();
187
		left.setLayout(new FormLayout());
190
		left.setLayout(new FormLayout());
188
		left.setStyleAttribute("padding", "15px");
191
		left.setStyleAttribute("padding", "15px");
189
		
192
		
190
		LayoutContainer right = new LayoutContainer();
193
		LayoutContainer right = new LayoutContainer();
191
		right.setLayout(new FormLayout());
194
		right.setLayout(new FormLayout());
192
		right.setStyleAttribute("padding", "15px");
195
		right.setStyleAttribute("padding", "15px");
193
		
196
		
194
		LayoutContainer main = new LayoutContainer();
197
		LayoutContainer main = new LayoutContainer();
195
		
198
		
196
		main.add(left, new ColumnData(.45));
199
		main.add(left, new ColumnData(.45));
197
		main.add(right, new ColumnData(.45));
200
		main.add(right, new ColumnData(.45));
198
		
201
		
199
		main.setLayout(new ColumnLayout());
202
		main.setLayout(new ColumnLayout());
200
		main.setHeight("100%");
203
		main.setHeight("100%");
201
		main.setScrollMode(Scroll.AUTO);
204
		main.setScrollMode(Scroll.AUTO);
202
		
205
		
203
		// Création des champs
206
		// Création des champs
204
		FormLayout formLayout = new FormLayout();
207
		FormLayout formLayout = new FormLayout();
205
		formLayout.setLabelAlign(LabelAlign.LEFT);
208
		formLayout.setLabelAlign(LabelAlign.LEFT);
206
		
209
		
207
		FieldSet fsProjet = new FieldSet();
210
		FieldSet fsProjet = new FieldSet();
208
		fsProjet.setHeading(i18nC.menuProjet());
211
		fsProjet.setHeading(i18nC.menuProjet());
209
		fsProjet.setLayout(new FormLayout());
212
		fsProjet.setLayout(new FormLayout());
210
		
213
		
211
		ListStore<Projet> storeProjets = new ListStore<Projet>();
214
		ListStore<Projet> storeProjets = new ListStore<Projet>();
212
		ComboBox cbProjets = new ComboBox<Projet>();
215
		ComboBox cbProjets = new ComboBox<Projet>();
213
		cbProjets.setFieldLabel(i18nC.personneProjet()+ " :");
216
		cbProjets.setFieldLabel(i18nC.personneProjet()+ " :");
214
		cbProjets.setEmptyText(i18nC.txtListeProjetDefaut());
217
		cbProjets.setEmptyText(i18nC.txtListeProjetDefaut());
215
		cbProjets.setLabelSeparator("");
218
		cbProjets.setLabelSeparator("");
216
		cbProjets.setDisplayField("nom");
219
		cbProjets.setDisplayField("nom");
217
		cbProjets.setEditable(false);
220
		cbProjets.setEditable(false);
218
		cbProjets.setTriggerAction(TriggerAction.ALL);
221
		cbProjets.setTriggerAction(TriggerAction.ALL);
219
		cbProjets.setStore(storeProjets);
222
		cbProjets.setStore(storeProjets);
220
		cbProjets.setAllowBlank(false);
223
		cbProjets.setAllowBlank(false);
221
		fsProjet.add(cbProjets);
224
		fsProjet.add(cbProjets);
222
		
225
		
223
		hmIdentite.put("cbProjets", cbProjets);
226
		hmIdentite.put("cbProjets", cbProjets);
224
		
227
		
225
		mediateur.selectionnerProjet(this, null);
228
		mediateur.selectionnerProjet(this, null);
226
				
229
				
227
		left.add(fsProjet);
230
		left.add(fsProjet);
228
					
231
					
229
		FieldSet fsNoms = new FieldSet();
232
		FieldSet fsNoms = new FieldSet();
230
		fsNoms.setHeading("Noms");
233
		fsNoms.setHeading("Noms");
231
		fsNoms.setLayout(formLayout); 
234
		fsNoms.setLayout(formLayout); 
232
					
235
					
233
		// Nom complet : Affiché que si valeurs saisies
236
		// Nom complet : Affiché que si valeurs saisies
234
		LabelField nomComplet = new LabelField();
237
		LabelField nomComplet = new LabelField();
235
		nomComplet.setFieldLabel(i18nC.personneNomComplet() +" :");
238
		nomComplet.setFieldLabel(i18nC.personneNomComplet() +" :");
236
		nomComplet.hide();
239
		nomComplet.hide();
237
				
240
				
238
		fsNoms.add(nomComplet);
241
		fsNoms.add(nomComplet);
239
		hmIdentite.put("nomComplet", nomComplet);
242
		hmIdentite.put("nomComplet", nomComplet);
240
			
243
			
241
		//Préfixe
244
		//Préfixe
242
		ListStore<Valeur> storePrefixe = new ListStore<Valeur>();
245
		ListStore<Valeur> storePrefixe = new ListStore<Valeur>();
243
		ComboBox<Valeur> cbPrefixe = new ComboBox<Valeur>();
246
		ComboBox<Valeur> cbPrefixe = new ComboBox<Valeur>();
244
		cbPrefixe.setStore(storePrefixe);
247
		cbPrefixe.setStore(storePrefixe);
245
		cbPrefixe.setDisplayField("nom");
248
		cbPrefixe.setDisplayField("nom");
246
		cbPrefixe.setEmptyText("Choisissez le préfixe:");
249
		cbPrefixe.setEmptyText("Choisissez le préfixe:");
247
		cbPrefixe.setFieldLabel("Prefix");
250
		cbPrefixe.setFieldLabel("Prefix");
248
		
251
		
249
		fsNoms.add(cbPrefixe);
252
		fsNoms.add(cbPrefixe);
250
		hmIdentite.put("cbPrefixe", cbPrefixe);
253
		hmIdentite.put("cbPrefixe", cbPrefixe);
251
		
254
		
252
		mediateur.obtenirListeValeurEtRafraichir(this, "prefixe");
255
		mediateur.obtenirListeValeurEtRafraichir(this, "prefixe");
253
 
256
 
254
		//Prénom
257
		//Prénom
255
		TextField<String> tfPrenom = new TextField<String>();
258
		TextField<String> tfPrenom = new TextField<String>();
256
		tfPrenom.setFieldLabel("Prénom");
259
		tfPrenom.setFieldLabel("Prénom");
257
		tfPrenom.setName("prenom");
260
		tfPrenom.setName("prenom");
258
 
261
 
259
		fsNoms.add(tfPrenom);
262
		fsNoms.add(tfPrenom);
260
		hmIdentite.put("tfPrenom", tfPrenom);
263
		hmIdentite.put("tfPrenom", tfPrenom);
261
 
264
 
262
		//Nom
265
		//Nom
263
		TextField<String> tfNom = new TextField<String>();
266
		TextField<String> tfNom = new TextField<String>();
264
		tfNom.setFieldLabel("Nom");
267
		tfNom.setFieldLabel("Nom");
265
		tfNom.setAllowBlank(false);
268
		tfNom.setAllowBlank(false);
266
		tfNom.setName("nom");
269
		tfNom.setName("nom");
267
		
270
		
268
		fsNoms.add(tfNom);
271
		fsNoms.add(tfNom);
269
		hmIdentite.put("tfNom", tfNom);
272
		hmIdentite.put("tfNom", tfNom);
270
		
273
		
271
		//Suffixe
274
		//Suffixe
272
		ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();
275
		ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();
273
		ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();
276
		ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();
274
		cbSuffixe.setStore(storeSuffixe);
277
		cbSuffixe.setStore(storeSuffixe);
275
		cbSuffixe.setFieldLabel("Suffixe");
278
		cbSuffixe.setFieldLabel("Suffixe");
276
		cbSuffixe.setDisplayField("nom");
279
		cbSuffixe.setDisplayField("nom");
277
		cbSuffixe.setEmptyText("Choisissez un suffixe:");
280
		cbSuffixe.setEmptyText("Choisissez un suffixe:");
278
		
281
		
279
		fsNoms.add(cbSuffixe);			
282
		fsNoms.add(cbSuffixe);			
280
		hmIdentite.put("cbSuffixe", cbSuffixe);
283
		hmIdentite.put("cbSuffixe", cbSuffixe);
281
		
284
		
282
		mediateur.obtenirListeValeurEtRafraichir(this, "suffixes");
285
		mediateur.obtenirListeValeurEtRafraichir(this, "suffixes");
283
 
286
 
284
		TextField<String> tfAbreviation = new TextField<String>();
287
		TextField<String> tfAbreviation = new TextField<String>();
285
		tfAbreviation.setFieldLabel("Abréviation");
288
		tfAbreviation.setFieldLabel("Abréviation");
286
		tfAbreviation.setName("abreviation");
289
		tfAbreviation.setName("abreviation");
287
		
290
		
288
		fsNoms.add(tfAbreviation);
291
		fsNoms.add(tfAbreviation);
289
		hmIdentite.put("tfAbreviation", tfAbreviation);
292
		hmIdentite.put("tfAbreviation", tfAbreviation);
290
 
293
 
291
		TableLayout layoutAutreNoms = new TableLayout(2);
294
		TableLayout layoutAutreNoms = new TableLayout(2);
292
		layoutAutreNoms.setCellVerticalAlign(VerticalAlignment.TOP);
295
		layoutAutreNoms.setCellVerticalAlign(VerticalAlignment.TOP);
293
		LayoutContainer autresNoms = new LayoutContainer(layoutAutreNoms);
296
		LayoutContainer autresNoms = new LayoutContainer(layoutAutreNoms);
294
		ChampMultiValeurs nomAutre = new ChampMultiValeurs("Autres noms",150);
297
		ChampMultiValeurs nomAutre = new ChampMultiValeurs("Autres noms",150);
295
		hmIdentite.put("nomAutre", nomAutre);
298
		hmIdentite.put("nomAutre", nomAutre);
296
		autresNoms.add(nomAutre, new TableData("200px", "15px"));
299
		autresNoms.add(nomAutre, new TableData("200px", "15px"));
297
		
300
		
298
		ChampMultiValeurs abreviationAutre = new ChampMultiValeurs("Autres abréviation",150);
301
		ChampMultiValeurs abreviationAutre = new ChampMultiValeurs("Autres abréviation",150);
299
		hmIdentite.put("abreviationAutre", abreviationAutre);
302
		hmIdentite.put("abreviationAutre", abreviationAutre);
300
		autresNoms.add(abreviationAutre, new TableData("200px", "15px"));
303
		autresNoms.add(abreviationAutre, new TableData("200px", "15px"));
301
		fsNoms.add(autresNoms);
304
		fsNoms.add(autresNoms);
302
										
305
										
303
		left.add(fsNoms);
306
		left.add(fsNoms);
304
		
-
 
305
		formLayout = new FormLayout();
-
 
306
		formLayout.setLabelAlign(LabelAlign.LEFT);
-
 
307
		
307
		
308
		FieldSet fsNaissance = new FieldSet();
308
		FieldSet fsNaissanceEtDeces = new FieldSet();
309
		fsNaissance.setHeading("Naissance");
309
		fsNaissanceEtDeces.setHeading("Naissance et Décès");
-
 
310
		fsNaissanceEtDeces.setLayout(new ColumnLayout()); 
-
 
311
		
-
 
312
		formLayout = new FormLayout();
-
 
313
		formLayout.setLabelAlign(LabelAlign.TOP);
310
		fsNaissance.setLayout(formLayout); 
314
		LayoutContainer containerNaissance = new LayoutContainer(formLayout);
311
		
315
				
312
		DateField dfDateNaissance = new DateField();
316
		DateField dfDateNaissance = new DateField();
313
		dfDateNaissance.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
317
		dfDateNaissance.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
314
		dfDateNaissance.setFieldLabel("Date");
318
		dfDateNaissance.setFieldLabel("Date de naissance");
315
		dfDateNaissance.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");
319
		dfDateNaissance.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");
316
		
320
		
317
		fsNaissance.add(dfDateNaissance);
321
		containerNaissance.add(dfDateNaissance);
318
		hmIdentite.put("dfDateNaissance", dfDateNaissance);
322
		hmIdentite.put("dfDateNaissance", dfDateNaissance);
319
		
323
		
320
		// Lieu naissance
324
		// Lieu naissance
321
		TextField<String> tfLieuNaissance = new TextField<String>();
325
		TextField<String> tfLieuNaissance = new TextField<String>();
322
		tfLieuNaissance.setFieldLabel("Lieu");
326
		tfLieuNaissance.setFieldLabel("Lieu de naissance");
323
		tfLieuNaissance.setName("naissance_lieu");
327
		tfLieuNaissance.setName("naissance_lieu");
324
		
328
		
325
		fsNaissance.add(tfLieuNaissance);
329
		containerNaissance.add(tfLieuNaissance);
326
		hmIdentite.put("tfLieuNaissance", tfLieuNaissance);
330
		hmIdentite.put("tfLieuNaissance", tfLieuNaissance);
-
 
331
		
327
			
332
		fsNaissanceEtDeces.add(containerNaissance, new ColumnData(.5));
328
		left.add(fsNaissance);
333
		left.add(fsNaissanceEtDeces);
329
		
334
		
-
 
335
		formLayout = new FormLayout();
330
		formLayout = new FormLayout();
-
 
331
		formLayout.setLabelAlign(LabelAlign.LEFT);
-
 
332
		
-
 
333
		FieldSet fsDeces = new FieldSet();
-
 
334
		fsDeces.setHeading("Décès");
336
		formLayout.setLabelAlign(LabelAlign.TOP);
-
 
337
		LayoutContainer containerDeces = new LayoutContainer(formLayout);
-
 
338
		
335
		fsDeces.setLayout(formLayout); 
339
		Radio rbEstDecedee = new Radio();
336
			
340
		rbEstDecedee.setId("ce_deces");
-
 
341
		
337
		Radio rbEstDecedee = new Radio();
342
		rbEstDecedee.setBoxLabel("oui");
338
		rbEstDecedee.setBoxLabel("oui");
343
		rbEstDecedee.setValueAttribute("1");
339
		rbEstDecedee.setValueAttribute("1");
344
		rbEstDecedee.setId("rbEstD");
340
	
345
		
341
		rbEstDecedee.addListener(Events.Change, new Listener<ComponentEvent>() {
346
		rbEstDecedee.addListener(Events.Change, new Listener<ComponentEvent>() {
342
						
347
						
343
			public void handleEvent(ComponentEvent be) {
348
			public void handleEvent(ComponentEvent be) {
344
				if(((Radio) be.getComponent()).getValue().equals(true))	{
349
				if(((Radio) be.getComponent()).getValue().equals(true))	{
345
					((DateField) hmIdentite.get("dfDateDeces")).setVisible(true);
350
					hmIdentite.getDateField("dfDateDeces").setVisible(true);
346
					((TextField) hmIdentite.get("tfLieuDeces")).setVisible(true);
351
					hmIdentite.getTextField("tfLieuDeces").setVisible(true);
347
				} else	{
352
				} else	{
348
					DateField dfDateDeces = ((DateField) hmIdentite.get("dfDateDeces"));
353
					DateField dfDateDeces = hmIdentite.getDateField("dfDateDeces");
349
					dfDateDeces.setValue(null);
354
					dfDateDeces.setValue(null);
350
					dfDateDeces.setVisible(false);
355
					dfDateDeces.setVisible(false);
351
					
356
					
352
					TextField tfLieuDeces = ((TextField) hmIdentite.get("tfLieuDeces"));
357
					TextField tfLieuDeces = hmIdentite.getTextField("tfLieuDeces");
353
					tfLieuDeces.setValue(null);
358
					tfLieuDeces.setValue(null);
354
					tfLieuDeces.setVisible(false);
359
					tfLieuDeces.setVisible(false);
355
				}
360
				}
356
			}	
361
			}	
357
		});
362
		});
358
					
-
 
359
		hmIdentite.put("rbEstDecedee", rbEstDecedee);
-
 
360
		
-
 
361
		Radio rbNestPasDecedee = new Radio();
-
 
362
		rbNestPasDecedee.setValueAttribute("0");
-
 
363
		rbNestPasDecedee.setBoxLabel("non");
-
 
364
		rbNestPasDecedee.setValue(true);
-
 
365
		
-
 
366
	/*	Radio rbDecesInconnu = new Radio();
-
 
367
		rbDecesInconnu.setBoxLabel("Ne sais pas");
-
 
368
		rbDecesInconnu.setValue(true);*/
-
 
369
		
-
 
370
		RadioGroup rbgDeces = new RadioGroup();
-
 
371
		rbgDeces.setFieldLabel("Est décédée");
-
 
372
		rbgDeces.add(rbEstDecedee);
-
 
373
		rbgDeces.add(rbNestPasDecedee);
-
 
374
		
-
 
375
		fsDeces.add(rbgDeces);
-
 
376
		
363
					
377
		DateField dfDateDeces = new DateField();
364
		DateField dfDateDeces = new DateField();
378
		dfDateDeces.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
365
		dfDateDeces.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
379
		dfDateDeces.setFormatValue(true);
366
		dfDateDeces.setFormatValue(true);
380
		dfDateDeces.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");
367
		dfDateDeces.getMessages().setInvalidText("La valeur saisie n'est pas une date valide. La date doit être au format «jj/mm/aaaa».");
381
		dfDateDeces.setFieldLabel("Date");
368
		dfDateDeces.setFieldLabel("Date de décès");
382
		dfDateDeces.setVisible(false);
369
		dfDateDeces.setVisible(false);
383
 
370
 
384
		fsDeces.add(dfDateDeces);
371
		containerDeces.add(dfDateDeces);
385
		hmIdentite.put("dfDateDeces", dfDateDeces);
372
		hmIdentite.put("dfDateDeces", dfDateDeces);
386
 
373
 
387
		TextField<String> tfLieuDeces = new TextField<String>();
374
		TextField<String> tfLieuDeces = new TextField<String>();
388
		tfLieuDeces.setFieldLabel("Lieu");
375
		tfLieuDeces.setFieldLabel("Lieu de décès");
389
		tfLieuDeces.setName("deces_lieu");
376
		tfLieuDeces.setName("deces_lieu");
390
		tfLieuDeces.setVisible(false);
377
		tfLieuDeces.setVisible(false);
391
		
378
		
392
		fsDeces.add(tfLieuDeces);
379
		containerDeces.add(tfLieuDeces);
-
 
380
		hmIdentite.put("tfLieuDeces", tfLieuDeces);
393
		hmIdentite.put("tfLieuDeces", tfLieuDeces);
381
		hmIdentite.put("rbEstDecedee", rbEstDecedee);
-
 
382
		
-
 
383
		Radio rbNestPasDecedee = new Radio();
-
 
384
		rbNestPasDecedee.setValueAttribute("0");
394
								
385
		rbNestPasDecedee.setBoxLabel("non");
-
 
386
		rbNestPasDecedee.setValue(true);
-
 
387
			
-
 
388
		RadioGroup rbgDeces = new RadioGroup();
-
 
389
		rbgDeces.setFieldLabel("Est décédée");
-
 
390
		rbgDeces.add(rbEstDecedee);
-
 
391
		rbgDeces.add(rbNestPasDecedee);
-
 
392
		
-
 
393
		containerDeces.add(rbgDeces);
395
		left.add(fsDeces);
394
		
396
			
395
		fsNaissanceEtDeces.add(containerDeces, new ColumnData(.5));
397
		tiIdentite.add(main);
396
		tiIdentite.add(main);
398
			
397
			
-
 
398
		FieldSet fsContact = new FieldSet();
399
		FieldSet fsContactTel = new FieldSet();
399
		fsContact.setHeading("Contact");
400
		fsContactTel.setHeading("Contact - Téléphones");
400
		fsContact.setLayout(new RowLayout());
401
		fsContactTel.setLayout(new RowLayout());
401
		
402
		
402
		LayoutContainer containerTelEtEmail = new LayoutContainer(new ColumnLayout());
403
		
-
 
404
		ChampMultiValeursMultiTypes telephones = new ChampMultiValeursMultiTypes("Téléphones");
-
 
405
		hmIdentite.put("telephones", telephones);
-
 
406
		telephones.initialiserType("tel");
-
 
407
		fsContactTel.add(telephones);
-
 
408
		right.add(fsContactTel);
-
 
409
		hmIdentite.put("fsContactTel", fsContactTel);
-
 
410
				
-
 
411
		
-
 
412
		FieldSet fsContact = new FieldSet();
-
 
413
		fsContact.setHeading("Contact - Autres");
-
 
414
		fsContact.setId("fsContact");
403
		
415
		fsContact.setLayout(new RowLayout());
404
		ChampMultiValeursMultiTypes telephones = new ChampMultiValeursMultiTypes("Téléphones", 180, 100);
-
 
405
		hmIdentite.put("telephones", telephones);
416
 
406
		telephones.initialiserType("tel");
-
 
407
		containerTelEtEmail.add(telephones, new ColumnData(.5));
417
		right.add(fsContact);
408
		
418
		hmIdentite.put("fsContact", fsContact);
409
		ChampMultiValeurs courriels = new ChampMultiValeurs("Courriels", 280);
419
 
410
		courriels.setValidation(Pattern.email, "moi@domaine.fr");
420
		ChampMultiValeurs courriels = new ChampMultiValeurs("Courriels");
411
		containerTelEtEmail.add(courriels, new ColumnData(.5));
421
		courriels.setValidation(Pattern.email, "moi@domaine.fr");
412
		fsContact.add(containerTelEtEmail);
422
		fsContact.add(courriels);
413
		right.add(fsContact);
423
		hmIdentite.put("courriels", courriels);
414
		hmIdentite.put("courriels", courriels);
424
		
415
		
425
		LayoutContainer lcCourrielContainer = new LayoutContainer(new RowLayout());
416
		LayoutContainer lcCourrielContainer = new LayoutContainer(new RowLayout());
426
		
-
 
427
		fsContact.add(lcCourrielContainer);
417
		fsContact.add(lcCourrielContainer);
428
		hmIdentite.put("lcCourrielContainer", lcCourrielContainer);
418
		hmIdentite.put("lcCourrielContainer", lcCourrielContainer);
-
 
419
 
-
 
420
		fsContact.add(new Text(""));
429
 
421
		
430
		ChampMultiValeurs sites = new ChampMultiValeurs("Sites web");
422
		ChampMultiValeurs sites = new ChampMultiValeurs("Sites web");
431
		sites.setValeurParDefaut("http://");
423
		sites.setValeurParDefaut("http://");
432
		sites.setValidation(Pattern.url, "http://www.monsite.com");
424
		sites.setValidation(Pattern.url, "http://www.monsite.com");
433
		fsContact.add(sites);
425
		fsContact.add(sites);
434
		hmIdentite.put("sites", sites);
426
		hmIdentite.put("sites", sites);
435
			
427
			
436
		FieldSet fsAutresInfos = new FieldSet();
428
		FieldSet fsAutresInfos = new FieldSet();
437
		fsAutresInfos.setHeading("Autres informations");
429
		fsAutresInfos.setHeading("Autres informations");
438
	
430
	
439
		formLayout = new FormLayout();
431
		formLayout = new FormLayout();
440
		formLayout.setLabelAlign(LabelAlign.LEFT);
432
		formLayout.setLabelAlign(LabelAlign.LEFT);
441
		fsAutresInfos.setLayout(formLayout); 
433
		fsAutresInfos.setLayout(formLayout); 
442
			
434
			
443
				
435
				
444
		formLayout = new FormLayout();
436
		formLayout = new FormLayout();
445
		formLayout.setLabelAlign(LabelAlign.TOP);
437
		formLayout.setLabelAlign(LabelAlign.TOP);
446
		LayoutContainer lcAutreInformations1 = new LayoutContainer(formLayout);
438
		LayoutContainer lcAutreInformations1 = new LayoutContainer(formLayout);
447
							
439
							
448
		//Civilité				
440
		//Civilité				
449
		ListStore<Valeur> storeSexe = new ListStore<Valeur>();
441
		ListStore<Valeur> storeSexe = new ListStore<Valeur>();
450
		ComboBox<Valeur> cbSexe = new ComboBox<Valeur>();
442
		ComboBox<Valeur> cbSexe = new ComboBox<Valeur>();
451
		cbSexe.setStore(storeSexe);
443
		cbSexe.setStore(storeSexe);
452
		cbSexe.setFieldLabel("Sexe");
444
		cbSexe.setFieldLabel("Sexe");
453
		cbSexe.setDisplayField("nom");
445
		cbSexe.setDisplayField("nom");
454
		cbSexe.setEmptyText("Choisissez le sexe:");
446
		cbSexe.setEmptyText("Choisissez le sexe:");
455
	
447
		
-
 
448
		FormData fd = new FormData();
-
 
449
		fd.setWidth(100);
456
		lcAutreInformations1.add(cbSexe, new FormData(100, 10));			
450
		lcAutreInformations1.add(cbSexe, fd);			
457
		hmIdentite.put("cbSexe", cbSexe);
451
		hmIdentite.put("cbSexe", cbSexe);
458
	
452
	
459
		mediateur.obtenirListeValeurEtRafraichir(this, "sexe");			
453
		mediateur.obtenirListeValeurEtRafraichir(this, "sexe");			
460
		
454
		
461
		//Description
455
		//Description
462
		TextArea taDescription = new TextArea();
456
		TextArea taDescription = new TextArea();
463
		taDescription.setEmptyText("Saisissez une description");
457
		taDescription.setEmptyText("Saisissez une description");
464
		taDescription.setFieldLabel("Description");
458
		taDescription.setFieldLabel("Description");
465
		taDescription.setWidth("100%");
459
		taDescription.setWidth("100%");
466
		taDescription.setName("description");
460
		taDescription.setName("description");
467
		
461
		
468
		lcAutreInformations1.add(taDescription, fd100);
462
		lcAutreInformations1.add(taDescription, fd100);
469
		hmIdentite.put("taDescription", taDescription);
463
		hmIdentite.put("taDescription", taDescription);
470
		
464
		
471
		fsAutresInfos.add(lcAutreInformations1);
465
		fsAutresInfos.add(lcAutreInformations1);
472
		
466
		
473
		// Logo
467
		// Logo
474
		LayoutContainer lcLogoUrl = new LayoutContainer();
468
		LayoutContainer lcLogoUrl = new LayoutContainer();
475
		hmIdentite.put("lcLogoUrl", lcLogoUrl);
469
		hmIdentite.put("lcLogoUrl", lcLogoUrl);
476
		
470
		
477
		ChampMultiValeursImage logo = new ChampMultiValeursImage(i18nC.personneLogos());
471
		ChampMultiValeursImage logo = new ChampMultiValeursImage(i18nC.personneLogos());
478
		logo.setImageHeight("150px");
472
		logo.setImageHeight("150px");
479
		logo.setValeurParDefaut("http://");
473
		logo.setValeurParDefaut("http://");
480
		logo.setValidation(Pattern.url, "http://www.monsite.com/mon_image.jpg");
474
		logo.setValidation(Pattern.url, "http://www.monsite.com/mon_image.jpg");
481
		logo.setValeurBoutonSupprimer("Supprimer");
475
		logo.setValeurBoutonSupprimer("Supprimer");
482
		hmIdentite.put("logos", logo);
476
		hmIdentite.put("logos", logo);
483
		
477
		
484
		lcLogoUrl.add(logo);
478
		lcLogoUrl.add(logo);
485
		
479
		
486
		fsAutresInfos.add(logo);
480
		fsAutresInfos.add(logo);
487
		
481
		
488
		LayoutContainer lcAutreInformations2 = new LayoutContainer(new ColumnLayout());
482
		LayoutContainer lcAutreInformations2 = new LayoutContainer(new ColumnLayout());
489
		hmIdentite.put("lcAutreInformations2", lcAutreInformations2);
483
		hmIdentite.put("lcAutreInformations2", lcAutreInformations2);
490
		fsAutresInfos.add(lcAutreInformations2);
484
		fsAutresInfos.add(lcAutreInformations2);
491
			
485
			
492
		right.add(fsAutresInfos);
486
		right.add(fsAutresInfos);
493
			
487
			
494
		// Ajout des évènements saisi
488
		// Ajout des évènements saisi
495
		KeyListener klNoms = new KeyListener()	{
489
		KeyListener klNoms = new KeyListener()	{
496
			public void componentKeyUp(ComponentEvent ev)	{
490
			public void componentKeyUp(ComponentEvent ev)	{
497
				rafraichir(null);	
491
				rafraichir(null);	
498
			}				
492
			}				
499
		};
493
		};
500
		
494
		
501
		SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
495
		SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
502
			public void selectionChanged(SelectionChangedEvent se) {
496
			public void selectionChanged(SelectionChangedEvent se) {
503
				rafraichir(null);
497
				rafraichir(null);
504
			}
498
			}
505
		};
499
		};
506
						
500
						
507
		cbPrefixe.addSelectionChangedListener(selectionChange);
501
		cbPrefixe.addSelectionChangedListener(selectionChange);
508
		cbPrefixe.addKeyListener(klNoms);
502
		cbPrefixe.addKeyListener(klNoms);
509
		tfPrenom.addKeyListener(klNoms);
503
		tfPrenom.addKeyListener(klNoms);
510
		tfNom.addKeyListener(klNoms);
504
		tfNom.addKeyListener(klNoms);
511
		cbSuffixe.addSelectionChangedListener(selectionChange);		
505
		cbSuffixe.addSelectionChangedListener(selectionChange);		
512
			
506
			
513
	}
507
	}
514
	
508
	
515
	public void creerComposantsAdresse()	{
509
	public void creerComposantsAdresse()	{
516
		// Gauche
510
		// Gauche
517
		LayoutContainer left = new LayoutContainer();
511
		LayoutContainer left = new LayoutContainer();
518
		left.setLayout(new FormLayout());
512
		left.setLayout(new FormLayout());
519
		left.setStyleAttribute("padding", "15px");
513
		left.setStyleAttribute("padding", "15px");
520
		// Droite
514
		// Droite
521
		LayoutContainer right = new LayoutContainer();
515
		LayoutContainer right = new LayoutContainer();
522
		right.setLayout(new FormLayout());
516
		right.setLayout(new FormLayout());
523
		
517
		
524
		// Principal
518
		// Principal
525
		LayoutContainer main = new LayoutContainer();
519
		LayoutContainer main = new LayoutContainer();
526
		main.setLayout(new TableLayout(2));
520
		main.setLayout(new TableLayout(2));
527
		
521
		
528
		// Ajout au principal
522
		// Ajout au principal
529
		main.add(left);
523
		main.add(left);
530
		main.add(right);	
524
		main.add(right);	
531
		
525
		
532
		TextField<String> tfAdresse1 = new TextField();
526
		TextField<String> tfAdresse1 = new TextField();
533
		tfAdresse1.setFieldLabel("Adresse");
527
		tfAdresse1.setFieldLabel("Adresse");
534
		tfAdresse1.setName("adresse_01");
528
		tfAdresse1.setName("adresse_01");
535
		left.add(tfAdresse1, fd100);
529
		left.add(tfAdresse1, fd100);
536
		hmAdresse.put("tfAdresse1", tfAdresse1);
530
		hmAdresse.put("tfAdresse1", tfAdresse1);
537
		
531
		
538
		TextField<String> tfAdresse2 = new TextField();
532
		TextField<String> tfAdresse2 = new TextField();
539
		tfAdresse2.setFieldLabel("Complément d'adresse");
533
		tfAdresse2.setFieldLabel("Complément d'adresse");
540
		tfAdresse2.setName("adresse_02");
534
		tfAdresse2.setName("adresse_02");
541
		left.add(tfAdresse2, fd100);
535
		left.add(tfAdresse2, fd100);
542
		hmAdresse.put("tfAdresse2", tfAdresse2);
536
		hmAdresse.put("tfAdresse2", tfAdresse2);
543
		
537
		
544
		ComboBox<Valeur> cbPays = new ComboBox<Valeur>();
538
		ComboBox<Valeur> cbPays = new ComboBox<Valeur>();
545
		cbPays.setFieldLabel("Pays");
539
		cbPays.setFieldLabel("Pays");
546
		cbPays.setDisplayField("nom");
540
		cbPays.setDisplayField("nom");
547
		cbPays.setEmptyText("Sélectionnez le pays:");
541
		cbPays.setEmptyText("Sélectionnez le pays:");
548
		
542
		
549
		ListStore<Valeur> storePays = new ListStore<Valeur>();
543
		ListStore<Valeur> storePays = new ListStore<Valeur>();
550
		cbPays.setStore(storePays);
544
		cbPays.setStore(storePays);
551
		
545
		
552
		right.add(cbPays, fd100);
546
		right.add(cbPays, fd100);
553
		hmAdresse.put("cbPays", cbPays);
547
		hmAdresse.put("cbPays", cbPays);
554
		
548
		
555
		SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
549
		SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
556
			public void selectionChanged(SelectionChangedEvent se) {
550
			public void selectionChanged(SelectionChangedEvent se) {
557
				// Rafraichir avec le pays sélectionné
551
				// Rafraichir avec le pays sélectionné
558
				obtenirListeRegionParPays(((Valeur) se.getSelectedItem()).getAbreviation().toString());
552
				obtenirListeRegionParPays(((Valeur) se.getSelectedItem()).getAbreviation().toString());
559
			}
553
			}
560
		};
554
		};
561
					
555
					
562
		cbPays.addSelectionChangedListener(selectionChange);
556
		cbPays.addSelectionChangedListener(selectionChange);
563
		
557
		
564
		
558
		
565
		ComboBox<Valeur> cbRegion = new ComboBox<Valeur>();
559
		ComboBox<Valeur> cbRegion = new ComboBox<Valeur>();
566
		cbRegion.setFieldLabel("Region");
560
		cbRegion.setFieldLabel("Region");
567
		cbRegion.setDisplayField("nom");
561
		cbRegion.setDisplayField("nom");
568
		cbRegion.setEmptyText("Sélectionnez la région:");
562
		cbRegion.setEmptyText("Sélectionnez la région:");
569
		cbRegion.setVisible(false);
563
		cbRegion.setVisible(false);
570
		
564
		
571
		ListStore<Valeur> storeRegion = new ListStore<Valeur>();
565
		ListStore<Valeur> storeRegion = new ListStore<Valeur>();
572
		cbRegion.setStore(storeRegion);
566
		cbRegion.setStore(storeRegion);
573
		
567
		
574
		
568
		
575
		right.add(cbRegion, fd100);
569
		right.add(cbRegion, fd100);
576
		hmAdresse.put("cbRegion", cbRegion);
570
		hmAdresse.put("cbRegion", cbRegion);
577
		
571
		
578
		TextField<String> tfBoitePostale = new TextField<String>();
572
		TextField<String> tfBoitePostale = new TextField<String>();
579
		tfBoitePostale.setFieldLabel("Boite postale");
573
		tfBoitePostale.setFieldLabel("Boite postale");
580
		tfBoitePostale.setName("bp");
574
		tfBoitePostale.setName("bp");
581
		
575
		
582
		left.add(tfBoitePostale, fd100);
576
		left.add(tfBoitePostale, fd100);
583
		hmAdresse.put("tfBoitePostale", tfBoitePostale);
577
		hmAdresse.put("tfBoitePostale", tfBoitePostale);
584
		
578
		
585
		TextField<Integer> tfCodePostal = new TextField<Integer>();
579
		TextField<Integer> tfCodePostal = new TextField<Integer>();
586
		tfCodePostal.setFieldLabel("Code postal");
580
		tfCodePostal.setFieldLabel("Code postal");
587
		tfCodePostal.setName("code_postal");
581
		tfCodePostal.setName("code_postal");
588
		
582
		
589
		right.add(tfCodePostal, fd100);
583
		right.add(tfCodePostal, fd100);
590
		hmAdresse.put("tfCodePostal", tfCodePostal);
584
		hmAdresse.put("tfCodePostal", tfCodePostal);
591
		
585
		
592
		TextField tfVille = new TextField();
586
		TextField tfVille = new TextField();
593
		tfVille.setFieldLabel("Ville");
587
		tfVille.setFieldLabel("Ville");
594
		tfVille.setName("ville");
588
		tfVille.setName("ville");
595
		
589
		
596
		right.add(tfVille, fd100);
590
		right.add(tfVille, fd100);
597
		hmAdresse.put("tfVille", tfVille);
591
		hmAdresse.put("tfVille", tfVille);
598
		
592
		
599
		// MAJ ComboBox
593
		// MAJ ComboBox
600
		mediateur.obtenirListeValeurEtRafraichir(this, "pays");
594
		mediateur.obtenirListeValeurEtRafraichir(this, "pays");
601
		
595
		
602
		FieldSet fsAdresse = new FieldSet();
596
		FieldSet fsAdresse = new FieldSet();
603
		fsAdresse.setHeading("Adresse personnelle");
597
		fsAdresse.setHeading("Adresse personnelle");
604
		fsAdresse.add(main);
598
		fsAdresse.add(main);
605
		
599
		
606
		tiAdresses.add(fsAdresse);
600
		tiAdresses.add(fsAdresse);
607
	}
601
	}
608
	
602
	
609
	public void creerComposantsInfosNat()	{
603
	public void creerComposantsInfosNat()	{
610
		
604
		
611
		FieldSet fsInfosNat = new FieldSet();
605
		FieldSet fsInfosNat = new FieldSet();
612
		fsInfosNat.setTitle("Informations Naturaliste");
606
		fsInfosNat.setTitle("Informations Naturaliste");
613
		
607
		
614
		ChampMultiValeurs specialite = new ChampMultiValeurs(i18nC.personneSpecialite());
608
		ChampMultiValeurs specialite = new ChampMultiValeurs(i18nC.personneSpecialite());
615
		fsInfosNat.add(specialite);
609
		fsInfosNat.add(specialite);
616
		hmInfosNat.put("specialite", specialite);
610
		hmInfosNat.put("specialite", specialite);
617
		
611
		
618
		ChampMultiValeursMultiTypes recolte = new ChampMultiValeursMultiTypes(i18nC.personneRecolte());
612
		ChampMultiValeursMultiTypes recolte = new ChampMultiValeursMultiTypes(i18nC.personneRecolte());
619
		recolte.initialiserType("pays");
613
		recolte.initialiserType("pays");
620
		hmInfosNat.put("recolte", recolte);
614
		hmInfosNat.put("recolte", recolte);
621
		
615
		
622
		fsInfosNat.add(recolte);
616
		fsInfosNat.add(recolte);
623
		tiInfosNat.add(fsInfosNat);
617
		tiInfosNat.add(fsInfosNat);
624
	}
618
	}
625
	
619
	
626
	
620
	
627
	
621
	
628
	/**
622
	/**
629
	 * Ajouter le bouton Sauvegarder et revenir à la liste à la barre d'outils donnée
623
	 * Ajouter le bouton Sauvegarder et revenir à la liste à la barre d'outils donnée
630
	 * 
624
	 * 
631
	 * @param barreOutils la barre d'outils à modifier
625
	 * @param barreOutils la barre d'outils à modifier
632
	 * */
626
	 * */
633
	private void ajouterBoutonEnregistrerEtRevenir(ButtonBar barreOutils)	{
627
	private void ajouterBoutonEnregistrerEtRevenir(ButtonBar barreOutils)	{
634
		
628
		
635
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
629
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
636
		enregistrerEtRevenir = new Button("Enregistrer et revenir à la liste");
630
		enregistrerEtRevenir = new Button("Enregistrer et revenir à la liste");
637
		enregistrerEtRevenir.setIcon(Images.ICONES.scriptGo());
631
		enregistrerEtRevenir.setIcon(Images.ICONES.scriptGo());
638
		enregistrerEtRevenir.setIconAlign(IconAlign.LEFT);
632
		enregistrerEtRevenir.setIconAlign(IconAlign.LEFT);
639
		enregistrerEtRevenir.addSelectionListener(new SelectionListener<ButtonEvent>() {  
633
		enregistrerEtRevenir.addSelectionListener(new SelectionListener<ButtonEvent>() {  
640
			public void componentSelected(ButtonEvent ce) {  
634
			public void componentSelected(ButtonEvent ce) {  
641
				if (enregistrer() == true)	{
635
				if (enregistrer() == true)	{
642
					((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
636
					((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
643
				}
637
				}
644
			}  
638
			}  
645
		});
639
		});
646
		
640
		
647
		hmIdentite.put("btnEnregistrerRevenir", enregistrerEtRevenir);
641
		hmIdentite.put("btnEnregistrerRevenir", enregistrerEtRevenir);
648
		barreOutils.add(enregistrerEtRevenir);
642
		barreOutils.add(enregistrerEtRevenir);
649
		enregistrerEtRevenir.setEnabled(false);
643
		enregistrerEtRevenir.setEnabled(false);
650
		
644
		
651
	}
645
	}
652
	
646
	
653
	/**
647
	/**
654
	 * Ajouter le bouton Sauvegarder à la barre d'outils donnée
648
	 * Ajouter le bouton Sauvegarder à la barre d'outils donnée
655
	 * 
649
	 * 
656
	 * @param barreOutils la barre d'outils à modifier
650
	 * @param barreOutils la barre d'outils à modifier
657
	 * */
651
	 * */
658
	private void ajouterBoutonEnregistrer(ButtonBar barreOutils)	{
652
	private void ajouterBoutonEnregistrer(ButtonBar barreOutils)	{
659
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
653
		//Le bouton réintialiser recharge la page sans sauvegarder les informations
660
		enregistrer = new Button("Enregistrer");
654
		enregistrer = new Button("Enregistrer");
661
		enregistrer.setIcon(Images.ICONES.scriptSave());
655
		enregistrer.setIcon(Images.ICONES.scriptSave());
662
		enregistrer.setIconAlign(IconAlign.LEFT);
656
		enregistrer.setIconAlign(IconAlign.LEFT);
663
		enregistrer.setId("main-button");
657
		enregistrer.setId("main-button");
664
		enregistrer.addSelectionListener(new SelectionListener<ButtonEvent>() {  
658
		enregistrer.addSelectionListener(new SelectionListener<ButtonEvent>() {  
665
			public void componentSelected(ButtonEvent ce) {  
659
			public void componentSelected(ButtonEvent ce) {  
666
				enregistrer();
660
				enregistrer();
667
			}  
661
			}  
668
		});
662
		});
669
		enregistrer.setEnabled(false);
663
		enregistrer.setEnabled(false);
670
		hmIdentite.put("btnEnregistrer", enregistrer);
664
		hmIdentite.put("btnEnregistrer", enregistrer);
671
		barreOutils.add(enregistrer);
665
		barreOutils.add(enregistrer);
672
	}
666
	}
673
	
667
	
674
	/**
668
	/**
675
	 * Ajouter le bouton annuler à la barre d'outils donnée
669
	 * Ajouter le bouton annuler à la barre d'outils donnée
676
	 * 
670
	 * 
677
	 * @param barreOutils la barre d'outils à modifier
671
	 * @param barreOutils la barre d'outils à modifier
678
	 * */
672
	 * */
679
	public static void ajouterBoutonAnnuler(ButtonBar barreOutils)	{
673
	public static void ajouterBoutonAnnuler(ButtonBar barreOutils)	{
680
		
674
		
681
		// Le bouton annuler ne sauvegarde pas les informations et renvoie vers la page précédente
675
		// Le bouton annuler ne sauvegarde pas les informations et renvoie vers la page précédente
682
		Button annuler = new Button("Revenir à la liste");
676
		Button annuler = new Button("Revenir à la liste");
683
		annuler.addSelectionListener(new SelectionListener<ButtonEvent>() {  
677
		annuler.addSelectionListener(new SelectionListener<ButtonEvent>() {  
684
			public void componentSelected(ButtonEvent ce) {  
678
			public void componentSelected(ButtonEvent ce) {  
685
				((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
679
				((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
686
			}  
680
			}  
687
		});
681
		});
688
		annuler.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
682
		annuler.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
689
		barreOutils.add(annuler);
683
		barreOutils.add(annuler);
690
	}
684
	}
691
	
685
	
692
	public void obtenirListeRegionParPays(String strPays)	{
686
	public void obtenirListeRegionParPays(String strPays)	{
693
		mediateur.obtenirListeRegionsEtRafraichir(this, "region", strPays);
687
		mediateur.obtenirListeRegionsEtRafraichir(this, "region", strPays);
694
	}
688
	}
695
	
689
	
696
	// RAFRAICHISSEMENT DU PANNEAU
690
	// RAFRAICHISSEMENT DU PANNEAU
697
 
691
 
698
	public void rafraichir(Object nouvellesDonnees) {
692
	public void rafraichir(Object nouvellesDonnees) {
699
		if (nouvellesDonnees instanceof ValeurListe) {
693
		if (nouvellesDonnees instanceof ValeurListe) {
700
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
694
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
701
			
695
			
702
			// Créer une liste de valeurs
696
			// Créer une liste de valeurs
703
			List<Valeur> liste = new ArrayList<Valeur>();
697
			List<Valeur> liste = new ArrayList<Valeur>();
704
			for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
698
			for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
705
				liste.add(listeValeurs.get(it.next()));
699
				liste.add(listeValeurs.get(it.next()));
706
			}
700
			}
707
			
701
			
708
	
702
	
709
			if (listeValeurs.getId().equals(config.getListeId("prefixe")))	{
703
			if (listeValeurs.getId().equals(config.getListeId("prefixe")))	{
710
				remplirCombobox("cbPrefixe", liste, "hmIdentite");
704
				remplirCombobox("cbPrefixe", liste, "hmIdentite");
711
			} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) {
705
			} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) {
712
				remplirCombobox("cbSuffixe", liste, "hmIdentite");
706
				remplirCombobox("cbSuffixe", liste, "hmIdentite");
713
			} else if (listeValeurs.getId().equals(config.getListeId("sexe"))) {
707
			} else if (listeValeurs.getId().equals(config.getListeId("sexe"))) {
714
				remplirCombobox("cbSexe", liste, "hmIdentite");
708
				remplirCombobox("cbSexe", liste, "hmIdentite");
715
			} else if (listeValeurs.getId().equals(config.getListeId("tel"))) {
709
			} else if (listeValeurs.getId().equals(config.getListeId("tel"))) {
716
				remplirCombobox("cbTelephone", liste, "hmIdentite");
710
				remplirCombobox("cbTelephone", liste, "hmIdentite");
717
 
711
 
718
				//Préselection du tél
712
				//Préselection du tél
719
				ComboBox<Valeur> cbTelephone = (ComboBox<Valeur>) hmIdentite.get("cbTelephone");
713
				ComboBox<Valeur> cbTelephone = hmIdentite.getComboBoxValeur("cbTelephone");
720
				cbTelephone.setValue(liste.get(1));
714
				cbTelephone.setValue(liste.get(1));
721
			} else if (listeValeurs.getId().equals(config.getListeId("pays")))	{
715
			} else if (listeValeurs.getId().equals(config.getListeId("pays")))	{
722
				remplirCombobox("cbPays", liste, "hmAdresse");
716
				remplirCombobox("cbPays", liste, "hmAdresse");
723
			} else if (listeValeurs.getId().equals(config.getListeId("region")))	{
717
			} else if (listeValeurs.getId().equals(config.getListeId("region")))	{
724
				remplirCombobox("cbRegion", liste, "hmAdresse");
718
				remplirCombobox("cbRegion", liste, "hmAdresse");
725
				((ComboBox) hmAdresse.get("cbRegion")).setVisible(true);
719
				((ComboBox) hmAdresse.get("cbRegion")).setVisible(true);
726
			}
720
			}
727
		} else if (nouvellesDonnees instanceof ProjetListe) {
721
		} else if (nouvellesDonnees instanceof ProjetListe) {
728
			ProjetListe projets = (ProjetListe) nouvellesDonnees;
722
			ProjetListe projets = (ProjetListe) nouvellesDonnees;
729
			List<Projet> liste = projets.toList();
723
			List<Projet> liste = projets.toList();
730
			
724
			
731
			ComboBox cbProjets = (ComboBox) hmIdentite.get("cbProjets");
725
			ComboBox cbProjets = hmIdentite.getComboBox("cbProjets");
732
			ListStore<Projet> storeProjets= cbProjets.getStore();
726
			ListStore<Projet> storeProjets= cbProjets.getStore();
733
			storeProjets.removeAll();
727
			storeProjets.removeAll();
734
			storeProjets.add(liste);
728
			storeProjets.add(liste);
735
			cbProjets.setStore(storeProjets);
729
			cbProjets.setStore(storeProjets);
736
		} else if (nouvellesDonnees instanceof Information)	{
730
		} else if (nouvellesDonnees instanceof Information)	{
737
			Information info = (Information) nouvellesDonnees;
731
			Information info = (Information) nouvellesDonnees;
738
			if (info.getType().equals("ajout_personne"))	{
732
			if (info.getType().equals("ajout_personne"))	{
739
				if (info.getDonnee(0) != null) {
733
				if (info.getDonnee(0) != null) {
740
					personneSelectionnee.setId(info.getDonnee(0).toString());
734
					personneSelectionnee.setId(info.getDonnee(0).toString());
741
					GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null);
735
					GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null);
742
					Info.display("Enregistrement", "La personne a été ajoutée (id: " + personneSelectionnee.getId() + ")");
736
					Info.display("Enregistrement", "La personne a été ajoutée (id: " + personneSelectionnee.getId() + ")");
743
					repandreRafraichissement();
737
					repandreRafraichissement();
744
					if (clicBoutonvalidation)	{
738
					if (clicBoutonvalidation)	{
745
						mediateur.clicMenu(menuIdCourant);
739
						mediateur.clicMenu(menuIdCourant);
746
					}
740
					}
747
				} else {
741
				} else {
748
					Info.display("Enregistrement", info.getMessages().toString());
742
					Info.display("Enregistrement", info.getMessages().toString());
749
				}
743
				}
750
			} else if (info.getType().equals("modification_personne"))	{
744
			} else if (info.getType().equals("modification_personne"))	{
751
				Info.display("Enregistrement", "Les modifications apportées à la personne " + personneSelectionnee.getId() + " ont été correctement enregistrées.");
745
				Info.display("Enregistrement", "Les modifications apportées à la personne " + personneSelectionnee.getId() + " ont été correctement enregistrées.");
752
				repandreRafraichissement();
746
				repandreRafraichissement();
753
				if (clicBoutonvalidation)	{
747
				if (clicBoutonvalidation)	{
754
					mediateur.clicMenu(menuIdCourant);
748
					mediateur.clicMenu(menuIdCourant);
755
				}
749
				}
756
			} else if (info.getType().equals("maj_utilisateur"))	{
750
			} else if (info.getType().equals("maj_utilisateur"))	{
757
				gererEtatActivationBouton();
751
				gererEtatActivationBouton();
758
			} else if (info.getDonnee(0) instanceof PersonneListe)	{
752
			} else if (info.getDonnee(0) instanceof PersonneListe)	{
759
				
753
				
760
				Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values();
754
				Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values();
761
				Iterator itPersonneListe = colPersonneListe.iterator();
755
				Iterator itPersonneListe = colPersonneListe.iterator();
762
				Personne personne = (Personne) itPersonneListe.next();
756
				Personne personne = (Personne) itPersonneListe.next();
763
				
757
				
764
				personneSauvegarde = new Personne();
758
				personneSauvegarde = new Personne();
765
				personneSauvegarde = (Personne) personne.cloner(personneSauvegarde);
759
				personneSauvegarde = (Personne) personne.cloner(personneSauvegarde);
766
				
760
				
767
				binderPersonne(personne);
761
				binderPersonne(personne);
768
				
762
				
769
				mettreAJourPersonne(personne);
763
				mettreAJourPersonne(personne);
770
				
764
				
771
				nouvellesDonnees = null;
765
				nouvellesDonnees = null;
772
			} else {
766
			} else {
773
				Info.display("messages", info.getMessages().toString());
767
				Info.display("messages", info.getMessages().toString());
774
			}
768
			}
775
		}
769
		}
776
		
770
		
777
		if (nouvellesDonnees == null) {
771
		if (nouvellesDonnees == null) {
778
			ComboBox cb= (ComboBox) hmIdentite.get("cbPrefixe");
772
			ComboBox<Valeur> cb= hmIdentite.getComboBoxValeur("cbPrefixe");
779
			
773
			
780
			//Met à jour le nom Complet du formulaire
774
			//Met à jour le nom Complet du formulaire
781
			String valeurRetour = "";
775
			String valeurRetour = "";
782
			
776
			
783
			// Prefixe
777
			// Prefixe
784
			String prefixe = "";
778
			String prefixe = "";
785
			Valeur valPrefixe = (Valeur) ((ComboBox) hmIdentite.get("cbPrefixe")).getValue();
779
			Valeur valPrefixe = cb.getValue();
786
			
780
			
787
			if (valPrefixe != null)	{
781
			if (valPrefixe != null)	{
788
				prefixe = valPrefixe.getNom();
782
				prefixe = valPrefixe.getNom();
789
			} else 	{
783
			} else 	{
790
				prefixe =  (String) ((ComboBox) hmIdentite.get("cbPrefixe")).getRawValue();
784
				prefixe =  (String) cb.getRawValue();
791
			}		
785
			}		
792
			
786
			
793
			// Prénom
787
			// Prénom
794
			String prenom = (String) ((TextField) hmIdentite.get("tfPrenom")).getValue();
788
			String prenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
795
			
789
			
796
			// Nom
790
			// Nom
797
			String nom = (String) ((TextField) hmIdentite.get("tfNom")).getValue();
791
			String nom = (String) hmIdentite.getTextField("tfNom").getValue();
-
 
792
			
-
 
793
			// Suffixe
798
			
794
			ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe");
799
			// Suffixe
795
			
800
			String suffixe = "";
796
			String suffixe = "";
801
			Valeur valSuffixe = (Valeur) ((ComboBox) hmIdentite.get("cbSuffixe")).getValue();
797
			Valeur valSuffixe = cbSuffixe.getValue();
802
			
798
			
803
			if (valSuffixe != null)	{
799
			if (valSuffixe != null)	{
804
				suffixe = valSuffixe.getNom();
800
				suffixe = valSuffixe.getNom();
805
			} else 	{
801
			} else 	{
806
				suffixe =  (String) ((ComboBox) hmIdentite.get("cbSuffixe")).getRawValue();
802
				suffixe =  (String) cbSuffixe.getRawValue();
807
			}
803
			}
808
			
804
			
809
			// Mettre à jour la valeur
805
			// Mettre à jour la valeur
810
			valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
806
			valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
811
			valeurRetour = valeurRetour.replaceAll("null", "");
807
			valeurRetour = valeurRetour.replaceAll("null", "");
812
			
808
			
813
			((LabelField) hmIdentite.get("nomComplet")).setValue(valeurRetour);
809
			hmIdentite.getLabelField("nomComplet").setValue(valeurRetour);
814
			
810
			
815
			if (!valeurRetour.trim().equals(""))	{
811
			if (!valeurRetour.trim().equals(""))	{
816
				((LabelField) hmIdentite.get("nomComplet")).show();
812
				hmIdentite.getLabelField("nomComplet").show();
817
			} else {
813
			} else {
818
				((LabelField) hmIdentite.get("nomComplet")).hide();
814
				hmIdentite.getLabelField("nomComplet").hide();
819
			}
815
			}
820
		}
816
		}
821
		
817
		
822
		mediateur.masquerPopinChargement();
818
		mediateur.masquerPopinChargement();
823
		
819
		
824
		if (this.mode.equals(MODE_AJOUTER))	{
820
		if (this.mode.equals(MODE_AJOUTER))	{
825
			gererEtatActivationBouton();
821
			gererEtatActivationBouton();
826
		}
822
		}
827
	}
823
	}
828
 
824
 
829
	private void repandreRafraichissement() {
825
	private void repandreRafraichissement() {
830
		if (vueExterneARafraichirApresValidation != null) {
826
		if (vueExterneARafraichirApresValidation != null) {
831
			String type = "personne_modifiee";
827
			String type = "personne_modifiee";
832
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
828
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
833
				type = "personne_ajoutee";
829
				type = "personne_ajoutee";
834
			}
830
			}
835
			Information info = new Information(type);
831
			Information info = new Information(type);
836
			info.setDonnee(0, personneSelectionnee);
832
			info.setDonnee(0, personneSelectionnee);
837
			vueExterneARafraichirApresValidation.rafraichir(info);
833
			vueExterneARafraichirApresValidation.rafraichir(info);
838
		}
834
		}
839
	}
835
	}
840
	
836
	
841
	private void mettreAJourPersonne(Personne personne)	{
837
	private void mettreAJourPersonne(Personne personne)	{
842
		//Mise à jour de la personne		
838
		//Mise à jour de la personne		
843
		//Personne personne = (Personne) nouvellesDonnees;
839
		//Personne personne = (Personne) nouvellesDonnees;
844
		
840
		
845
		ComboBox cbProjets = (ComboBox) hmIdentite.get("cbProjets");
841
		ComboBox cbProjets = hmIdentite.getComboBox("cbProjets");
846
		cbProjets.setValue(cbProjets.getStore().findModel("id_projet", personne.get("ce_projet")));
842
		cbProjets.setValue(cbProjets.getStore().findModel("id_projet", personne.get("ce_projet")));
847
		
843
		
848
		//Prefixe
844
		//Prefixe
849
		String prefixe = personne.get("ce_truk_prefix");
845
		String prefixe = personne.get("ce_truk_prefix");
850
		ComboBox<Valeur> cbPrefixe = (ComboBox<Valeur>) hmIdentite.get("cbPrefixe");
846
		ComboBox<Valeur> cbPrefixe = hmIdentite.getComboBoxValeur("cbPrefixe");
851
		
847
		
852
		
848
		
853
		String prefixeCourant = personne.get("ce_truk_prefix");
849
		String prefixeCourant = personne.get("ce_truk_prefix");
854
		if (cbPrefixe.getStore().findModel("id_valeur", prefixeCourant) != null)	{
850
		if (cbPrefixe.getStore().findModel("id_valeur", prefixeCourant) != null)	{
855
			cbPrefixe.setValue(cbPrefixe.getStore().findModel("id_valeur", prefixeCourant));
851
			cbPrefixe.setValue(cbPrefixe.getStore().findModel("id_valeur", prefixeCourant));
856
		}	else	{
852
		}	else	{
857
			cbPrefixe.setRawValue(prefixeCourant);
853
			cbPrefixe.setRawValue(prefixeCourant);
858
		}
854
		}
859
		
-
 
860
		
855
		
861
		((TextField) hmIdentite.get("tfPrenom")).setValue(personne.get("prenom"));
856
		hmIdentite.getTextField("tfPrenom").setValue(personne.get("prenom"));
862
		((TextField) hmIdentite.get("tfNom")).setValue(personne.get("nom"));
857
		hmIdentite.getTextField("tfNom").setValue(personne.get("nom"));
863
		
858
		
864
		//Suffixe
859
		//Suffixe
865
		String suffixe = personne.get("ce_truk_suffixe");
860
		String suffixe = personne.get("ce_truk_suffixe");
866
		ComboBox<Valeur> cbSuffixe = (ComboBox<Valeur>) hmIdentite.get("cbSuffixe");
861
		ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe");
867
		
862
		
868
		String suffixeCourant = personne.get("ce_truk_suffix");
863
		String suffixeCourant = personne.get("ce_truk_suffix");
869
		if (cbSuffixe.getStore().findModel("id_valeur", suffixeCourant) != null)	{
864
		if (cbSuffixe.getStore().findModel("id_valeur", suffixeCourant) != null)	{
870
			cbSuffixe.setValue(cbSuffixe.getStore().findModel("id_valeur", suffixeCourant));
865
			cbSuffixe.setValue(cbSuffixe.getStore().findModel("id_valeur", suffixeCourant));
871
		}	else	{
866
		}	else	{
872
			cbSuffixe.setRawValue(suffixeCourant);
867
			cbSuffixe.setRawValue(suffixeCourant);
873
		}
868
		}
874
		
869
		
875
		((ChampMultiValeurs) hmIdentite.get("nomAutre")).peupler(personne.getString("truk_nom_autre"));
870
		hmIdentite.getChampMultiValeurs("nomAutre").peupler(personne.getString("truk_nom_autre"));
876
		((TextField) hmIdentite.get("tfAbreviation")).setValue(personne.get("abreviation"));
871
		hmIdentite.getTextField("tfAbreviation").setValue(personne.get("abreviation"));
877
		((ChampMultiValeurs) hmIdentite.get("abreviationAutre")).peupler(personne.getString("truk_abreviation_autre"));
-
 
878
		
872
		hmIdentite.getChampMultiValeurs("abreviationAutre").peupler(personne.getString("truk_abreviation_autre"));
879
		
873
		
880
		(((DateField) hmIdentite.get("dfDateNaissance"))).setValue(personne.getDate("naissance_date"));
874
		hmIdentite.getDateField("dfDateNaissance").setValue(personne.getDate("naissance_date"));
881
		((TextField) hmIdentite.get("tfLieuNaissance")).setValue(personne.get("naissance_lieu"));
875
		hmIdentite.getTextField("tfLieuNaissance").setValue(personne.get("naissance_lieu"));
882
		
876
		
883
		if (personne.estDecedee())	{
877
		if (personne.estDecedee())	{
884
			(((DateField) hmIdentite.get("dfDateDeces"))).setValue(personne.getDate("deces_date"));
878
			hmIdentite.getDateField("dfDateDeces").setValue(personne.getDate("deces_date"));
885
			((TextField) hmIdentite.get("tfLieuDeces")).setValue(personne.get("deces_lieu"));
-
 
886
			Radio rbEstDecede = (Radio) hmIdentite.get("rbEstDecedee");
879
			hmIdentite.getTextField("tfLieuDeces").setValue(personne.get("deces_lieu"));
887
			rbEstDecede.setValue(true);
880
			Radio rbEstDecede = hmIdentite.getRadio("rbEstDecedee");
888
			
881
			rbEstDecede.setValue(true);
889
		}
882
		}
890
		
883
		
891
		((ChampMultiValeurs) hmIdentite.get("telephones")).peupler(personne.getString("truk_telephone"));
884
		hmIdentite.getChampMultiValeurs("telephones").peupler(personne.getString("truk_telephone"));
892
		
-
 
893
		//Courriel
885
		
894
		((ChampMultiValeurs) hmIdentite.get("courriels")).peupler(personne.getCourriel());
886
		//Courriel
895
		
887
		hmIdentite.getChampMultiValeurs("courriels").peupler(personne.getCourriel());
896
		//Sites web
888
		
897
		((ChampMultiValeurs) hmIdentite.get("sites")).peupler(personne.getString("truk_url"));
889
		//Sites web
898
		
890
		hmIdentite.getChampMultiValeurs("sites").peupler(personne.getString("truk_url"));
899
		
891
		
900
		// Sexe
892
		// Sexe
901
		String strSexe = personne.get("ce_sexe");
893
		String strSexe = personne.get("ce_sexe");
902
		ComboBox<Valeur> cbSexe = (ComboBox<Valeur>) hmIdentite.get("cbSexe");
894
		ComboBox<Valeur> cbSexe = hmIdentite.getComboBoxValeur("cbSexe");
903
 
895
 
904
		if (cbSexe.getStore().findModel("id_valeur", strSexe) != null)	{
896
		if (cbSexe.getStore().findModel("id_valeur", strSexe) != null)	{
905
			cbSexe.setValue(cbSexe.getStore().findModel("id_valeur", strSexe));
897
			cbSexe.setValue(cbSexe.getStore().findModel("id_valeur", strSexe));
906
		}	else	{
898
		}	else	{
907
			cbSexe.setRawValue(strSexe);
899
			cbSexe.setRawValue(strSexe);
908
		}
900
		}
909
		
901
		
910
		((TextArea) hmIdentite.get("taDescription")).setRawValue((String) personne.get("description"));
902
		hmIdentite.getTextArea("taDescription").setRawValue((String) personne.get("description"));
911
		
903
		
912
		//Logo
904
		//Logo
913
		((ChampMultiValeurs) hmIdentite.get("logos")).peupler(personne.getString("truk_logo"));
905
		hmIdentite.getChampMultiValeurs("logos").peupler(personne.getString("truk_logo"));
914
		
906
		
915
		/*--------------------------------------------------
907
		/*--------------------------------------------------
916
		                      Adresse
908
		                      Adresse
917
		 ---------------------------------------------------*/
909
		 ---------------------------------------------------*/
918
		
910
		
919
		// Adresse
911
		// Adresse
920
		((TextField<String>) hmAdresse.get("tfAdresse1")).setValue((String) personne.get("adresse_01"));
912
		((TextField<String>) hmAdresse.get("tfAdresse1")).setValue((String) personne.get("adresse_01"));
921
 
913
 
922
		// Complément
914
		// Complément
923
		((TextField<String>) hmAdresse.get("tfAdresse2")).setValue((String) personne.get("adresse_02"));
915
		((TextField<String>) hmAdresse.get("tfAdresse2")).setValue((String) personne.get("adresse_02"));
924
		
916
		
925
		//Boite postale
917
		//Boite postale
926
		((TextField<String>) hmAdresse.get("tfBoitePostale")).setValue((String) personne.get("bp"));
918
		((TextField<String>) hmAdresse.get("tfBoitePostale")).setValue((String) personne.get("bp"));
927
		
919
		
928
		//Pays
920
		//Pays
929
		String strPays = personne.get("pays");
921
		String strPays = personne.get("pays");
930
		ComboBox<Valeur> cbPays = (ComboBox<Valeur>) hmAdresse.get("cbPays");
922
		ComboBox<Valeur> cbPays = (ComboBox<Valeur>) hmAdresse.get("cbPays");
931
		
923
		
932
		
924
		
933
		if (cbPays.getStore().findModel("nom", strPays) != null)	{
925
		if (cbPays.getStore().findModel("nom", strPays) != null)	{
934
			cbPays.setValue(cbPays.getStore().findModel("nom", strPays));
926
			cbPays.setValue(cbPays.getStore().findModel("nom", strPays));
935
		}	else	{
927
		}	else	{
936
			cbPays.setRawValue(strPays);
928
			cbPays.setRawValue(strPays);
937
		}
929
		}
938
		
930
		
939
		//Région
931
		//Région
940
		String strRegion = personne.get("region");
932
		String strRegion = personne.get("region");
941
		if ((strRegion!=null)&&(!strRegion.equals("")))	{
933
		if ((strRegion!=null)&&(!strRegion.equals("")))	{
942
			ComboBox<Valeur> cbRegion = (ComboBox<Valeur>) hmAdresse.get("cbRegion");
934
			ComboBox<Valeur> cbRegion = (ComboBox<Valeur>) hmAdresse.get("cbRegion");
943
			cbRegion.setVisible(true);
935
			cbRegion.setVisible(true);
944
			
936
			
945
			if (cbRegion.getStore().findModel("nom", strRegion) != null)	{
937
			if (cbRegion.getStore().findModel("nom", strRegion) != null)	{
946
				cbRegion.setValue(cbRegion.getStore().findModel("nom", strRegion));
938
				cbRegion.setValue(cbRegion.getStore().findModel("nom", strRegion));
947
			}	else	{
939
			}	else	{
948
				cbRegion.setRawValue(strRegion);
940
				cbRegion.setRawValue(strRegion);
949
			}
941
			}
950
		}
942
		}
951
		
943
		
952
		//Cp
944
		//Cp
953
		((TextField) hmAdresse.get("tfCodePostal")).setValue(personne.get("code_postal"));
945
		((TextField) hmAdresse.get("tfCodePostal")).setValue(personne.get("code_postal"));
954
		
946
		
955
		//Ville
947
		//Ville
956
		((TextField) hmAdresse.get("tfVille")).setValue(personne.get("ville"));
948
		((TextField) hmAdresse.get("tfVille")).setValue(personne.get("ville"));
957
		
949
		
958
		/*--------------------------------------------------------
950
		/*--------------------------------------------------------
959
		 * 					Infos naturalistes
951
		 * 					Infos naturalistes
960
		 * -----------------------------------------------------*/
952
		 * -----------------------------------------------------*/
961
		
953
		
962
		((ChampMultiValeurs) hmInfosNat.get("specialite")).peupler(personne.getString("ce_truk_specialite"));
954
		((ChampMultiValeurs) hmInfosNat.get("specialite")).peupler(personne.getString("ce_truk_specialite"));
963
		((ChampMultiValeursMultiTypes) hmInfosNat.get("recolte")).peupler(personne.getString("truk_recolte"));
955
		((ChampMultiValeursMultiTypes) hmInfosNat.get("recolte")).peupler(personne.getString("truk_recolte"));
964
		 
956
		 
965
		gererEtatActivationBouton();
957
		gererEtatActivationBouton();
966
	}
958
	}
967
 
959
 
968
	public void remplirCombobox(String idComboBox, List liste, String hashMapId)	{
960
	public void remplirCombobox(String idComboBox, List liste, String hashMapId)	{
969
		HashMap hm = null;
961
		HashMap hm = null;
970
		if (hashMapId.equals("hmIdentite"))	{
962
		if (hashMapId.equals("hmIdentite"))	{
971
			hm = hmIdentite;
963
			hm = hmIdentite;
972
		} else if (hashMapId.equals("hmAdresse")){
964
		} else if (hashMapId.equals("hmAdresse")){
973
			hm = hmAdresse;
965
			hm = hmAdresse;
974
		} else {
966
		} else {
975
			hm = hmInfosNat;
967
			hm = hmInfosNat;
976
		}
968
		}
977
		
969
		
978
		ListStore<Valeur> store = ((ComboBox) hm.get(idComboBox)).getStore();
970
		ListStore<Valeur> store = ((ComboBox) hm.get(idComboBox)).getStore();
979
		
971
		
980
		store.removeAll();
972
		store.removeAll();
981
		store.add(liste);
973
		store.add(liste);
982
		((ComboBox) hm.get(idComboBox)).setStore(store);
974
		((ComboBox) hm.get(idComboBox)).setStore(store);
983
	}
975
	}
984
	
976
	
985
	private void gererEtatActivationBouton()	{
977
	private void gererEtatActivationBouton()	{
986
	/*	if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie() == false)	{			
978
	/*	if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie() == false)	{			
987
			enregistrer.setEnabled(false);
979
			enregistrer.setEnabled(false);
988
			enregistrerEtRevenir.setEnabled(false);
980
			enregistrerEtRevenir.setEnabled(false);
989
		} else	{
981
		} else	{
990
			enregistrer.setEnabled(true);
982
			enregistrer.setEnabled(true);
991
			enregistrerEtRevenir.setEnabled(true);
983
			enregistrerEtRevenir.setEnabled(true);
992
		}*/
984
		}*/
993
	}
985
	}
994
	
986
	
995
	public void reinitialiserFormulaire()	{
987
	public void reinitialiserFormulaire()	{
996
		mediateur.afficherPopinChargement();
988
		mediateur.afficherPopinChargement();
997
		mettreAJourPersonne(personneSauvegarde);
989
		mettreAJourPersonne(personneSauvegarde);
998
		mediateur.masquerPopinChargement();
990
		mediateur.masquerPopinChargement();
999
	}
991
	}
1000
	
992
	
1001
	public void binderPersonne(Personne personne)	{
993
	public void binderPersonne(Personne personne)	{
1002
		binding = new FormBinding(getFormulaire());
994
		binding = new FormBinding(getFormulaire());
1003
		
995
		
1004
		personneSelectionnee = personne;
996
		personneSelectionnee = personne;
1005
		binding.autoBind();
997
		binding.autoBind();
1006
		binding.bind(personneSelectionnee);
998
		binding.bind(personneSelectionnee);
1007
		layout();
999
		layout();
1008
	}
1000
	}
1009
 
1001
 
1010
	/**
1002
	/**
1011
	 * Enregistre les information de la personne en cours 
1003
	 * Enregistre les information de la personne en cours 
1012
	 * 
1004
	 * 
1013
	 */
1005
	 */
1014
	public boolean enregistrer()	{
1006
	public boolean enregistrer()	{
1015
		boolean success = false;
1007
		boolean success = false;
1016
		LinkedList lstMessageErreur = new LinkedList<String>();
1008
		LinkedList lstMessageErreur = new LinkedList<String>();
1017
		
1009
	
1018
		ComboBox<Projet> cbProjets = (ComboBox<Projet>) hmIdentite.get("cbProjets");
1010
		ComboBox<Projet> cbProjets = hmIdentite.getComboBox("cbProjets");
1019
		Projet projet = cbProjets.getValue();
1011
		Projet projet = cbProjets.getValue();
1020
		if (projet == null)	{
1012
		if (projet == null)	{
1021
			lstMessageErreur.add("Le projet n'a pas été renseigné");
1013
			lstMessageErreur.add("Le projet n'a pas été renseigné");
1022
		} else {
1014
		} else {
1023
			personneSelectionnee.set("ce_projet", projet.getId());
1015
			personneSelectionnee.set("ce_projet", projet.getId());
1024
		}
1016
		}
1025
		
1017
		
1026
		String strTfNom = ((TextField<String>) hmIdentite.get("tfNom")).getValue();
1018
		String strTfNom = (String) hmIdentite.getTextField("tfNom").getValue();
1027
		if ((strTfNom == null)||(strTfNom.trim().equals("")))	{
1019
		if ((strTfNom == null)||(strTfNom.trim().equals("")))	{
1028
			lstMessageErreur.add("Le nom n'a pas été saisi");
1020
			lstMessageErreur.add("Le nom n'a pas été saisi");
1029
		} else {
1021
		} else {
1030
			strTfNom = UtilString.ucFirst(strTfNom);
1022
			strTfNom = UtilString.ucFirst(strTfNom);
1031
			personneSelectionnee.set("nom", strTfNom);
1023
			personneSelectionnee.set("nom", strTfNom);
1032
		}
1024
		}
1033
		
1025
		
1034
		String strTfPrenom = ((TextField<String>) hmIdentite.get("tfPrenom")).getValue();
1026
		String strTfPrenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
1035
		personneSelectionnee.set("prenom", UtilString.ucFirst(strTfPrenom));
1027
		personneSelectionnee.set("prenom", UtilString.ucFirst(strTfPrenom));
1036
		
1028
		
1037
		//Préparer les données
1029
		//Préparer les données
1038
		ComboBox combo = (ComboBox) hmIdentite.get("cbSexe");
1030
		ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur("cbSexe");
1039
		Valeur valeur;
1031
		Valeur valeur;
1040
		String strValeur = "";
1032
		String strValeur = "";
1041
		
1033
		
1042
		valeur = (Valeur) combo.getValue();
1034
		valeur = combo.getValue();
1043
		if (valeur!=null)	{
1035
		if (valeur!=null)	{
1044
			personneSelectionnee.set("ce_sexe", valeur.getId());
1036
			personneSelectionnee.set("ce_sexe", valeur.getId());
1045
		}
1037
		}
1046
		
1038
		
1047
		strValeur = obtenirValeurCombo("cbPrefixe");
1039
		strValeur = obtenirValeurCombo("cbPrefixe");
1048
		personneSelectionnee.set("ce_truk_prefix", strValeur);
1040
		personneSelectionnee.set("ce_truk_prefix", strValeur);
1049
		
1041
		
1050
		strValeur = obtenirValeurCombo("cbSuffixe"); 
1042
		strValeur = obtenirValeurCombo("cbSuffixe"); 
1051
		personneSelectionnee.set("ce_truk_suffix", strValeur);
1043
		personneSelectionnee.set("ce_truk_suffix", strValeur);
1052
		
1044
		
1053
		String nomAutre = ((ChampMultiValeurs) hmIdentite.get("nomAutre")).getValeurs();
1045
		String nomAutre = hmIdentite.getChampMultiValeurs("nomAutre").getValeurs();
1054
		personneSelectionnee.set("truk_nom_autre", nomAutre);
1046
		personneSelectionnee.set("truk_nom_autre", nomAutre);
1055
		
1047
		
1056
		String abreviationAutre = ((ChampMultiValeurs) hmIdentite.get("abreviationAutre")).getValeurs();
1048
		String abreviationAutre = hmIdentite.getChampMultiValeurs("abreviationAutre").getValeurs();
1057
		personneSelectionnee.set("truk_abreviation_autre", abreviationAutre);
1049
		personneSelectionnee.set("truk_abreviation_autre", abreviationAutre);
1058
		
1050
		
1059
		personneSelectionnee.set("truk_courriel", ((ChampMultiValeurs) hmIdentite.get("courriels")).getValeurs());
1051
		personneSelectionnee.set("truk_courriel", hmIdentite.getChampMultiValeurs("courriels").getValeurs());
1060
		
1052
		
1061
		
1053
		
1062
		//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
1054
		//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
1063
		String strPrefixe = "";
1055
		String strPrefixe = "";
1064
		combo = (ComboBox) hmIdentite.get("cbPrefixe");
1056
		combo = hmIdentite.getComboBoxValeur("cbPrefixe");
1065
		valeur = (Valeur) combo.getValue();
1057
		valeur = combo.getValue();
1066
		if (valeur != null)	{
1058
		if (valeur != null)	{
1067
			strPrefixe = valeur.getNom();
1059
			strPrefixe = valeur.getNom();
1068
		} else {
1060
		} else {
1069
			strPrefixe = combo.getRawValue();
1061
			strPrefixe = combo.getRawValue();
1070
		}
1062
		}
1071
		
1063
		
1072
		String strSuffixe = "";
1064
		String strSuffixe = "";
1073
		combo = (ComboBox) hmIdentite.get("cbSuffixe");
1065
		combo = hmIdentite.getComboBoxValeur("cbSuffixe");
1074
		valeur = (Valeur) combo.getValue();
1066
		valeur = combo.getValue();
1075
		if (valeur != null)	{
1067
		if (valeur != null)	{
1076
			strSuffixe = valeur.getNom() + " ";
1068
			strSuffixe = valeur.getNom() + " ";
1077
		} else {
1069
		} else {
1078
			strSuffixe = combo.getRawValue() +" ";
1070
			strSuffixe = combo.getRawValue() +" ";
1079
		}
1071
		}
1080
		
1072
		
1081
		personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe);
1073
		personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe);
1082
		
1074
		
1083
		DateField dfDateNaissance = (DateField) hmIdentite.get("dfDateNaissance");
1075
		DateField dfDateNaissance = hmIdentite.getDateField("dfDateNaissance");
1084
		Date naissanceDate = dfDateNaissance.getValue();
1076
		Date naissanceDate = dfDateNaissance.getValue();
1085
		personneSelectionnee.setNaissanceDate(naissanceDate);
1077
		personneSelectionnee.setNaissanceDate(naissanceDate);
1086
		
1078
		
1087
		Radio rbEstDecedee = (Radio) hmIdentite.get("rbEstDecedee");
1079
		Radio rbEstDecedee = hmIdentite.getRadio("rbEstDecedee");
1088
		if (rbEstDecedee.getValue() == true)	{
1080
		if (rbEstDecedee.getValue() == true)	{
1089
			DateField dfDecesDate = (DateField) hmIdentite.get("dfDateDeces");
1081
			DateField dfDecesDate = hmIdentite.getDateField("dfDateDeces");
1090
			String decesLieu = ((TextField<String>) hmIdentite.get("tfLieuDeces")).getValue();
1082
			String decesLieu = (String) hmIdentite.getTextField("tfLieuDeces").getValue();
1091
			personneSelectionnee.setDeces(dfDecesDate.getValue(), decesLieu);
1083
			personneSelectionnee.setDeces(dfDecesDate.getValue(), decesLieu);
1092
		}	else	{
1084
		}	else	{
1093
			personneSelectionnee.setNonDecedee();			
1085
			personneSelectionnee.setNonDecedee();			
1094
		}
1086
		}
1095
		
1087
		
1096
		strValeur = obtenirValeurCombo("cbPays");
1088
		strValeur = obtenirValeurCombo("cbPays");
1097
		personneSelectionnee.set("ce_truk_pays", strValeur);
1089
		personneSelectionnee.set("ce_truk_pays", strValeur);
1098
		
1090
		
1099
		strValeur = obtenirValeurCombo("cbRegion");
1091
		strValeur = obtenirValeurCombo("cbRegion");
1100
		personneSelectionnee.set("ce_truk_region", strValeur);
1092
		personneSelectionnee.set("ce_truk_region", strValeur);
1101
		
1093
		
1102
		personneSelectionnee.set("truk_telephone", ((ChampMultiValeursMultiTypes) hmIdentite.get("telephones")).getValeurs());
1094
		personneSelectionnee.set("truk_telephone", hmIdentite.getChampMultiValeursMultiTypes("telephones").getValeurs());
1103
		
1095
		
1104
		String logoUrls = ((ChampMultiValeursImage) hmIdentite.get("logos")).getValeurs();
1096
		String logoUrls = hmIdentite.getChampMultiValeursImage("logos").getValeurs();
1105
		personneSelectionnee.set("truk_logo", logoUrls);
1097
		personneSelectionnee.set("truk_logo", logoUrls);
1106
		
1098
		
1107
		personneSelectionnee.set("truk_url", ((ChampMultiValeurs) hmIdentite.get("sites")).getValeurs());
1099
		personneSelectionnee.set("truk_url", hmIdentite.getChampMultiValeurs("sites").getValeurs());
1108
		
1100
		
1109
		//Infos Naturalistes
1101
		//Infos Naturalistes
1110
		String recolte = ((ChampMultiValeursMultiTypes) hmInfosNat.get("recolte")).getValeurs();
1102
		String recolte = ((ChampMultiValeursMultiTypes) hmInfosNat.get("recolte")).getValeurs();
1111
		personneSelectionnee.set("truk_recolte", recolte);
1103
		personneSelectionnee.set("truk_recolte", recolte);
1112
		
1104
		
1113
		String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs();
1105
		String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs();
1114
		personneSelectionnee.set("ce_truk_specialite", specialite);
1106
		personneSelectionnee.set("ce_truk_specialite", specialite);
1115
		
1107
		
1116
		
1108
		
1117
		if (lstMessageErreur.size() == 0)	{
1109
		if (lstMessageErreur.size() == 0)	{
-
 
1110
			
-
 
1111
			System.out.println("2." + personne);
1118
			mediateur.enregistrerPersonne(this, personneSelectionnee);
1112
			mediateur.enregistrerPersonne(this, personneSelectionnee);
1119
			success = true;
1113
			success = true;
1120
		} else {
1114
		} else {
1121
			String strMessagesErreur = "<span><br />";
1115
			String strMessagesErreur = "<span><br />";
1122
			Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
1116
			Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
1123
			while (itMessagesErreur.hasNext())	{
1117
			while (itMessagesErreur.hasNext())	{
1124
				strMessagesErreur += "<br /> - " + itMessagesErreur.next();
1118
				strMessagesErreur += "<br /> - " + itMessagesErreur.next();
1125
			}
1119
			}
1126
			strMessagesErreur += "</span>";
1120
			strMessagesErreur += "</span>";
1127
			
1121
			
1128
 			MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
1122
 			MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
1129
 			success = false;
1123
 			success = false;
1130
		}
1124
		}
1131
		
1125
		
1132
		return success;
1126
		return success;
1133
	}
1127
	}
1134
	
1128
	
1135
	private String obtenirValeurCombo(String strComboName)	{
1129
	private String obtenirValeurCombo(String strComboName)	{
1136
		String strValeur = "";
1130
		String strValeur = "";
1137
		Valeur valeur;
1131
		Valeur valeur;
1138
		
1132
		
1139
		ComboBox combo = (ComboBox) hmIdentite.get(strComboName);
1133
		ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur(strComboName);
1140
		if (combo == null)	{
1134
		if (combo == null)	{
1141
			combo = (ComboBox) hmAdresse.get(strComboName);
1135
			combo = (ComboBox) hmAdresse.get(strComboName);
1142
		}
1136
		}
1143
		strValeur = combo.getRawValue();
1137
		strValeur = combo.getRawValue();
1144
		valeur = (Valeur) combo.getStore().findModel(strValeur);
1138
		valeur = combo.getStore().findModel(strValeur);
1145
		if (valeur != null)	{
1139
		if (valeur != null)	{
1146
			strValeur = valeur.getId();
1140
			strValeur = valeur.getId();
1147
		}
1141
		}
1148
		
1142
		
1149
		/*if (combo.getValue()!=null)	{
1143
		/*if (combo.getValue()!=null)	{
1150
			valeur = (Valeur) combo.getValue();
1144
			valeur = (Valeur) combo.getValue();
1151
			strValeur = valeur.getId();
1145
			strValeur = valeur.getId();
1152
		} else {
1146
		} else {
1153
			strValeur = combo.getRawValue();
1147
			strValeur = combo.getRawValue();
1154
		}*/
1148
		}*/
1155
		
1149
		
1156
		return strValeur;
1150
		return strValeur;
1157
	}
1151
	}
1158
 
1152
 
1159
	public boolean soumettreFormulaire() {
1153
	public boolean soumettreFormulaire() {
1160
		if (verifierFormulaire())	{
1154
		if (verifierFormulaire())	{
1161
			mediateur.enregistrerPersonne(this, personneSelectionnee);
1155
			mediateur.enregistrerPersonne(this, personneSelectionnee);
1162
		}
1156
		}
1163
		return true;
1157
		return true;
1164
	}
1158
	}
1165
 
1159
 
1166
	public boolean verifierFormulaire() {
1160
	public boolean verifierFormulaire() {
1167
		boolean success = true;
1161
		boolean success = true;
1168
		LinkedList<String> lstMessageErreur = new LinkedList<String>();
1162
		LinkedList<String> lstMessageErreur = new LinkedList<String>();
1169
		
1163
		
1170
		ComboBox<Projet> cbProjets = (ComboBox<Projet>) hmIdentite.get("cbProjets");
1164
		ComboBox<Projet> cbProjets = hmIdentite.getComboBox("cbProjets");
1171
		Projet projet = cbProjets.getValue();
1165
		Projet projet = cbProjets.getValue();
1172
		if (projet == null)	{
1166
		if (projet == null)	{
1173
			lstMessageErreur.add("Le projet n'a pas été renseigné");
1167
			lstMessageErreur.add("Le projet n'a pas été renseigné");
1174
		} else {
1168
		} else {
1175
			personneSelectionnee.set("ce_projet", projet.getId());
1169
			personneSelectionnee.set("ce_projet", projet.getId());
1176
		}
1170
		}
1177
		
1171
		
1178
		String strTfNom = ((TextField<String>) hmIdentite.get("tfNom")).getValue();
1172
		String strTfNom = (String) hmIdentite.getTextField("tfNom").getValue();
1179
		if ((strTfNom == null)||(strTfNom.trim().equals("")))	{
1173
		if ((strTfNom == null)||(strTfNom.trim().equals("")))	{
1180
			lstMessageErreur.add("Le nom n'a pas été saisi");
1174
			lstMessageErreur.add("Le nom n'a pas été saisi");
1181
		} else {
1175
		} else {
1182
			strTfNom = UtilString.ucFirst(strTfNom);
1176
			strTfNom = UtilString.ucFirst(strTfNom);
1183
			personneSelectionnee.set("nom", strTfNom);
1177
			personneSelectionnee.set("nom", strTfNom);
1184
		}
1178
		}
1185
		
1179
		
1186
		String strTfPrenom = ((TextField<String>) hmIdentite.get("tfPrenom")).getValue();
1180
		String strTfPrenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
1187
		personneSelectionnee.set("prenom", UtilString.ucFirst(strTfPrenom));
1181
		personneSelectionnee.set("prenom", UtilString.ucFirst(strTfPrenom));
1188
		
1182
		
1189
		//Préparer les données
1183
		//Préparer les données
1190
		ComboBox combo = (ComboBox) hmIdentite.get("cbSexe");
1184
		ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur("cbSexe");
1191
		Valeur valeur;
1185
		Valeur valeur;
1192
		String strValeur = "";
1186
		String strValeur = "";
1193
		
1187
		
1194
		valeur = (Valeur) combo.getValue();
1188
		valeur = combo.getValue();
1195
		if (valeur!=null)	{
1189
		if (valeur!=null)	{
1196
			personneSelectionnee.set("ce_sexe", valeur.getId());
1190
			personneSelectionnee.set("ce_sexe", valeur.getId());
1197
		}
1191
		}
1198
		
1192
		
1199
		strValeur = obtenirValeurCombo("cbPrefixe");
1193
		strValeur = obtenirValeurCombo("cbPrefixe");
1200
		personneSelectionnee.set("ce_truk_prefix", strValeur);
1194
		personneSelectionnee.set("ce_truk_prefix", strValeur);
1201
		
1195
		
1202
		strValeur = obtenirValeurCombo("cbSuffixe"); 
1196
		strValeur = obtenirValeurCombo("cbSuffixe"); 
1203
		personneSelectionnee.set("ce_truk_suffix", strValeur);
1197
		personneSelectionnee.set("ce_truk_suffix", strValeur);
1204
		
1198
		
1205
		String nomAutre = ((ChampMultiValeurs) hmIdentite.get("nomAutre")).getValeurs();
1199
		String nomAutre = hmIdentite.getChampMultiValeurs("nomAutre").getValeurs();
1206
		personneSelectionnee.set("truk_nom_autre", nomAutre);
1200
		personneSelectionnee.set("truk_nom_autre", nomAutre);
1207
		
1201
		
1208
		String abreviationAutre = ((ChampMultiValeurs) hmIdentite.get("abreviationAutre")).getValeurs();
1202
		String abreviationAutre = hmIdentite.getChampMultiValeurs("abreviationAutre").getValeurs();
1209
		personneSelectionnee.set("truk_abreviation_autre", abreviationAutre);
1203
		personneSelectionnee.set("truk_abreviation_autre", abreviationAutre);
1210
		
1204
		
1211
		personneSelectionnee.set("truk_courriel", ((ChampMultiValeurs) hmIdentite.get("courriels")).getValeurs());
1205
		personneSelectionnee.set("truk_courriel", hmIdentite.getChampMultiValeurs("courriels").getValeurs());
1212
		
1206
		
1213
		
1207
		
1214
		//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
1208
		//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
1215
		String strPrefixe = "";
1209
		String strPrefixe = "";
1216
		combo = (ComboBox) hmIdentite.get("cbPrefixe");
1210
		combo = hmIdentite.getComboBoxValeur("cbPrefixe");
1217
		valeur = (Valeur) combo.getValue();
1211
		valeur = combo.getValue();
1218
		if (valeur != null)	{
1212
		if (valeur != null)	{
1219
			strPrefixe = valeur.getNom();
1213
			strPrefixe = valeur.getNom();
1220
		} else {
1214
		} else {
1221
			strPrefixe = combo.getRawValue();
1215
			strPrefixe = combo.getRawValue();
1222
		}
1216
		}
1223
		
1217
		
1224
		String strSuffixe = "";
1218
		String strSuffixe = "";
1225
		combo = (ComboBox) hmIdentite.get("cbSuffixe");
1219
		combo = hmIdentite.getComboBox("cbSuffixe");
1226
		valeur = (Valeur) combo.getValue();
1220
		valeur = combo.getValue();
1227
		if (valeur != null)	{
1221
		if (valeur != null)	{
1228
			strSuffixe = valeur.getNom() + " ";
1222
			strSuffixe = valeur.getNom() + " ";
1229
		} else {
1223
		} else {
1230
			strSuffixe = combo.getRawValue() +" ";
1224
			strSuffixe = combo.getRawValue() +" ";
1231
		}
1225
		}
1232
		
1226
		
1233
		personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe);
1227
		personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe);
1234
		
1228
		
1235
		DateField dfDateNaissance = (DateField) hmIdentite.get("dfDateNaissance");
1229
		DateField dfDateNaissance = hmIdentite.getDateField("dfDateNaissance");
1236
		Date naissanceDate = dfDateNaissance.getValue();
1230
		Date naissanceDate = dfDateNaissance.getValue();
1237
		personneSelectionnee.setNaissanceDate(naissanceDate);
1231
		personneSelectionnee.setNaissanceDate(naissanceDate);
1238
		
1232
		
1239
		Radio rbEstDecedee = (Radio) hmIdentite.get("rbEstDecedee");
1233
		Radio rbEstDecedee = hmIdentite.getRadio("rbEstDecedee");
1240
		if (rbEstDecedee.getValue() == true)	{
1234
		if (rbEstDecedee.getValue() == true)	{
1241
			DateField dfDecesDate = (DateField) hmIdentite.get("dfDateDeces");
1235
			DateField dfDecesDate = hmIdentite.getDateField("dfDateDeces");
1242
			String decesLieu = ((TextField<String>) hmIdentite.get("tfLieuDeces")).getValue();
1236
			String decesLieu = (String) hmIdentite.getTextField("tfLieuDeces").getValue();
1243
			personneSelectionnee.setDeces(dfDecesDate.getValue(), decesLieu);
1237
			personneSelectionnee.setDeces(dfDecesDate.getValue(), decesLieu);
1244
		}	else	{
1238
		}	else	{
1245
			personneSelectionnee.setNonDecedee();			
1239
			personneSelectionnee.setNonDecedee();			
1246
		}
1240
		}
1247
		
1241
		
1248
		strValeur = obtenirValeurCombo("cbPays");
1242
		strValeur = obtenirValeurCombo("cbPays");
1249
		personneSelectionnee.set("ce_truk_pays", strValeur);
1243
		personneSelectionnee.set("ce_truk_pays", strValeur);
1250
		
1244
		
1251
		strValeur = obtenirValeurCombo("cbRegion");
1245
		strValeur = obtenirValeurCombo("cbRegion");
1252
		personneSelectionnee.set("ce_truk_region", strValeur);
1246
		personneSelectionnee.set("ce_truk_region", strValeur);
1253
		
1247
		
1254
		personneSelectionnee.set("truk_telephone", ((ChampMultiValeursMultiTypes) hmIdentite.get("telephones")).getValeurs());
1248
		personneSelectionnee.set("truk_telephone", hmIdentite.getChampMultiValeursMultiTypes("telephones").getValeurs());
1255
		
1249
		
1256
		String logoUrls = ((ChampMultiValeursImage) hmIdentite.get("logos")).getValeurs();
1250
		String logoUrls = hmIdentite.getChampMultiValeursImage("logos").getValeurs();
1257
		personneSelectionnee.set("truk_logo", logoUrls);
1251
		personneSelectionnee.set("truk_logo", logoUrls);
1258
		
1252
		
1259
		personneSelectionnee.set("truk_url", ((ChampMultiValeurs) hmIdentite.get("sites")).getValeurs());
1253
		personneSelectionnee.set("truk_url", hmIdentite.getChampMultiValeurs("sites").getValeurs());
1260
		
1254
		
1261
		//Infos Naturalistes
1255
		//Infos Naturalistes
1262
		String recolte = ((ChampMultiValeursMultiTypes) hmInfosNat.get("recolte")).getValeurs();
1256
		String recolte = ((ChampMultiValeursMultiTypes) hmInfosNat.get("recolte")).getValeurs();
1263
		personneSelectionnee.set("truk_recolte", recolte);
1257
		personneSelectionnee.set("truk_recolte", recolte);
1264
		
1258
		
1265
		String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs();
1259
		String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs();
1266
		personneSelectionnee.set("ce_truk_specialite", specialite);
1260
		personneSelectionnee.set("ce_truk_specialite", specialite);
1267
		
1261
		
1268
		
1262
		
1269
		if (lstMessageErreur.size() != 0)	{
1263
		if (lstMessageErreur.size() != 0)	{
1270
			String strMessagesErreur = "<span><br />";
1264
			String strMessagesErreur = "<span><br />";
1271
			Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
1265
			Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
1272
			while (itMessagesErreur.hasNext())	{
1266
			while (itMessagesErreur.hasNext())	{
1273
				strMessagesErreur += "<br /> - " + itMessagesErreur.next();
1267
				strMessagesErreur += "<br /> - " + itMessagesErreur.next();
1274
			}
1268
			}
1275
			strMessagesErreur += "</span>";
1269
			strMessagesErreur += "</span>";
1276
			
1270
			
1277
 			MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
1271
 			MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
1278
 			success = false;
1272
 			success = false;
1279
		}
1273
		}
1280
		
1274
		
1281
		return success;
1275
		return success;
1282
	}
1276
	}
1283
}
1277
}