Subversion Repositories eFlore/Applications.coel

Rev

Rev 1845 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1845 Rev 1846
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.ChampMultiValeursMultiTypesPaginable;
17
import org.tela_botanica.client.composants.ChampMultiValeursMultiTypesPaginable;
18
import org.tela_botanica.client.composants.HashMapComposants;
18
import org.tela_botanica.client.composants.HashMapComposants;
19
import org.tela_botanica.client.configuration.Configuration;
19
import org.tela_botanica.client.configuration.Configuration;
20
import org.tela_botanica.client.images.Images;
20
import org.tela_botanica.client.images.Images;
21
import org.tela_botanica.client.interfaces.Rafraichissable;
21
import org.tela_botanica.client.interfaces.Rafraichissable;
22
 
22
 
23
import org.tela_botanica.client.modeles.Information;
23
import org.tela_botanica.client.modeles.Information;
24
import org.tela_botanica.client.modeles.MenuApplicationId;
24
import org.tela_botanica.client.modeles.MenuApplicationId;
25
import org.tela_botanica.client.modeles.Valeur;
25
import org.tela_botanica.client.modeles.Valeur;
26
import org.tela_botanica.client.modeles.ValeurListe;
26
import org.tela_botanica.client.modeles.ValeurListe;
27
import org.tela_botanica.client.modeles.personne.Personne;
27
import org.tela_botanica.client.modeles.personne.Personne;
28
import org.tela_botanica.client.modeles.personne.PersonneAsyncDao;
28
import org.tela_botanica.client.modeles.personne.PersonneAsyncDao;
29
import org.tela_botanica.client.modeles.personne.PersonneListe;
29
import org.tela_botanica.client.modeles.personne.PersonneListe;
30
import org.tela_botanica.client.modeles.publication.Publication;
30
import org.tela_botanica.client.modeles.publication.Publication;
31
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
31
import org.tela_botanica.client.modeles.publication.PublicationAPersonneListe;
32
import org.tela_botanica.client.modeles.publication.PublicationListe;
32
import org.tela_botanica.client.modeles.publication.PublicationListe;
33
import org.tela_botanica.client.synchronisation.Sequenceur;
33
import org.tela_botanica.client.synchronisation.Sequenceur;
34
import org.tela_botanica.client.util.Debug;
34
import org.tela_botanica.client.util.Debug;
35
import org.tela_botanica.client.util.Pattern;
35
import org.tela_botanica.client.util.Pattern;
36
import org.tela_botanica.client.util.UtilDate;
36
import org.tela_botanica.client.util.UtilDate;
37
import org.tela_botanica.client.util.UtilString;
37
import org.tela_botanica.client.util.UtilString;
38
import org.tela_botanica.client.vues.Formulaire;
38
import org.tela_botanica.client.vues.Formulaire;
39
 
39
 
40
import com.extjs.gxt.ui.client.data.ModelData;
40
import com.extjs.gxt.ui.client.data.ModelData;
41
import com.extjs.gxt.ui.client.data.ModelType;
41
import com.extjs.gxt.ui.client.data.ModelType;
42
import com.extjs.gxt.ui.client.data.PagingLoadResult;
42
import com.extjs.gxt.ui.client.data.PagingLoadResult;
43
import com.extjs.gxt.ui.client.event.Events;
43
import com.extjs.gxt.ui.client.event.Events;
44
import com.extjs.gxt.ui.client.Registry;
44
import com.extjs.gxt.ui.client.Registry;
45
import com.extjs.gxt.ui.client.Style.Scroll;
45
import com.extjs.gxt.ui.client.Style.Scroll;
46
import com.extjs.gxt.ui.client.Style.SortDir;
46
import com.extjs.gxt.ui.client.Style.SortDir;
47
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
47
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
48
 
48
 
49
import com.extjs.gxt.ui.client.binding.FieldBinding;
49
import com.extjs.gxt.ui.client.binding.FieldBinding;
50
import com.extjs.gxt.ui.client.binding.FormBinding;
50
import com.extjs.gxt.ui.client.binding.FormBinding;
51
 
51
 
52
import com.extjs.gxt.ui.client.event.BaseEvent;
52
import com.extjs.gxt.ui.client.event.BaseEvent;
53
import com.extjs.gxt.ui.client.event.ButtonEvent;
53
import com.extjs.gxt.ui.client.event.ButtonEvent;
54
import com.extjs.gxt.ui.client.event.ComponentEvent;
54
import com.extjs.gxt.ui.client.event.ComponentEvent;
55
import com.extjs.gxt.ui.client.event.KeyListener;
55
import com.extjs.gxt.ui.client.event.KeyListener;
56
import com.extjs.gxt.ui.client.event.Listener;
56
import com.extjs.gxt.ui.client.event.Listener;
57
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
57
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
58
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
58
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
59
import com.extjs.gxt.ui.client.event.SelectionListener;
59
import com.extjs.gxt.ui.client.event.SelectionListener;
-
 
60
import com.extjs.gxt.ui.client.event.WidgetListener;
60
import com.extjs.gxt.ui.client.store.ListStore;
61
import com.extjs.gxt.ui.client.store.ListStore;
61
import com.extjs.gxt.ui.client.widget.LayoutContainer;
62
import com.extjs.gxt.ui.client.widget.LayoutContainer;
62
import com.extjs.gxt.ui.client.widget.MessageBox;
63
import com.extjs.gxt.ui.client.widget.MessageBox;
63
 
64
 
64
import com.extjs.gxt.ui.client.widget.ContentPanel;
65
import com.extjs.gxt.ui.client.widget.ContentPanel;
65
import org.tela_botanica.client.composants.InfoLogger;
66
import org.tela_botanica.client.composants.InfoLogger;
66
import org.tela_botanica.client.composants.pagination.Proxy;
67
import org.tela_botanica.client.composants.pagination.Proxy;
67
import org.tela_botanica.client.composants.pagination.ProxyValeur;
68
import org.tela_botanica.client.composants.pagination.ProxyValeur;
68
 
69
 
69
import com.extjs.gxt.ui.client.widget.TabItem;
70
import com.extjs.gxt.ui.client.widget.TabItem;
70
import com.extjs.gxt.ui.client.widget.TabPanel;
71
import com.extjs.gxt.ui.client.widget.TabPanel;
71
import com.extjs.gxt.ui.client.widget.Text;
72
import com.extjs.gxt.ui.client.widget.Text;
72
 
73
 
73
import com.extjs.gxt.ui.client.widget.button.Button;
74
import com.extjs.gxt.ui.client.widget.button.Button;
74
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
75
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
75
import com.extjs.gxt.ui.client.widget.form.ComboBox;
76
import com.extjs.gxt.ui.client.widget.form.ComboBox;
76
import com.extjs.gxt.ui.client.widget.form.DateField;
77
import com.extjs.gxt.ui.client.widget.form.DateField;
77
import com.extjs.gxt.ui.client.widget.form.Field;
78
import com.extjs.gxt.ui.client.widget.form.Field;
78
import com.extjs.gxt.ui.client.widget.form.FieldSet;
79
import com.extjs.gxt.ui.client.widget.form.FieldSet;
79
import com.extjs.gxt.ui.client.widget.form.LabelField;
80
import com.extjs.gxt.ui.client.widget.form.LabelField;
80
import com.extjs.gxt.ui.client.widget.form.Radio;
81
import com.extjs.gxt.ui.client.widget.form.Radio;
81
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
82
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
82
import com.extjs.gxt.ui.client.widget.form.TextArea;
83
import com.extjs.gxt.ui.client.widget.form.TextArea;
83
import com.extjs.gxt.ui.client.widget.form.TextField;
84
import com.extjs.gxt.ui.client.widget.form.TextField;
84
import com.extjs.gxt.ui.client.widget.form.Validator;
85
import com.extjs.gxt.ui.client.widget.form.Validator;
85
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
86
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
86
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
87
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
87
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
88
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
88
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
89
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
89
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
90
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
90
import com.extjs.gxt.ui.client.widget.layout.FormData;
91
import com.extjs.gxt.ui.client.widget.layout.FormData;
91
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
92
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
92
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
93
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
93
import com.extjs.gxt.ui.client.widget.layout.TableData;
94
import com.extjs.gxt.ui.client.widget.layout.TableData;
94
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
95
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
95
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
96
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
96
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
97
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
97
import com.google.gwt.core.client.Callback;
98
import com.google.gwt.core.client.Callback;
98
import com.google.gwt.core.client.GWT;
99
import com.google.gwt.core.client.GWT;
99
import com.google.gwt.json.client.JSONArray;
100
import com.google.gwt.json.client.JSONArray;
100
import com.google.gwt.json.client.JSONObject;
101
import com.google.gwt.json.client.JSONObject;
101
import com.google.gwt.user.client.Window;
102
import com.google.gwt.user.client.Window;
102
 
103
 
103
public class PersonneForm extends Formulaire implements Rafraichissable {
104
public class PersonneForm extends Formulaire implements Rafraichissable {
104
 
105
 
105
	// VARIABLES
106
	// VARIABLES
106
	private TabItem tiIdentite, tiAdresses, tiInfosNat;
107
	private TabItem tiIdentite, tiAdresses, tiInfosNat;
107
	PersonneFormPublication tiPubli;
108
	PersonneFormPublication tiPubli;
108
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
109
	private Configuration config = (Configuration) Registry.get(RegistreId.CONFIG);
109
	protected Personne personneSelectionnee, personneSauvegarde = null;
110
	protected Personne personneSelectionnee, personneSauvegarde = null;
110
	
111
	
111
	//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
112
	//hmIdentite[...] référence par une chaine de caractère tous les composants de l'onglet Identite
112
	private HashMapComposants hmIdentite = new HashMapComposants();
113
	private HashMapComposants hmIdentite = new HashMapComposants();
113
	private HashMapComposants hmAdresse = new HashMapComposants();
114
	private HashMapComposants hmAdresse = new HashMapComposants();
114
	private HashMapComposants hmInfosNat = new HashMapComposants();
115
	private HashMapComposants hmInfosNat = new HashMapComposants();
115
	private HashMap<String, Valeur> hmCbSelectionnee = new HashMap();
116
	private HashMap<String, Valeur> hmCbSelectionnee = new HashMap();
116
	private FormData fd100 = new FormData("95%");
117
	private FormData fd100 = new FormData("95%");
117
	
118
	
118
	private Button enregistrer, enregistrerEtRevenir;
119
	private Button enregistrer, enregistrerEtRevenir;
119
	
120
	
120
	private Personne personne = null;
121
	private Personne personne = null;
121
	private String personneId = null;
122
	private String personneId = null;
122
	private FormBinding binding = null;
123
	private FormBinding binding = null;
123
	
124
	
124
	//Gestion du mode synchrone
125
	//Gestion du mode synchrone
125
	private Sequenceur sequenceur;
126
	private Sequenceur sequenceur;
126
	
127
	
127
	//Publi
128
	//Publi
128
	private ComboBox<Publication> cbPubli;
129
	private ComboBox<Publication> cbPubli;
129
	private ListStore<Publication> storePubli;
130
	private ListStore<Publication> storePubli;
130
	
131
	
131
	// Gestion de la vérification des doublons
132
	// Gestion de la vérification des doublons
132
	private boolean verificationDoublonEffectuee = false;
133
	private boolean verificationDoublonEffectuee = false;
133
	
134
	
134
	// CONSTRUCTEUR  
135
	// CONSTRUCTEUR  
135
	public PersonneForm(Mediateur mediateurCourrant, String personneId) {
136
	public PersonneForm(Mediateur mediateurCourrant, String personneId) {
136
		initialiserPersonneForm(mediateurCourrant, personneId);
137
		initialiserPersonneForm(mediateurCourrant, personneId);
137
	}
138
	}
138
	
139
	
139
	public PersonneForm(Mediateur mediateurCourrant, String personneId, Rafraichissable vueARafraichirApresValidation) {
140
	public PersonneForm(Mediateur mediateurCourrant, String personneId, Rafraichissable vueARafraichirApresValidation) {
140
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
141
		vueExterneARafraichirApresValidation = vueARafraichirApresValidation;
141
		initialiserPersonneForm(mediateurCourrant, personneId);		
142
		initialiserPersonneForm(mediateurCourrant, personneId);		
142
	}
143
	}
143
	
144
	
144
	private void initialiserPersonneForm(Mediateur mediateurCourrant, String personneIdCourrant) {
145
	private void initialiserPersonneForm(Mediateur mediateurCourrant, String personneIdCourrant) {
145
		
146
		
146
		//Initialisation du séquenceur
147
		//Initialisation du séquenceur
147
		sequenceur = new Sequenceur();
148
		sequenceur = new Sequenceur();
148
		personne = new Personne();
149
		personne = new Personne();
149
		personne.setId(personneIdCourrant);
150
		personne.setId(personneIdCourrant);
150
		personneId = personneIdCourrant;
151
		personneId = personneIdCourrant;
151
		
152
		
152
		String modeDeCreation = (UtilString.isEmpty(personneId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
153
		String modeDeCreation = (UtilString.isEmpty(personneId) ? Formulaire.MODE_AJOUTER : Formulaire.MODE_MODIFIER);
153
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PERSONNE);
154
		initialiserFormulaire(mediateurCourrant, modeDeCreation, MenuApplicationId.PERSONNE);
154
 
155
 
155
		initialiserComposants();
156
		initialiserComposants();
156
		genererTitreFormulaire();
157
		genererTitreFormulaire();
157
		
158
		
158
		mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", sequenceur);
159
		mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", sequenceur);
159
		mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", null);
160
		mediateur.obtenirListeValeurEtRafraichir(this, "relationPersonnePublication", null);
160
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
161
		if (modeDeCreation.equals(Formulaire.MODE_MODIFIER)) {
161
			mediateur.selectionnerPersonne(this, personne.getId(), sequenceur);
162
			mediateur.selectionnerPersonne(this, personne.getId(), sequenceur);
162
		}
163
		}
163
	}
164
	}
164
	
165
	
165
	private void genererTitreFormulaire() {
166
	private void genererTitreFormulaire() {
166
		String titre = i18nC.personneModeAjout();
167
		String titre = i18nC.personneModeAjout();
167
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
168
		if (mode.equals(Formulaire.MODE_MODIFIER)) {
168
			 titre = i18nC.personneModeModifier()+" - "+i18nC.id()+": "+personneId;
169
			 titre = i18nC.personneModeModifier()+" - "+i18nC.id()+": "+personneId;
169
		}
170
		}
170
		panneauFormulaire.setHeadingHtml(titre);
171
		panneauFormulaire.setHeadingHtml(titre);
171
	}
172
	}
172
	
173
	
173
	public void initialiserComposants()	{
174
	public void initialiserComposants()	{
174
		personneSelectionnee = new Personne();
175
		personneSelectionnee = new Personne();
175
		personneSauvegarde = new Personne();
176
		personneSauvegarde = new Personne();
176
		
177
		
177
		initialiserOnglets();	
178
		initialiserOnglets();	
178
		
179
		
179
		creerComposantsIdentite();
180
		creerComposantsIdentite();
180
		creerComposantsAdresse();
181
		creerComposantsAdresse();
181
		creerComposantsInfosNat();
182
		creerComposantsInfosNat();
182
		//creerComposantsPubli();
183
		//creerComposantsPubli();
183
		
184
		
184
		binderPersonne(personneSelectionnee);
185
		binderPersonne(personneSelectionnee);
185
	}
186
	}
186
	
187
	
187
	/**
188
	/**
188
	 * Crée les onglets identité, adresse et informations naturaliste
189
	 * Crée les onglets identité, adresse et informations naturaliste
189
	 * 
190
	 * 
190
	 * */
191
	 * */
191
	public void initialiserOnglets()	{
192
	public void initialiserOnglets()	{
192
		//TabPanel
193
		//TabPanel
193
		TabPanel formulaireOnglets = new TabPanel();
194
		TabPanel formulaireOnglets = new TabPanel();
194
		
195
		
195
		//Tab 1 : identite
196
		//Tab 1 : identite
196
		tiIdentite = creerOnglet(i18nC.personneIdentite(), "tiIdentite");
197
		tiIdentite = creerOnglet(i18nC.personneIdentite(), "tiIdentite");
197
		tiIdentite.setStyleAttribute("padding", "0");
198
		tiIdentite.setStyleAttribute("padding", "0");
198
		formulaireOnglets.add(tiIdentite);
199
		formulaireOnglets.add(tiIdentite);
199
		
200
		
200
		//Tab 2 : Adresse
201
		//Tab 2 : Adresse
201
		tiAdresses = creerOnglet(i18nC.adresse(), "tiAdresses");
202
		tiAdresses = creerOnglet(i18nC.adresse(), "tiAdresses");
202
		formulaireOnglets.add(tiAdresses);
203
		formulaireOnglets.add(tiAdresses);
203
		
204
		
204
		//Tab 3 : Infos Naturalistes
205
		//Tab 3 : Infos Naturalistes
205
		tiInfosNat = creerOnglet(i18nC.personneInfoNat(), "tiInfosNat");
206
		tiInfosNat = creerOnglet(i18nC.personneInfoNat(), "tiInfosNat");
206
		formulaireOnglets.add(tiInfosNat);
207
		formulaireOnglets.add(tiInfosNat);
207
		
208
		
208
		//Tab 4 : Publications
209
		//Tab 4 : Publications
209
		tiPubli = new PersonneFormPublication(this);
210
		tiPubli = new PersonneFormPublication(this);
210
		formulaireOnglets.add(tiPubli);
211
		formulaireOnglets.add(tiPubli);
211
	
212
	
212
		getFormulaire().add(formulaireOnglets);
213
		getFormulaire().add(formulaireOnglets);
213
	}
214
	}
214
	
215
	
215
	/**
216
	/**
216
	 * Crée les widgets pour l'onglet identité
217
	 * Crée les widgets pour l'onglet identité
217
	 * 
218
	 * 
218
	 * */
219
	 * */
219
	
220
	
220
	
221
	
221
	public void creerComposantsIdentite()	{
222
	public void creerComposantsIdentite()	{
222
		// Gestion de l'affichage en colonnes : 3 Layout container : principal, gauche & droite
223
		// Gestion de l'affichage en colonnes : 3 Layout container : principal, gauche & droite
223
		LayoutContainer left = new LayoutContainer();
224
		LayoutContainer left = new LayoutContainer();
224
		left.setLayout(new FormLayout());
225
		left.setLayout(new FormLayout());
225
		left.setStyleAttribute("padding", "15px");
226
		left.setStyleAttribute("padding", "15px");
226
		
227
		
227
		LayoutContainer right = new LayoutContainer();
228
		LayoutContainer right = new LayoutContainer();
228
		right.setLayout(new FormLayout());
229
		right.setLayout(new FormLayout());
229
		right.setStyleAttribute("padding", "15px");
230
		right.setStyleAttribute("padding", "15px");
230
		
231
		
231
		LayoutContainer main = new LayoutContainer();
232
		LayoutContainer main = new LayoutContainer();
232
		
233
		
233
		main.add(left, new ColumnData(.45));
234
		main.add(left, new ColumnData(.45));
234
		main.add(right, new ColumnData(.50));
235
		main.add(right, new ColumnData(.50));
235
		
236
		
236
		main.setLayout(new ColumnLayout());
237
		main.setLayout(new ColumnLayout());
237
		main.setHeight("100%");
238
		main.setHeight("100%");
238
		main.setScrollMode(Scroll.AUTO);
239
		main.setScrollMode(Scroll.AUTO);
239
		
240
		
240
		// Création des champs
241
		// Création des champs
241
		FormLayout formLayout = new FormLayout();
242
		FormLayout formLayout = new FormLayout();
242
		formLayout.setLabelAlign(LabelAlign.LEFT);
243
		formLayout.setLabelAlign(LabelAlign.LEFT);
243
			
244
			
244
		//+------------------------------------------------------------------------------------------------------------+
245
		//+------------------------------------------------------------------------------------------------------------+
245
		// Fieldset NOM
246
		// Fieldset NOM
246
		FieldSet fsNoms = new FieldSet();
247
		FieldSet fsNoms = new FieldSet();
247
		fsNoms.setHeadingHtml("Noms");
248
		fsNoms.setHeadingHtml("Noms");
248
		fsNoms.setLayout(formLayout); 
249
		fsNoms.setLayout(formLayout); 
249
					
250
					
250
		// Nom complet : Affiché que si valeurs saisies
251
		// Nom complet : Affiché que si valeurs saisies
251
		LabelField nomComplet = new LabelField();
252
		LabelField nomComplet = new LabelField();
252
		nomComplet.setFieldLabel(i18nC.personneNomComplet() +" :");
253
		nomComplet.setFieldLabel(i18nC.personneNomComplet() +" :");
253
		nomComplet.hide();
254
		nomComplet.hide();
254
				
255
				
255
		fsNoms.add(nomComplet);
256
		fsNoms.add(nomComplet);
256
		hmIdentite.put("nomComplet", nomComplet);
257
		hmIdentite.put("nomComplet", nomComplet);
257
			
258
			
258
		//Préfixe
259
		//Préfixe
259
		ListStore<Valeur> storePrefixe = new ListStore<Valeur>();
260
		ListStore<Valeur> storePrefixe = new ListStore<Valeur>();
260
		ComboBox<Valeur> cbPrefixe = new ComboBox<Valeur>();
261
		ComboBox<Valeur> cbPrefixe = new ComboBox<Valeur>();
261
		cbPrefixe.setStore(storePrefixe);
262
		cbPrefixe.setStore(storePrefixe);
262
		cbPrefixe.setDisplayField("nom");
263
		cbPrefixe.setDisplayField("nom");
263
		cbPrefixe.setEmptyText("Choisissez le préfixe:");
264
		cbPrefixe.setEmptyText("Choisissez le préfixe:");
264
		cbPrefixe.setFieldLabel("Prefix");
265
		cbPrefixe.setFieldLabel("Prefix");
265
		
266
		
266
		fsNoms.add(cbPrefixe);
267
		fsNoms.add(cbPrefixe);
267
		hmIdentite.put("cbPrefixe", cbPrefixe);
268
		hmIdentite.put("cbPrefixe", cbPrefixe);
268
		
269
		
269
		mediateur.obtenirListeValeurEtRafraichir(this, "prefixe", sequenceur);
270
		mediateur.obtenirListeValeurEtRafraichir(this, "prefixe", sequenceur);
270
 
271
 
271
		//Prénom
272
		//Prénom
272
		TextField<String> tfPrenom = new TextField<String>();
273
		TextField<String> tfPrenom = new TextField<String>();
273
		tfPrenom.setFieldLabel("Prénom");
274
		tfPrenom.setFieldLabel("Prénom");
274
		tfPrenom.setName("prenom");
275
		tfPrenom.setName("prenom");
275
 
276
 
276
		fsNoms.add(tfPrenom, new FormData(300, 0));
277
		fsNoms.add(tfPrenom, new FormData(300, 0));
277
		hmIdentite.put("tfPrenom", tfPrenom);
278
		hmIdentite.put("tfPrenom", tfPrenom);
278
		
279
		
279
		tfPrenom.addListener(Events.Blur, creerEcouteurNomPrenomExistant());
280
		tfPrenom.addListener(Events.Blur, creerEcouteurNomPrenomExistant());
280
		tfPrenom.addListener(Events.Change, new Listener<BaseEvent>() {
281
		tfPrenom.addListener(Events.Change, new Listener<BaseEvent>() {
281
			@Override
282
			@Override
282
			public void handleEvent(BaseEvent be) {
283
			public void handleEvent(BaseEvent be) {
283
				verificationDoublonEffectuee = false;	
284
				verificationDoublonEffectuee = false;	
284
			}
285
			}
285
		});
286
		});
286
 
287
 
287
		//Nom
288
		//Nom
288
		TextField<String> tfNom = new TextField<String>();
289
		TextField<String> tfNom = new TextField<String>();
289
		tfNom.setFieldLabel("Nom");
290
		tfNom.setFieldLabel("Nom");
290
		tfNom.setAllowBlank(false);
291
		tfNom.setAllowBlank(false);
291
		tfNom.setName("nom");
292
		tfNom.setName("nom");
292
		tfNom.addStyleName(ComposantClass.OBLIGATOIRE);
293
		tfNom.addStyleName(ComposantClass.OBLIGATOIRE);
293
		tfNom.addListener(Events.Valid, creerEcouteurChampObligatoire());
294
		tfNom.addListener(Events.Valid, creerEcouteurChampObligatoire());
294
		
295
		
295
		tfNom.addListener(Events.Blur, creerEcouteurNomPrenomExistant());
296
		tfNom.addListener(Events.Blur, creerEcouteurNomPrenomExistant());
296
		tfNom.addListener(Events.Change, new Listener<BaseEvent>() {
297
		tfNom.addListener(Events.Change, new Listener<BaseEvent>() {
297
			@Override
298
			@Override
298
			public void handleEvent(BaseEvent be) {
299
			public void handleEvent(BaseEvent be) {
299
				verificationDoublonEffectuee = false;	
300
				verificationDoublonEffectuee = false;	
300
			}
301
			}
301
		});
302
		});
302
		
303
		
303
		fsNoms.add(tfNom, new FormData(300, 0));
304
		fsNoms.add(tfNom, new FormData(300, 0));
304
		hmIdentite.put("tfNom", tfNom);
305
		hmIdentite.put("tfNom", tfNom);
305
		
306
		
306
		//Suffixe
307
		//Suffixe
307
		ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();
308
		ListStore<Valeur> storeSuffixe = new ListStore<Valeur>();
308
		ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();
309
		ComboBox<Valeur> cbSuffixe = new ComboBox<Valeur>();
309
		cbSuffixe.setStore(storeSuffixe);
310
		cbSuffixe.setStore(storeSuffixe);
310
		cbSuffixe.setFieldLabel("Suffixe");
311
		cbSuffixe.setFieldLabel("Suffixe");
311
		cbSuffixe.setDisplayField("nom");
312
		cbSuffixe.setDisplayField("nom");
312
		cbSuffixe.setEmptyText("Choisissez un suffixe:");
313
		cbSuffixe.setEmptyText("Choisissez un suffixe:");
313
		
314
		
314
		fsNoms.add(cbSuffixe);			
315
		fsNoms.add(cbSuffixe);			
315
		hmIdentite.put("cbSuffixe", cbSuffixe);
316
		hmIdentite.put("cbSuffixe", cbSuffixe);
316
		
317
		
317
		mediateur.obtenirListeValeurEtRafraichir(this, "suffixes", sequenceur);
318
		mediateur.obtenirListeValeurEtRafraichir(this, "suffixes", sequenceur);
318
 
319
 
319
		TextField<String> tfAbreviation = new TextField<String>();
320
		TextField<String> tfAbreviation = new TextField<String>();
320
		tfAbreviation.setFieldLabel("Abréviation");
321
		tfAbreviation.setFieldLabel("Abréviation");
321
		tfAbreviation.setName("abreviation");
322
		tfAbreviation.setName("abreviation");
322
		
323
		
323
		fsNoms.add(tfAbreviation);
324
		fsNoms.add(tfAbreviation);
324
		hmIdentite.put("tfAbreviation", tfAbreviation);
325
		hmIdentite.put("tfAbreviation", tfAbreviation);
325
 
326
 
326
		TableLayout layoutAutreNoms = new TableLayout(2);
327
		TableLayout layoutAutreNoms = new TableLayout(2);
327
		layoutAutreNoms.setCellVerticalAlign(VerticalAlignment.TOP);
328
		layoutAutreNoms.setCellVerticalAlign(VerticalAlignment.TOP);
328
		LayoutContainer autresNoms = new LayoutContainer(layoutAutreNoms);
329
		LayoutContainer autresNoms = new LayoutContainer(layoutAutreNoms);
329
		ChampMultiValeurs nomAutre = new ChampMultiValeurs("Autres noms",150);
330
		ChampMultiValeurs nomAutre = new ChampMultiValeurs("Autres noms",150);
330
		hmIdentite.put("nomAutre", nomAutre);
331
		hmIdentite.put("nomAutre", nomAutre);
331
		autresNoms.add(nomAutre, new TableData("200px", "15px"));
332
		autresNoms.add(nomAutre, new TableData("200px", "15px"));
332
		
333
		
333
		ChampMultiValeurs abreviationAutre = new ChampMultiValeurs("Autres abréviation",150);
334
		ChampMultiValeurs abreviationAutre = new ChampMultiValeurs("Autres abréviation",150);
334
		hmIdentite.put("abreviationAutre", abreviationAutre);
335
		hmIdentite.put("abreviationAutre", abreviationAutre);
335
		autresNoms.add(abreviationAutre, new TableData("200px", "15px"));
336
		autresNoms.add(abreviationAutre, new TableData("200px", "15px"));
336
		fsNoms.add(autresNoms);
337
		fsNoms.add(autresNoms);
337
										
338
										
338
		left.add(fsNoms);
339
		left.add(fsNoms);
339
		
340
		
340
		//+------------------------------------------------------------------------------------------------------------+
341
		//+------------------------------------------------------------------------------------------------------------+
341
		// Fieldset NAISSANCE ET DÉCÈS
342
		// Fieldset NAISSANCE ET DÉCÈS
342
		FieldSet fsNaissanceEtDeces = new FieldSet();
343
		FieldSet fsNaissanceEtDeces = new FieldSet();
343
		fsNaissanceEtDeces.setHeadingHtml("Naissance et Décès");
344
		fsNaissanceEtDeces.setHeadingHtml("Naissance et Décès");
344
		fsNaissanceEtDeces.setLayout(new ColumnLayout()); 
345
		fsNaissanceEtDeces.setLayout(new ColumnLayout()); 
345
		
346
		
346
		formLayout = new FormLayout();
347
		formLayout = new FormLayout();
347
		formLayout.setLabelAlign(LabelAlign.TOP);
348
		formLayout.setLabelAlign(LabelAlign.TOP);
348
		LayoutContainer containerNaissance = new LayoutContainer(formLayout);
349
		LayoutContainer containerNaissance = new LayoutContainer(formLayout);
349
				
350
				
350
		//Remplacement du DateField par un champ texte
351
		//Remplacement du DateField par un champ texte
351
		TextField tfDateNaissance = new TextField();
352
		TextField tfDateNaissance = new TextField();
352
		tfDateNaissance.setFieldLabel("Date de naissance");
353
		tfDateNaissance.setFieldLabel("Date de naissance");
353
		containerNaissance.add(tfDateNaissance);
354
		containerNaissance.add(tfDateNaissance);
354
		hmIdentite.put("tfDateNaissance", tfDateNaissance);
355
		hmIdentite.put("tfDateNaissance", tfDateNaissance);
355
		
356
		
356
		// Lieu naissance
357
		// Lieu naissance
357
		TextField<String> tfLieuNaissance = new TextField<String>();
358
		TextField<String> tfLieuNaissance = new TextField<String>();
358
		tfLieuNaissance.setFieldLabel("Lieu de naissance");
359
		tfLieuNaissance.setFieldLabel("Lieu de naissance");
359
		tfLieuNaissance.setName("naissance_lieu");
360
		tfLieuNaissance.setName("naissance_lieu");
360
		
361
		
361
		containerNaissance.add(tfLieuNaissance);
362
		containerNaissance.add(tfLieuNaissance);
362
		hmIdentite.put("tfLieuNaissance", tfLieuNaissance);
363
		hmIdentite.put("tfLieuNaissance", tfLieuNaissance);
363
		
364
		
364
		fsNaissanceEtDeces.add(containerNaissance, new ColumnData(.5));
365
		fsNaissanceEtDeces.add(containerNaissance, new ColumnData(.5));
365
		left.add(fsNaissanceEtDeces);
366
		left.add(fsNaissanceEtDeces);
366
		
367
		
367
		formLayout = new FormLayout();
368
		formLayout = new FormLayout();
368
		formLayout.setLabelAlign(LabelAlign.TOP);
369
		formLayout.setLabelAlign(LabelAlign.TOP);
369
		LayoutContainer containerDeces = new LayoutContainer(formLayout);
370
		LayoutContainer containerDeces = new LayoutContainer(formLayout);
370
		
371
		
371
		Radio rbEstDecedee = new Radio();
372
		Radio rbEstDecedee = new Radio();
372
		rbEstDecedee.setId("ce_deces");
373
		rbEstDecedee.setId("ce_deces");
373
		
374
		
374
		rbEstDecedee.setBoxLabel("oui");
375
		rbEstDecedee.setBoxLabel("oui");
375
		rbEstDecedee.setValueAttribute("1");
376
		rbEstDecedee.setValueAttribute("1");
376
		rbEstDecedee.setId("rbEstD");
377
		rbEstDecedee.setId("rbEstD");
377
		
378
		
378
		rbEstDecedee.addListener(Events.Change, new Listener<ComponentEvent>() {
379
		rbEstDecedee.addListener(Events.Change, new Listener<ComponentEvent>() {
379
						
380
						
380
			public void handleEvent(ComponentEvent be) {
381
			public void handleEvent(ComponentEvent be) {
381
				if(((Radio) be.getComponent()).getValue().equals(true))	{
382
				if(((Radio) be.getComponent()).getValue().equals(true))	{
382
					hmIdentite.getTextField("tfDateDeces").setVisible(true);
383
					hmIdentite.getTextField("tfDateDeces").setVisible(true);
383
					hmIdentite.getTextField("tfLieuDeces").setVisible(true);
384
					hmIdentite.getTextField("tfLieuDeces").setVisible(true);
384
				} else	{
385
				} else	{
385
					TextField tfDateDeces = hmIdentite.getTextField("tfDateDeces");
386
					TextField tfDateDeces = hmIdentite.getTextField("tfDateDeces");
386
					tfDateDeces.setValue(null);
387
					tfDateDeces.setValue(null);
387
					tfDateDeces.setVisible(false);
388
					tfDateDeces.setVisible(false);
388
					
389
					
389
					TextField tfLieuDeces = hmIdentite.getTextField("tfLieuDeces");
390
					TextField tfLieuDeces = hmIdentite.getTextField("tfLieuDeces");
390
					tfLieuDeces.setValue(null);
391
					tfLieuDeces.setValue(null);
391
					tfLieuDeces.setVisible(false);
392
					tfLieuDeces.setVisible(false);
392
				}
393
				}
393
			}	
394
			}	
394
		});
395
		});
395
					
396
					
396
		TextField tfDateDeces = new TextField();
397
		TextField tfDateDeces = new TextField();
397
		tfDateDeces.setFieldLabel("Date de décès");
398
		tfDateDeces.setFieldLabel("Date de décès");
398
		tfDateDeces.setVisible(false);
399
		tfDateDeces.setVisible(false);
399
 
400
 
400
		containerDeces.add(tfDateDeces);
401
		containerDeces.add(tfDateDeces);
401
		hmIdentite.put("tfDateDeces", tfDateDeces);
402
		hmIdentite.put("tfDateDeces", tfDateDeces);
402
 
403
 
403
		TextField<String> tfLieuDeces = new TextField<String>();
404
		TextField<String> tfLieuDeces = new TextField<String>();
404
		tfLieuDeces.setFieldLabel("Lieu de décès");
405
		tfLieuDeces.setFieldLabel("Lieu de décès");
405
		tfLieuDeces.setName("deces_lieu");
406
		tfLieuDeces.setName("deces_lieu");
406
		tfLieuDeces.setVisible(false);
407
		tfLieuDeces.setVisible(false);
407
		
408
		
408
		containerDeces.add(tfLieuDeces);
409
		containerDeces.add(tfLieuDeces);
409
		hmIdentite.put("tfLieuDeces", tfLieuDeces);
410
		hmIdentite.put("tfLieuDeces", tfLieuDeces);
410
		hmIdentite.put("rbEstDecedee", rbEstDecedee);
411
		hmIdentite.put("rbEstDecedee", rbEstDecedee);
411
		
412
		
412
		Radio rbNestPasDecedee = new Radio();
413
		Radio rbNestPasDecedee = new Radio();
413
		rbNestPasDecedee.setValueAttribute("0");
414
		rbNestPasDecedee.setValueAttribute("0");
414
		rbNestPasDecedee.setBoxLabel("non");
415
		rbNestPasDecedee.setBoxLabel("non");
415
		rbNestPasDecedee.setValue(true);
416
		rbNestPasDecedee.setValue(true);
416
			
417
			
417
		RadioGroup rbgDeces = new RadioGroup();
418
		RadioGroup rbgDeces = new RadioGroup();
418
		rbgDeces.setId("rbgDeces");
419
		rbgDeces.setId("rbgDeces");
419
				
420
				
420
		rbgDeces.setFieldLabel("Est décédée");
421
		rbgDeces.setFieldLabel("Est décédée");
421
		rbgDeces.add(rbEstDecedee);
422
		rbgDeces.add(rbEstDecedee);
422
		rbgDeces.add(rbNestPasDecedee);
423
		rbgDeces.add(rbNestPasDecedee);
423
		hmIdentite.put("rbgDeces", rbgDeces);
424
		hmIdentite.put("rbgDeces", rbgDeces);
424
		
425
		
425
		containerDeces.add(rbgDeces);
426
		containerDeces.add(rbgDeces);
426
		
427
		
427
		fsNaissanceEtDeces.add(containerDeces, new ColumnData(.5));
428
		fsNaissanceEtDeces.add(containerDeces, new ColumnData(.5));
428
		tiIdentite.add(main);
429
		tiIdentite.add(main);
429
		
430
		
430
		//+------------------------------------------------------------------------------------------------------------+
431
		//+------------------------------------------------------------------------------------------------------------+
431
		// Fieldset CONTACT
432
		// Fieldset CONTACT
432
		FieldSet fsContact = new FieldSet();
433
		FieldSet fsContact = new FieldSet();
433
		fsContact.setHeadingHtml("Contact");
434
		fsContact.setHeadingHtml("Contact");
-
 
435
		fsContact.setWidth("95%");
434
		fsContact.setLayout(new RowLayout());
436
		fsContact.setLayout(new RowLayout());
435
		
437
		
436
		ChampMultiValeursMultiTypes telephones = new ChampMultiValeursMultiTypes("Téléphones", 180, 100);
438
		ChampMultiValeursMultiTypes telephones = new ChampMultiValeursMultiTypes("Téléphones", 180, 100);
437
		telephones.initialiserType("tel");
439
		telephones.initialiserType("tel");
438
		fsContact.add(telephones, new FormData(450, 0));
440
		fsContact.add(telephones, new FormData(450, 0));
439
		hmIdentite.put("telephones", telephones);
441
		hmIdentite.put("telephones", telephones);
440
		
442
		
441
		ChampMultiValeurs courriels = new ChampMultiValeurs("Courriels", 280);
443
		ChampMultiValeurs courriels = new ChampMultiValeurs("Courriels", 280);
442
		courriels.setValidation(Pattern.email, "moi@domaine.fr");
444
		courriels.setValidation(Pattern.email, "moi@domaine.fr");
443
		fsContact.add(courriels, new FormData(450, 0));
445
		fsContact.add(courriels, new FormData(450, 0));
444
		hmIdentite.put("courriels", courriels);
446
		hmIdentite.put("courriels", courriels);
445
		
447
		
446
		LayoutContainer lcCourrielContainer = new LayoutContainer(new RowLayout());
448
		LayoutContainer lcCourrielContainer = new LayoutContainer(new RowLayout());
447
		fsContact.add(lcCourrielContainer);
449
		fsContact.add(lcCourrielContainer);
448
		hmIdentite.put("lcCourrielContainer", lcCourrielContainer);
450
		hmIdentite.put("lcCourrielContainer", lcCourrielContainer);
449
 
451
 
450
		fsContact.add(new Text(""));
452
		fsContact.add(new Text(""));
451
		
453
		
452
		ChampMultiValeurs sites = new ChampMultiValeurs("Sites web");
454
		ChampMultiValeurs sites = new ChampMultiValeurs("Sites web");
-
 
455
		sites.setWidth("95%");
453
		sites.setValeurParDefaut("http://");
456
		sites.setValeurParDefaut("http://");
454
		sites.setValidation(Pattern.url, "http://www.monsite.com");
457
		sites.setValidation(Pattern.url, "http://www.monsite.com");
455
		fsContact.add(sites);
458
		fsContact.add(sites);
456
		hmIdentite.put("sites", sites);
459
		hmIdentite.put("sites", sites);
457
		
460
		
458
		right.add(fsContact);
461
		right.add(fsContact);
459
		
462
		
460
		//+------------------------------------------------------------------------------------------------------------+
463
		//+------------------------------------------------------------------------------------------------------------+
461
		// Fieldset AUTRES INFOS
464
		// Fieldset AUTRES INFOS
462
		FieldSet fsAutresInfos = new FieldSet();
465
		FieldSet fsAutresInfos = new FieldSet();
463
		fsAutresInfos.setHeadingHtml("Autres informations");
466
		fsAutresInfos.setHeadingHtml("Autres informations");
-
 
467
		fsAutresInfos.setWidth("95%");
464
	
468
	
465
		formLayout = new FormLayout();
469
		formLayout = new FormLayout();
466
		formLayout.setLabelAlign(LabelAlign.LEFT);
470
		formLayout.setLabelAlign(LabelAlign.LEFT);
467
		fsAutresInfos.setLayout(formLayout); 
471
		fsAutresInfos.setLayout(formLayout); 
468
			
472
			
469
				
473
				
470
		formLayout = new FormLayout();
474
		formLayout = new FormLayout();
471
		formLayout.setLabelAlign(LabelAlign.TOP);
475
		formLayout.setLabelAlign(LabelAlign.TOP);
472
		LayoutContainer lcAutreInformations1 = new LayoutContainer(formLayout);
476
		LayoutContainer lcAutreInformations1 = new LayoutContainer(formLayout);
473
				
477
				
474
		ListStore<Valeur> storeSexe = new ListStore<Valeur>();
478
		ListStore<Valeur> storeSexe = new ListStore<Valeur>();
475
		ComboBox<Valeur> cbSexe = new ComboBox<Valeur>();
479
		ComboBox<Valeur> cbSexe = new ComboBox<Valeur>();
476
		cbSexe.setStore(storeSexe);
480
		cbSexe.setStore(storeSexe);
477
		cbSexe.setFieldLabel("Sexe");
481
		cbSexe.setFieldLabel("Sexe");
478
		cbSexe.setDisplayField("nom");
482
		cbSexe.setDisplayField("nom");
479
		cbSexe.setEmptyText("Choisissez le sexe:");
483
		cbSexe.setEmptyText("Choisissez le sexe:");
480
		cbSexe.setTypeAhead(true);
484
		cbSexe.setTypeAhead(true);
481
		cbSexe.setTriggerAction(TriggerAction.ALL);  
485
		cbSexe.setTriggerAction(TriggerAction.ALL);  
482
		
486
		
483
		FormData fd = new FormData();
487
		FormData fd = new FormData();
484
		fd.setWidth(100);
488
		fd.setWidth(100);
485
		lcAutreInformations1.add(cbSexe, fd);			
489
		lcAutreInformations1.add(cbSexe, fd);			
486
		hmIdentite.put("cbSexe", cbSexe);
490
		hmIdentite.put("cbSexe", cbSexe);
487
	
491
	
488
		mediateur.obtenirListeValeurEtRafraichir(this, "sexe", sequenceur);			
492
		mediateur.obtenirListeValeurEtRafraichir(this, "sexe", sequenceur);			
489
		
493
		
490
		//Description
494
		//Description
491
		TextArea taDescription = new TextArea();
495
		final TextArea taDescription = new TextArea();
492
		taDescription.setEmptyText("Saisissez une description");
496
		taDescription.setEmptyText("Saisissez une description");
493
		taDescription.setFieldLabel("Description");
497
		taDescription.setFieldLabel("Description");
494
		taDescription.setWidth("100%");
-
 
495
		taDescription.setName("description");
498
		taDescription.setName("description");
496
		
499
		
497
		lcAutreInformations1.add(taDescription, new FormData(500, 200));
500
		lcAutreInformations1.add(taDescription, new FormData(300, 200));
498
		hmIdentite.put("taDescription", taDescription);
501
		hmIdentite.put("taDescription", taDescription);
499
		
502
		
500
		fsAutresInfos.add(lcAutreInformations1);
503
		fsAutresInfos.add(lcAutreInformations1);
501
		
504
				
502
		// Logo
505
		// Logo
503
		LayoutContainer lcLogoUrl = new LayoutContainer();
506
		LayoutContainer lcLogoUrl = new LayoutContainer();
504
		hmIdentite.put("lcLogoUrl", lcLogoUrl);
507
		hmIdentite.put("lcLogoUrl", lcLogoUrl);
505
		
508
		
506
		ChampMultiValeursImage logo = new ChampMultiValeursImage(i18nC.personneLogos());
509
		final ChampMultiValeursImage logo = new ChampMultiValeursImage(i18nC.personneLogos());
507
		logo.setImageHeight("150px");
510
		logo.setImageHeight("150px");
508
		logo.setValeurParDefaut("http://");
511
		logo.setValeurParDefaut("http://");
509
		logo.setValidation(Pattern.url, "http://www.monsite.com/mon_image.jpg");
512
		logo.setValidation(Pattern.url, "http://www.monsite.com/mon_image.jpg");
510
		logo.setValeurBoutonSupprimer("Supprimer");
513
		logo.setValeurBoutonSupprimer("Supprimer");
-
 
514
		logo.setWidth("95%");
511
		hmIdentite.put("logos", logo);
515
		hmIdentite.put("logos", logo);
512
		
516
		
513
		lcLogoUrl.add(logo);
517
		lcLogoUrl.add(logo);
514
		
518
		
515
		fsAutresInfos.add(logo);
519
		fsAutresInfos.add(logo);
516
		
520
		
517
		LayoutContainer lcAutreInformations2 = new LayoutContainer(new ColumnLayout());
521
		LayoutContainer lcAutreInformations2 = new LayoutContainer(new ColumnLayout());
518
		hmIdentite.put("lcAutreInformations2", lcAutreInformations2);
522
		hmIdentite.put("lcAutreInformations2", lcAutreInformations2);
519
		fsAutresInfos.add(lcAutreInformations2);
523
		fsAutresInfos.add(lcAutreInformations2);
520
			
524
			
521
		right.add(fsAutresInfos);
525
		right.add(fsAutresInfos);
522
		
526
		
523
		//+------------------------------------------------------------------------------------------------------------+
527
		//+------------------------------------------------------------------------------------------------------------+
524
		// Ajout des évènements saisi
528
		// Ajout des évènements saisi
525
		KeyListener klNoms = new KeyListener()	{
529
		KeyListener klNoms = new KeyListener()	{
526
			public void componentKeyUp(ComponentEvent ev)	{
530
			public void componentKeyUp(ComponentEvent ev)	{
527
				rafraichir(null);	
531
				rafraichir(null);	
528
			}				
532
			}				
529
		};
533
		};
530
		
534
		
531
		SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
535
		SelectionChangedListener<Valeur> selectionChange = new SelectionChangedListener<Valeur>() {
532
			public void selectionChanged(SelectionChangedEvent se) {
536
			public void selectionChanged(SelectionChangedEvent se) {
533
				rafraichir(null);
537
				rafraichir(null);
534
			}
538
			}
535
		};
539
		};
536
						
540
						
537
		cbPrefixe.addSelectionChangedListener(selectionChange);
541
		cbPrefixe.addSelectionChangedListener(selectionChange);
538
		cbPrefixe.addKeyListener(klNoms);
542
		cbPrefixe.addKeyListener(klNoms);
539
		tfPrenom.addKeyListener(klNoms);
543
		tfPrenom.addKeyListener(klNoms);
540
		tfNom.addKeyListener(klNoms);
544
		tfNom.addKeyListener(klNoms);
541
		cbSuffixe.addSelectionChangedListener(selectionChange);		
545
		cbSuffixe.addSelectionChangedListener(selectionChange);		
542
			
546
			
543
	}
547
	}
544
	
548
	
545
	public void creerComposantsAdresse()	{
549
	public void creerComposantsAdresse()	{
546
		// Gauche
550
		// Gauche
547
		LayoutContainer left = new LayoutContainer();
551
		LayoutContainer left = new LayoutContainer();
548
		left.setLayout(new FormLayout());
552
		left.setLayout(new FormLayout());
549
		left.setStyleAttribute("padding", "15px");
553
		left.setStyleAttribute("padding", "15px");
550
		// Droite
554
		// Droite
551
		LayoutContainer right = new LayoutContainer();
555
		LayoutContainer right = new LayoutContainer();
552
		right.setLayout(new FormLayout());
556
		right.setLayout(new FormLayout());
553
		
557
		
554
		// Principal
558
		// Principal
555
		LayoutContainer main = new LayoutContainer();
559
		LayoutContainer main = new LayoutContainer();
556
		main.setLayout(new TableLayout(2));
560
		main.setLayout(new TableLayout(2));
557
		
561
		
558
		// Ajout au principal
562
		// Ajout au principal
559
		main.add(left);
563
		main.add(left);
560
		main.add(right);	
564
		main.add(right);	
561
		
565
		
562
		TextField<String> tfAdresse1 = new TextField();
566
		TextField<String> tfAdresse1 = new TextField();
563
		tfAdresse1.setFieldLabel("Adresse");
567
		tfAdresse1.setFieldLabel("Adresse");
564
		tfAdresse1.setName("adresse_01");
568
		tfAdresse1.setName("adresse_01");
565
		left.add(tfAdresse1, fd100);
569
		left.add(tfAdresse1, fd100);
566
		hmAdresse.put("tfAdresse1", tfAdresse1);
570
		hmAdresse.put("tfAdresse1", tfAdresse1);
567
		
571
		
568
		ComboBox<Valeur> cbPays = new ComboBox<Valeur>();
572
		ComboBox<Valeur> cbPays = new ComboBox<Valeur>();
569
		cbPays.setFieldLabel("Pays");
573
		cbPays.setFieldLabel("Pays");
570
		cbPays.setDisplayField("nom");
574
		cbPays.setDisplayField("nom");
571
		cbPays.setEmptyText("Sélectionnez le pays:");
575
		cbPays.setEmptyText("Sélectionnez le pays:");
572
		
576
		
573
		ListStore<Valeur> storePays = new ListStore<Valeur>();
577
		ListStore<Valeur> storePays = new ListStore<Valeur>();
574
		cbPays.setStore(storePays);
578
		cbPays.setStore(storePays);
575
		
579
		
576
		right.add(cbPays, fd100);
580
		right.add(cbPays, fd100);
577
		hmAdresse.put("cbPays", cbPays);
581
		hmAdresse.put("cbPays", cbPays);
578
		
582
		
579
		TextField<String> tfBoitePostale = new TextField<String>();
583
		TextField<String> tfBoitePostale = new TextField<String>();
580
		tfBoitePostale.setFieldLabel("Boite postale");
584
		tfBoitePostale.setFieldLabel("Boite postale");
581
		tfBoitePostale.setName("bp");
585
		tfBoitePostale.setName("bp");
582
		
586
		
583
		left.add(tfBoitePostale, fd100);
587
		left.add(tfBoitePostale, fd100);
584
		hmAdresse.put("tfBoitePostale", tfBoitePostale);
588
		hmAdresse.put("tfBoitePostale", tfBoitePostale);
585
		
589
		
586
		TextField<Integer> tfCodePostal = new TextField<Integer>();
590
		TextField<Integer> tfCodePostal = new TextField<Integer>();
587
		tfCodePostal.setFieldLabel("Code postal");
591
		tfCodePostal.setFieldLabel("Code postal");
588
		tfCodePostal.setName("code_postal");
592
		tfCodePostal.setName("code_postal");
589
		
593
		
590
		right.add(tfCodePostal, fd100);
594
		right.add(tfCodePostal, fd100);
591
		hmAdresse.put("tfCodePostal", tfCodePostal);
595
		hmAdresse.put("tfCodePostal", tfCodePostal);
592
		
596
		
593
		TextField tfVille = new TextField();
597
		TextField tfVille = new TextField();
594
		tfVille.setFieldLabel("Ville");
598
		tfVille.setFieldLabel("Ville");
595
		tfVille.setName("ville");
599
		tfVille.setName("ville");
596
		
600
		
597
		right.add(tfVille, fd100);
601
		right.add(tfVille, fd100);
598
		hmAdresse.put("tfVille", tfVille);
602
		hmAdresse.put("tfVille", tfVille);
599
		
603
		
600
		// MAJ ComboBox
604
		// MAJ ComboBox
601
		mediateur.obtenirListeValeurEtRafraichir(this, "pays", sequenceur);
605
		mediateur.obtenirListeValeurEtRafraichir(this, "pays", sequenceur);
602
		
606
		
603
		FieldSet fsAdresse = new FieldSet();
607
		FieldSet fsAdresse = new FieldSet();
604
		fsAdresse.setHeadingHtml("Adresse personnelle");
608
		fsAdresse.setHeadingHtml("Adresse personnelle");
605
		fsAdresse.add(main);
609
		fsAdresse.add(main);
606
		
610
		
607
		tiAdresses.add(fsAdresse);
611
		tiAdresses.add(fsAdresse);
608
	}
612
	}
609
	
613
	
610
	public void creerComposantsInfosNat()	{
614
	public void creerComposantsInfosNat()	{
611
		
615
		
612
		FormLayout fl = new FormLayout();
616
		FormLayout fl = new FormLayout();
613
		fl.setLabelAlign(LabelAlign.TOP);
617
		fl.setLabelAlign(LabelAlign.TOP);
614
		FieldSet fsInfosNat = new FieldSet();
618
		FieldSet fsInfosNat = new FieldSet();
615
		fsInfosNat.setLayout(fl);
619
		fsInfosNat.setLayout(fl);
616
		fsInfosNat.setTitle("Informations Naturaliste");
620
		fsInfosNat.setTitle("Informations Naturaliste");
617
 
621
 
618
		TextArea taBiographie = new TextArea();
622
		TextArea taBiographie = new TextArea();
619
		taBiographie.setFieldLabel("Vie et renommée de l'auteur");
623
		taBiographie.setFieldLabel("Vie et renommée de l'auteur");
620
		taBiographie.setWidth("400");
624
		taBiographie.setWidth("400");
621
		taBiographie.setName("biographie");
625
		taBiographie.setName("biographie");
622
		fsInfosNat.add(taBiographie, new FormData(800, 200));
626
		fsInfosNat.add(taBiographie, new FormData(800, 200));
623
 
627
 
624
		ChampMultiValeurs specialite = new ChampMultiValeurs(i18nC.personneSpecialite());
628
		ChampMultiValeurs specialite = new ChampMultiValeurs(i18nC.personneSpecialite());
625
		fsInfosNat.add(specialite);
629
		fsInfosNat.add(specialite);
626
		hmInfosNat.put("specialite", specialite);
630
		hmInfosNat.put("specialite", specialite);
627
 
631
 
628
		ModelType typeTypes = new ModelType();
632
		ModelType typeTypes = new ModelType();
629
		typeTypes.setRoot("valeurs");
633
		typeTypes.setRoot("valeurs");
630
		typeTypes.setTotalName("nbElements");
634
		typeTypes.setTotalName("nbElements");
631
		typeTypes.addField("cmlv_nom");
635
		typeTypes.addField("cmlv_nom");
632
		typeTypes.addField("cmlv_id_valeur");
636
		typeTypes.addField("cmlv_id_valeur");
633
		typeTypes.addField("cmlv_abreviation");
637
		typeTypes.addField("cmlv_abreviation");
634
		typeTypes.addField("cmlv_description");
638
		typeTypes.addField("cmlv_description");
635
		
639
		
636
		String displayNameTypes = "cmlv_nom";
640
		String displayNameTypes = "cmlv_nom";
637
		String nomListeTypes = "pays";
641
		String nomListeTypes = "pays";
638
		ProxyValeur<ModelData> proxyTypes = new ProxyValeur<ModelData>(nomListeTypes, null);
642
		ProxyValeur<ModelData> proxyTypes = new ProxyValeur<ModelData>(nomListeTypes, null);
639
		
643
		
640
		ChampMultiValeursMultiTypesPaginable recolte = new ChampMultiValeursMultiTypesPaginable(i18nC.personneRecolte(), 450, false, null, null, null, typeTypes, proxyTypes, displayNameTypes);
644
		ChampMultiValeursMultiTypesPaginable recolte = new ChampMultiValeursMultiTypesPaginable(i18nC.personneRecolte(), 450, false, null, null, null, typeTypes, proxyTypes, displayNameTypes);
641
		
645
		
642
		hmInfosNat.put("recolte", recolte);
646
		hmInfosNat.put("recolte", recolte);
643
		fsInfosNat.add(recolte);
647
		fsInfosNat.add(recolte);
644
		tiInfosNat.add(fsInfosNat);
648
		tiInfosNat.add(fsInfosNat);
645
	}
649
	}
646
	
650
	
647
	public void creerComposantsPubli(){
651
	public void creerComposantsPubli(){
648
		//Création des composants de l'onglet publication
652
		//Création des composants de l'onglet publication
649
 
653
 
650
		ContentPanel cp = new ContentPanel();
654
		ContentPanel cp = new ContentPanel();
651
		cp.setHeadingHtml("Publications dont la personne est le sujet");
655
		cp.setHeadingHtml("Publications dont la personne est le sujet");
652
		cp.setIcon(Images.ICONES.table());
656
		cp.setIcon(Images.ICONES.table());
653
		cp.setLayout(new FitLayout());
657
		cp.setLayout(new FitLayout());
654
		cp.setFrame(true);
658
		cp.setFrame(true);
655
		
659
		
656
		ToolBar toolBar = new ToolBar();
660
		ToolBar toolBar = new ToolBar();
657
 
661
 
658
		Button ajouterPubli = new Button("Ajouter");
662
		Button ajouterPubli = new Button("Ajouter");
659
		ajouterPubli.setIcon(Images.ICONES.vcardAjouter());
663
		ajouterPubli.setIcon(Images.ICONES.vcardAjouter());
660
		ajouterPubli.addSelectionListener(new SelectionListener<ButtonEvent>() {  
664
		ajouterPubli.addSelectionListener(new SelectionListener<ButtonEvent>() {  
661
			@Override  
665
			@Override  
662
			public void componentSelected(ButtonEvent ce) {  
666
			public void componentSelected(ButtonEvent ce) {  
663
				/*StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
667
				/*StructureAPersonne membreDuPersonnel = new StructureAPersonne("", StructureAPersonne.ROLE_EQUIPE, StructureAPersonne.ETAT_AJOUTE);
664
				ajouterMembreAGrillePersonnel(membreDuPersonnel);*/
668
				ajouterMembreAGrillePersonnel(membreDuPersonnel);*/
665
			}  
669
			}  
666
		});
670
		});
667
		toolBar.add(ajouterPubli);
671
		toolBar.add(ajouterPubli);
668
		
672
		
669
		toolBar.add(new SeparatorToolItem());
673
		toolBar.add(new SeparatorToolItem());
670
		
674
		
671
		Button supprimerPubli = new Button("Supprimer");
675
		Button supprimerPubli = new Button("Supprimer");
672
		supprimerPubli.setIcon(Images.ICONES.vcardSupprimer());
676
		supprimerPubli.setIcon(Images.ICONES.vcardSupprimer());
673
		supprimerPubli.addSelectionListener(new SelectionListener<ButtonEvent>() {  
677
		supprimerPubli.addSelectionListener(new SelectionListener<ButtonEvent>() {  
674
			@Override
678
			@Override
675
			public void componentSelected(ButtonEvent ce) {
679
			public void componentSelected(ButtonEvent ce) {
676
				/*StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
680
				/*StructureAPersonne personne = grillePersonnel.getSelectionModel().getSelectedItem();
677
				if (personne != null) {
681
				if (personne != null) {
678
					// Ajout de la personne supprimée à la liste
682
					// Ajout de la personne supprimée à la liste
679
					if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {
683
					if (personne.getIdPersonne() != null && !personne.getIdPersonne().equals("")) {
680
						personnelSupprime.put(personne.getId(), personne);
684
						personnelSupprime.put(personne.getId(), personne);
681
					}
685
					}
682
	
686
	
683
					// Suppression de l'enregistrement de la grille
687
					// Suppression de l'enregistrement de la grille
684
					grillePersonnel.getStore().remove(personne);
688
					grillePersonnel.getStore().remove(personne);
685
					
689
					
686
					// Désactivation du bouton supprimer si la grille contient plus d'élément
690
					// Désactivation du bouton supprimer si la grille contient plus d'élément
687
					if (grillePersonnel.getStore().getCount() == 0) {  
691
					if (grillePersonnel.getStore().getCount() == 0) {  
688
						//TODO : check : Item -> component
692
						//TODO : check : Item -> component
689
						ce.getComponent().disable();  
693
						ce.getComponent().disable();  
690
					}
694
					}
691
				}*/
695
				}*/
692
				Window.alert("supprimer");
696
				Window.alert("supprimer");
693
			}   
697
			}   
694
		});
698
		});
695
		toolBar.add(supprimerPubli);
699
		toolBar.add(supprimerPubli);
696
		
700
		
697
		toolBar.add(new SeparatorToolItem());
701
		toolBar.add(new SeparatorToolItem());
698
		
702
		
699
		Button rafraichirPersonnelBtn = new Button("Rafraichir");
703
		Button rafraichirPersonnelBtn = new Button("Rafraichir");
700
		rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir());
704
		rafraichirPersonnelBtn.setIcon(Images.ICONES.rafraichir());
701
		rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {  
705
		rafraichirPersonnelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {  
702
			@Override
706
			@Override
703
			public void componentSelected(ButtonEvent ce) {
707
			public void componentSelected(ButtonEvent ce) {
704
				//rafraichirPersonnel();
708
				//rafraichirPersonnel();
705
				Window.alert("rafraichir");
709
				Window.alert("rafraichir");
706
			}   
710
			}   
707
		});
711
		});
708
		toolBar.add(rafraichirPersonnelBtn);
712
		toolBar.add(rafraichirPersonnelBtn);
709
		
713
		
710
		//Ajout d'une ComboBox
714
		//Ajout d'une ComboBox
711
		storePubli = new ListStore<Publication>();
715
		storePubli = new ListStore<Publication>();
712
		storePubli.add(new ArrayList<Publication>());
716
		storePubli.add(new ArrayList<Publication>());
713
		
717
		
714
		cbPubli = new ComboBox<Publication>();
718
		cbPubli = new ComboBox<Publication>();
715
		cbPubli.setWidth(200);
719
		cbPubli.setWidth(200);
716
		cbPubli.setEmptyText("Chercher une publication existante...");
720
		cbPubli.setEmptyText("Chercher une publication existante...");
717
		cbPubli.setTriggerAction(TriggerAction.ALL);  
721
		cbPubli.setTriggerAction(TriggerAction.ALL);  
718
		cbPubli.setEditable(true);
722
		cbPubli.setEditable(true);
719
		cbPubli.setDisplayField("fmt_nom_complet");
723
		cbPubli.setDisplayField("fmt_nom_complet");
720
		cbPubli.setStore(storePubli);
724
		cbPubli.setStore(storePubli);
721
		cbPubli.addKeyListener(new KeyListener() {
725
		cbPubli.addKeyListener(new KeyListener() {
722
			
726
			
723
			public void componentKeyUp(ComponentEvent ce) {
727
			public void componentKeyUp(ComponentEvent ce) {
724
				if (!ce.isNavKeyPress() && cbPubli.getRawValue() != null && cbPubli.getRawValue().length() > 0) {
728
				if (!ce.isNavKeyPress() && cbPubli.getRawValue() != null && cbPubli.getRawValue().length() > 0) {
725
					rafraichirPublicationsExistante(cbPubli.getRawValue());
729
					rafraichirPublicationsExistante(cbPubli.getRawValue());
726
				}
730
				}
727
			}
731
			}
728
			
732
			
729
		});
733
		});
730
		
734
		
731
		toolBar.add(cbPubli);
735
		toolBar.add(cbPubli);
732
		toolBar.add(new SeparatorToolItem());
736
		toolBar.add(new SeparatorToolItem());
733
		cp.setTopComponent(toolBar);  
737
		cp.setTopComponent(toolBar);  
734
		
738
		
735
		
739
		
736
		tiPubli.add(cp);
740
		tiPubli.add(cp);
737
	}
741
	}
738
 
742
 
739
	public void rafraichirPublicationsExistante(String nomPubli)	{		
743
	public void rafraichirPublicationsExistante(String nomPubli)	{		
740
		nomPubli +="%";
744
		nomPubli +="%";
741
		mediateur.selectionnerPublicationParNomComplet(this, nomPubli);
745
		mediateur.selectionnerPublicationParNomComplet(this, nomPubli);
742
	}
746
	}
743
	
747
	
744
	/**
748
	/**
745
	 * Ajouter le bouton annuler à la barre d'outils donnée
749
	 * Ajouter le bouton annuler à la barre d'outils donnée
746
	 * 
750
	 * 
747
	 * @param barreOutils la barre d'outils à modifier
751
	 * @param barreOutils la barre d'outils à modifier
748
	 * */
752
	 * */
749
	public static void ajouterBoutonAnnuler(ButtonBar barreOutils)	{
753
	public static void ajouterBoutonAnnuler(ButtonBar barreOutils)	{
750
		
754
		
751
		// Le bouton annuler ne sauvegarde pas les informations et renvoie vers la page précédente
755
		// Le bouton annuler ne sauvegarde pas les informations et renvoie vers la page précédente
752
		Button annuler = new Button("Revenir à la liste");
756
		Button annuler = new Button("Revenir à la liste");
753
		annuler.addSelectionListener(new SelectionListener<ButtonEvent>() {  
757
		annuler.addSelectionListener(new SelectionListener<ButtonEvent>() {  
754
			public void componentSelected(ButtonEvent ce) {  
758
			public void componentSelected(ButtonEvent ce) {  
755
				((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
759
				((Mediateur) Registry.get(RegistreId.MEDIATEUR)).clicMenu("Personnes");
756
			}  
760
			}  
757
		});
761
		});
758
		annuler.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
762
		annuler.setIconStyle(ComposantClass.ICONE_SUPPRIMER);
759
		barreOutils.add(annuler);
763
		barreOutils.add(annuler);
760
	}
764
	}
761
	
765
	
762
	// RAFRAICHISSEMENT DU PANNEAU
766
	// RAFRAICHISSEMENT DU PANNEAU
763
 
767
 
764
	public void rafraichir(Object nouvellesDonnees) {
768
	public void rafraichir(Object nouvellesDonnees) {
765
		
769
		
766
		if (nouvellesDonnees instanceof PublicationAPersonneListe)	{					
770
		if (nouvellesDonnees instanceof PublicationAPersonneListe)	{					
767
			Information info = new Information();
771
			Information info = new Information();
768
			info.setType("publication_liees");
772
			info.setType("publication_liees");
769
			info.setDonnee(0, (PublicationAPersonneListe) nouvellesDonnees);
773
			info.setDonnee(0, (PublicationAPersonneListe) nouvellesDonnees);
770
			tiPubli.rafraichir(info);
774
			tiPubli.rafraichir(info);
771
			
775
			
772
		} else if (nouvellesDonnees instanceof ValeurListe) {
776
		} else if (nouvellesDonnees instanceof ValeurListe) {
773
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
777
			ValeurListe listeValeurs = (ValeurListe) nouvellesDonnees;
774
			// Créer une liste de valeurs
778
			// Créer une liste de valeurs
775
			List<Valeur> liste = new ArrayList<Valeur>();
779
			List<Valeur> liste = new ArrayList<Valeur>();
776
			for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
780
			for (Iterator<String> it = listeValeurs.keySet().iterator(); it.hasNext();) {
777
				liste.add(listeValeurs.get(it.next()));
781
				liste.add(listeValeurs.get(it.next()));
778
			}
782
			}
779
			if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication")))	{
783
			if (listeValeurs.getId().equals(config.getListeId("relationPersonnePublication")))	{
780
				tiPubli.rafraichir(nouvellesDonnees);				
784
				tiPubli.rafraichir(nouvellesDonnees);				
781
			} else if (listeValeurs.getId().equals(config.getListeId("prefixe")))	{
785
			} else if (listeValeurs.getId().equals(config.getListeId("prefixe")))	{
782
				remplirCombobox("cbPrefixe", liste, "hmIdentite");
786
				remplirCombobox("cbPrefixe", liste, "hmIdentite");
783
			} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) {
787
			} else if (listeValeurs.getId().equals(config.getListeId("suffixes"))) {
784
				remplirCombobox("cbSuffixe", liste, "hmIdentite");
788
				remplirCombobox("cbSuffixe", liste, "hmIdentite");
785
			} else if (listeValeurs.getId().equals(config.getListeId("sexe"))) {
789
			} else if (listeValeurs.getId().equals(config.getListeId("sexe"))) {
786
				
790
				
787
				//Ajout de la valeur "Inconnu"
791
				//Ajout de la valeur "Inconnu"
788
				ComboBox<Valeur> cbSexe = hmAdresse.getComboBoxValeur("cbSexe");
792
				ComboBox<Valeur> cbSexe = hmAdresse.getComboBoxValeur("cbSexe");
789
				Valeur inconnu = new Valeur();
793
				Valeur inconnu = new Valeur();
790
				inconnu.set("nom", "Inconnu");
794
				inconnu.set("nom", "Inconnu");
791
				inconnu.set("id", "0");
795
				inconnu.set("id", "0");
792
				liste.add(0, inconnu);
796
				liste.add(0, inconnu);
793
				
797
				
794
				remplirCombobox("cbSexe", liste, "hmIdentite");
798
				remplirCombobox("cbSexe", liste, "hmIdentite");
795
				
799
				
796
				/*List<Valeur> selection = new LinkedList<Valeur>();
800
				/*List<Valeur> selection = new LinkedList<Valeur>();
797
				selection.add(inconnu);
801
				selection.add(inconnu);
798
				cbSexe.setSelection(s);*/
802
				cbSexe.setSelection(s);*/
799
				
803
				
800
				
804
				
801
			} else if (listeValeurs.getId().equals(config.getListeId("tel"))) {
805
			} else if (listeValeurs.getId().equals(config.getListeId("tel"))) {
802
				remplirCombobox("cbTelephone", liste, "hmIdentite");
806
				remplirCombobox("cbTelephone", liste, "hmIdentite");
803
 
807
 
804
				//Préselection du tél
808
				//Préselection du tél
805
				ComboBox<Valeur> cbTelephone = hmIdentite.getComboBoxValeur("cbTelephone");
809
				ComboBox<Valeur> cbTelephone = hmIdentite.getComboBoxValeur("cbTelephone");
806
				cbTelephone.setValue(liste.get(1));
810
				cbTelephone.setValue(liste.get(1));
807
			} else if (listeValeurs.getId().equals(config.getListeId("pays")))	{
811
			} else if (listeValeurs.getId().equals(config.getListeId("pays")))	{
808
				remplirCombobox("cbPays", liste, "hmAdresse");
812
				remplirCombobox("cbPays", liste, "hmAdresse");
809
			}
813
			}
810
		} else if (nouvellesDonnees instanceof PublicationListe)	{
814
		} else if (nouvellesDonnees instanceof PublicationListe)	{
811
			PublicationListe publicationListe = (PublicationListe) nouvellesDonnees;
815
			PublicationListe publicationListe = (PublicationListe) nouvellesDonnees;
812
			List<Publication> liste = publicationListe.toList();
816
			List<Publication> liste = publicationListe.toList();
813
			storePubli.removeAll();
817
			storePubli.removeAll();
814
			storePubli.add(liste);
818
			storePubli.add(liste);
815
			cbPubli.setStore(storePubli);
819
			cbPubli.setStore(storePubli);
816
		} else if (nouvellesDonnees instanceof Information)	{			
820
		} else if (nouvellesDonnees instanceof Information)	{			
817
			Information info = (Information) nouvellesDonnees;
821
			Information info = (Information) nouvellesDonnees;
818
			if (info.getType().equals("ajout_personne"))	{
822
			if (info.getType().equals("ajout_personne"))	{
819
				if (info.getDonnee(0) != null) {
823
				if (info.getDonnee(0) != null) {
820
					personneSelectionnee.setId(info.getDonnee(0).toString());
824
					personneSelectionnee.setId(info.getDonnee(0).toString());
821
					GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null);
825
					GWT.log("Ajout de la personne " + personneSelectionnee.getId(), null);
822
					this.personne = personneSelectionnee;
826
					this.personne = personneSelectionnee;
823
					this.personneId = personneSelectionnee.getId();
827
					this.personneId = personneSelectionnee.getId();
824
					InfoLogger.display("Enregistrement", "La personne a été ajoutée (id: " + personneSelectionnee.getId() + ")");
828
					InfoLogger.display("Enregistrement", "La personne a été ajoutée (id: " + personneSelectionnee.getId() + ")");
825
					repandreRafraichissement();
829
					repandreRafraichissement();
826
					if (clicBoutonvalidation)	{
830
					if (clicBoutonvalidation)	{
827
						mediateur.clicMenu(menuIdCourant);
831
						mediateur.clicMenu(menuIdCourant);
828
					} else {
832
					} else {
829
						this.mode = MODE_MODIFIER;
833
						this.mode = MODE_MODIFIER;
830
					}
834
					}
831
				} else {
835
				} else {
832
					InfoLogger.display("Enregistrement", info.getMessages().toString());
836
					InfoLogger.display("Enregistrement", info.getMessages().toString());
833
				}
837
				}
834
			} else if (info.getType().equals("modification_personne"))	{
838
			} else if (info.getType().equals("modification_personne"))	{
835
				InfoLogger.display("Enregistrement", "Les modifications apportées à la personne " + personneSelectionnee.getId() + " ont été correctement enregistrées.");
839
				InfoLogger.display("Enregistrement", "Les modifications apportées à la personne " + personneSelectionnee.getId() + " ont été correctement enregistrées.");
836
				repandreRafraichissement();
840
				repandreRafraichissement();
837
				controlerFermeture();
841
				controlerFermeture();
838
			} else if (info.getType().equals("maj_utilisateur"))	{
842
			} else if (info.getType().equals("maj_utilisateur"))	{
839
				gererEtatActivationBouton();
843
				gererEtatActivationBouton();
840
			} else if (info.getDonnee(0) instanceof PersonneListe)	{
844
			} else if (info.getDonnee(0) instanceof PersonneListe)	{
841
				
845
				
842
				Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values();
846
				Collection colPersonneListe = ((PersonneListe) info.getDonnee(0)).values();
843
				Iterator itPersonneListe = colPersonneListe.iterator();
847
				Iterator itPersonneListe = colPersonneListe.iterator();
844
				Personne personne = (Personne) itPersonneListe.next();
848
				Personne personne = (Personne) itPersonneListe.next();
845
				
849
				
846
				//TODO : Je vois pas l'intérêt des lignes ci dessous..
850
				//TODO : Je vois pas l'intérêt des lignes ci dessous..
847
				personneSauvegarde = new Personne();
851
				personneSauvegarde = new Personne();
848
				personneSauvegarde = (Personne) personne.cloner(personneSauvegarde);
852
				personneSauvegarde = (Personne) personne.cloner(personneSauvegarde);
849
				
853
				
850
				binderPersonne(personne);
854
				binderPersonne(personne);
851
				
855
				
852
				mettreAJourPersonne(personne);
856
				mettreAJourPersonne(personne);
853
				
857
				
854
				this.personne = personne;
858
				this.personne = personne;
855
				this.personneId = personne.getId();
859
				this.personneId = personne.getId();
856
				
860
				
857
				tiPubli.rafraichirInformation(new Information("personne"));
861
				tiPubli.rafraichirInformation(new Information("personne"));
858
				
862
				
859
				nouvellesDonnees = null;
863
				nouvellesDonnees = null;
860
			} else {
864
			} else {
861
				InfoLogger.display("messages", info.getMessages().toString());
865
				InfoLogger.display("messages", info.getMessages().toString());
862
			}
866
			}
863
		}
867
		}
864
		
868
		
865
		if (nouvellesDonnees == null) {			
869
		if (nouvellesDonnees == null) {			
866
			ComboBox<Valeur> cb= hmIdentite.getComboBoxValeur("cbPrefixe");
870
			ComboBox<Valeur> cb= hmIdentite.getComboBoxValeur("cbPrefixe");
867
			
871
			
868
			//Met à jour le nom Complet du formulaire
872
			//Met à jour le nom Complet du formulaire
869
			String valeurRetour = "";
873
			String valeurRetour = "";
870
			
874
			
871
			// Prefixe
875
			// Prefixe
872
			String prefixe = "";
876
			String prefixe = "";
873
			Valeur valPrefixe = cb.getValue();
877
			Valeur valPrefixe = cb.getValue();
874
			
878
			
875
			if (valPrefixe != null)	{
879
			if (valPrefixe != null)	{
876
				prefixe = valPrefixe.getNom();
880
				prefixe = valPrefixe.getNom();
877
			} else 	{
881
			} else 	{
878
				prefixe =  (String) cb.getRawValue();
882
				prefixe =  (String) cb.getRawValue();
879
			}		
883
			}		
880
			
884
			
881
			// Prénom
885
			// Prénom
882
			String prenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
886
			String prenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
883
			
887
			
884
			// Nom
888
			// Nom
885
			String nom = (String) hmIdentite.getTextField("tfNom").getValue();
889
			String nom = (String) hmIdentite.getTextField("tfNom").getValue();
886
			
890
			
887
			// Suffixe
891
			// Suffixe
888
			ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe");
892
			ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe");
889
			
893
			
890
			String suffixe = "";
894
			String suffixe = "";
891
			Valeur valSuffixe = cbSuffixe.getValue();
895
			Valeur valSuffixe = cbSuffixe.getValue();
892
			
896
			
893
			if (valSuffixe != null)	{
897
			if (valSuffixe != null)	{
894
				suffixe = valSuffixe.getNom();
898
				suffixe = valSuffixe.getNom();
895
			} else 	{
899
			} else 	{
896
				suffixe =  (String) cbSuffixe.getRawValue();
900
				suffixe =  (String) cbSuffixe.getRawValue();
897
			}
901
			}
898
			
902
			
899
			// Mettre à jour la valeur
903
			// Mettre à jour la valeur
900
			valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
904
			valeurRetour = prefixe + " " + prenom + " " + nom + " " + suffixe;
901
			valeurRetour = valeurRetour.replaceAll("null", "");
905
			valeurRetour = valeurRetour.replaceAll("null", "");
902
			
906
			
903
			hmIdentite.getLabelField("nomComplet").setValue(valeurRetour);
907
			hmIdentite.getLabelField("nomComplet").setValue(valeurRetour);
904
			
908
			
905
			if (!valeurRetour.trim().equals(""))	{
909
			if (!valeurRetour.trim().equals(""))	{
906
				hmIdentite.getLabelField("nomComplet").show();
910
				hmIdentite.getLabelField("nomComplet").show();
907
			} else {
911
			} else {
908
				hmIdentite.getLabelField("nomComplet").hide();
912
				hmIdentite.getLabelField("nomComplet").hide();
909
			}
913
			}
910
		}
914
		}
911
		
915
		
912
		mediateur.masquerPopinChargement();
916
		mediateur.masquerPopinChargement();
913
		
917
		
914
		if (this.mode.equals(MODE_AJOUTER))	{
918
		if (this.mode.equals(MODE_AJOUTER))	{
915
			gererEtatActivationBouton();
919
			gererEtatActivationBouton();
916
		}	
920
		}	
917
	}
921
	}
918
 
922
 
919
	private void repandreRafraichissement() {		
923
	private void repandreRafraichissement() {		
920
		if (vueExterneARafraichirApresValidation != null) {
924
		if (vueExterneARafraichirApresValidation != null) {
921
			String type = "personne_modifiee";
925
			String type = "personne_modifiee";
922
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
926
			if (mode.equals(Formulaire.MODE_AJOUTER)) {
923
				type = "personne_ajoutee";
927
				type = "personne_ajoutee";
924
			}
928
			}
925
			Information info = new Information(type);
929
			Information info = new Information(type);
926
			info.setDonnee(0, personneSelectionnee);
930
			info.setDonnee(0, personneSelectionnee);
927
			vueExterneARafraichirApresValidation.rafraichir(info);
931
			vueExterneARafraichirApresValidation.rafraichir(info);
928
		}
932
		}
929
	}
933
	}
930
	
934
	
931
	private void mettreAJourPersonne(Personne personne)	{
935
	private void mettreAJourPersonne(Personne personne)	{
932
		
936
		
933
		//Mise à jour de la personne
937
		//Mise à jour de la personne
934
		
938
		
935
		//Prefixe
939
		//Prefixe
936
		String prefixe = personne.get("ce_truk_prefix");
940
		String prefixe = personne.get("ce_truk_prefix");
937
		ComboBox<Valeur> cbPrefixe = hmIdentite.getComboBoxValeur("cbPrefixe");
941
		ComboBox<Valeur> cbPrefixe = hmIdentite.getComboBoxValeur("cbPrefixe");
938
		
942
		
939
		
943
		
940
		String prefixeCourant = personne.get("ce_truk_prefix");
944
		String prefixeCourant = personne.get("ce_truk_prefix");
941
		if (cbPrefixe.getStore().findModel("id_valeur", prefixeCourant) != null)	{
945
		if (cbPrefixe.getStore().findModel("id_valeur", prefixeCourant) != null)	{
942
			cbPrefixe.setValue(cbPrefixe.getStore().findModel("id_valeur", prefixeCourant));
946
			cbPrefixe.setValue(cbPrefixe.getStore().findModel("id_valeur", prefixeCourant));
943
		}	else	{
947
		}	else	{
944
			cbPrefixe.setRawValue(prefixeCourant);
948
			cbPrefixe.setRawValue(prefixeCourant);
945
		}
949
		}
946
		
950
		
947
		hmIdentite.getTextField("tfPrenom").setValue(personne.get("prenom"));
951
		hmIdentite.getTextField("tfPrenom").setValue(personne.get("prenom"));
948
		hmIdentite.getTextField("tfNom").setValue(personne.get("nom"));
952
		hmIdentite.getTextField("tfNom").setValue(personne.get("nom"));
949
		
953
		
950
		//Suffixe
954
		//Suffixe
951
		String suffixe = personne.get("ce_truk_suffixe");
955
		String suffixe = personne.get("ce_truk_suffixe");
952
		ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe");
956
		ComboBox<Valeur> cbSuffixe = hmIdentite.getComboBoxValeur("cbSuffixe");
953
		
957
		
954
		String suffixeCourant = personne.get("ce_truk_suffix");
958
		String suffixeCourant = personne.get("ce_truk_suffix");
955
		if (cbSuffixe.getStore().findModel("id_valeur", suffixeCourant) != null)	{
959
		if (cbSuffixe.getStore().findModel("id_valeur", suffixeCourant) != null)	{
956
			cbSuffixe.setValue(cbSuffixe.getStore().findModel("id_valeur", suffixeCourant));
960
			cbSuffixe.setValue(cbSuffixe.getStore().findModel("id_valeur", suffixeCourant));
957
		}	else	{
961
		}	else	{
958
			cbSuffixe.setRawValue(suffixeCourant);
962
			cbSuffixe.setRawValue(suffixeCourant);
959
		}
963
		}
960
		
964
		
961
		hmIdentite.getChampMultiValeurs("nomAutre").peupler(personne.getString("truk_nom_autre"));
965
		hmIdentite.getChampMultiValeurs("nomAutre").peupler(personne.getString("truk_nom_autre"));
962
		hmIdentite.getTextField("tfAbreviation").setValue(personne.get("abreviation"));
966
		hmIdentite.getTextField("tfAbreviation").setValue(personne.get("abreviation"));
963
		hmIdentite.getChampMultiValeurs("abreviationAutre").peupler(personne.getString("truk_abreviation_autre"));
967
		hmIdentite.getChampMultiValeurs("abreviationAutre").peupler(personne.getString("truk_abreviation_autre"));
964
		
968
		
965
		hmIdentite.getTextField("tfDateNaissance").setValue(personne.getAnneeOuDateNaiss());
969
		hmIdentite.getTextField("tfDateNaissance").setValue(personne.getAnneeOuDateNaiss());
966
		hmIdentite.getTextField("tfLieuNaissance").setValue(personne.get("naissance_lieu"));
970
		hmIdentite.getTextField("tfLieuNaissance").setValue(personne.get("naissance_lieu"));
967
		
971
		
968
		
972
		
969
		if (personne.estDecedee())	{
973
		if (personne.estDecedee())	{
970
			hmIdentite.getTextField("tfDateDeces").setValue(personne.getAnneeOuDateDeces());
974
			hmIdentite.getTextField("tfDateDeces").setValue(personne.getAnneeOuDateDeces());
971
			hmIdentite.getTextField("tfLieuDeces").setValue(personne.get("deces_lieu"));
975
			hmIdentite.getTextField("tfLieuDeces").setValue(personne.get("deces_lieu"));
972
			Radio rbEstDecede = hmIdentite.getRadio("rbEstDecedee");
976
			Radio rbEstDecede = hmIdentite.getRadio("rbEstDecedee");
973
			rbEstDecede.setValue(true);
977
			rbEstDecede.setValue(true);
974
		}
978
		}
975
		
979
		
976
		hmIdentite.getChampMultiValeurs("telephones").peupler(personne.getString("truk_telephone"));
980
		hmIdentite.getChampMultiValeurs("telephones").peupler(personne.getString("truk_telephone"));
977
		
981
		
978
		//Courriel
982
		//Courriel
979
		hmIdentite.getChampMultiValeurs("courriels").peupler(personne.getCourriel());
983
		hmIdentite.getChampMultiValeurs("courriels").peupler(personne.getCourriel());
980
		
984
		
981
		//Sites web
985
		//Sites web
982
		hmIdentite.getChampMultiValeurs("sites").peupler(personne.getString("truk_url"));
986
		hmIdentite.getChampMultiValeurs("sites").peupler(personne.getString("truk_url"));
983
		
987
		
984
		// Sexe
988
		// Sexe
985
		String strSexe = personne.get("ce_sexe");
989
		String strSexe = personne.get("ce_sexe");
986
		ComboBox<Valeur> cbSexe = hmIdentite.getComboBoxValeur("cbSexe");
990
		ComboBox<Valeur> cbSexe = hmIdentite.getComboBoxValeur("cbSexe");
987
 
991
 
988
		if (cbSexe.getStore().findModel("id_valeur", strSexe) != null)	{
992
		if (cbSexe.getStore().findModel("id_valeur", strSexe) != null)	{
989
			cbSexe.setValue(cbSexe.getStore().findModel("id_valeur", strSexe));
993
			cbSexe.setValue(cbSexe.getStore().findModel("id_valeur", strSexe));
990
		}
994
		}
991
		
995
		
992
		hmIdentite.getTextArea("taDescription").setRawValue((String) personne.get("description"));
996
		hmIdentite.getTextArea("taDescription").setRawValue((String) personne.get("description"));
993
		
997
		
994
		//Logo
998
		//Logo
995
		hmIdentite.getChampMultiValeurs("logos").peupler(personne.getString("truk_logo"));
999
		hmIdentite.getChampMultiValeurs("logos").peupler(personne.getString("truk_logo"));
996
		
1000
		
997
		/*--------------------------------------------------
1001
		/*--------------------------------------------------
998
		                      Adresse
1002
		                      Adresse
999
		 ---------------------------------------------------*/
1003
		 ---------------------------------------------------*/
1000
		
1004
		
1001
		// Adresse
1005
		// Adresse
1002
		hmAdresse.getTextField("tfAdresse1").setValue((String) personne.get("adresse_01"));
1006
		hmAdresse.getTextField("tfAdresse1").setValue((String) personne.get("adresse_01"));
1003
		
1007
		
1004
		//Boite postale
1008
		//Boite postale
1005
		hmAdresse.getTextField("tfBoitePostale").setValue((String) personne.get("bp"));
1009
		hmAdresse.getTextField("tfBoitePostale").setValue((String) personne.get("bp"));
1006
		
1010
		
1007
		//Pays
1011
		//Pays
1008
		String strPays = personne.get("ce_truk_pays");
1012
		String strPays = personne.get("ce_truk_pays");
1009
		ComboBox<Valeur> cbPays = hmAdresse.getComboBoxValeur("cbPays");
1013
		ComboBox<Valeur> cbPays = hmAdresse.getComboBoxValeur("cbPays");
1010
		cbPays.getStore().sort("nom", SortDir.ASC);
1014
		cbPays.getStore().sort("nom", SortDir.ASC);
1011
		
1015
		
1012
		if (cbPays.getStore().findModel("id_valeur", strPays) != null)	{
1016
		if (cbPays.getStore().findModel("id_valeur", strPays) != null)	{
1013
			cbPays.setValue(cbPays.getStore().findModel("id_valeur", strPays));
1017
			cbPays.setValue(cbPays.getStore().findModel("id_valeur", strPays));
1014
			cbPays.fireEvent(Events.OnChange);
1018
			cbPays.fireEvent(Events.OnChange);
1015
		}	else	{
1019
		}	else	{
1016
			cbPays.setRawValue(strPays);
1020
			cbPays.setRawValue(strPays);
1017
		}
1021
		}
1018
		
1022
		
1019
		//Cp
1023
		//Cp
1020
		hmAdresse.getTextField("tfCodePostal").setValue(personne.get("code_postal"));
1024
		hmAdresse.getTextField("tfCodePostal").setValue(personne.get("code_postal"));
1021
		
1025
		
1022
		//Ville
1026
		//Ville
1023
		hmAdresse.getTextField("tfVille").setValue(personne.get("ville"));
1027
		hmAdresse.getTextField("tfVille").setValue(personne.get("ville"));
1024
		
1028
		
1025
		/*--------------------------------------------------------
1029
		/*--------------------------------------------------------
1026
		 * 					Infos naturalistes
1030
		 * 					Infos naturalistes
1027
		 * -----------------------------------------------------*/
1031
		 * -----------------------------------------------------*/
1028
		
1032
		
1029
		hmInfosNat.getChampMultiValeurs("specialite").peupler(personne.getString("ce_truk_specialite"));
1033
		hmInfosNat.getChampMultiValeurs("specialite").peupler(personne.getString("ce_truk_specialite"));
1030
		String tr = personne.getString("truk_recolte");		
1034
		String tr = personne.getString("truk_recolte");		
1031
		hmInfosNat.getChampMultiValeursMultiTypesPaginable("recolte").peupler(tr);
1035
		hmInfosNat.getChampMultiValeursMultiTypesPaginable("recolte").peupler(tr);
1032
		
1036
		
1033
		//Onglet publi	
1037
		//Onglet publi	
1034
		tiPubli.mettreAJourPersonne();
1038
		tiPubli.mettreAJourPersonne();
1035
		gererEtatActivationBouton();
1039
		gererEtatActivationBouton();
1036
	}
1040
	}
1037
 
1041
 
1038
	public void remplirCombobox(String idComboBox, List liste, String hashMapId)	{
1042
	public void remplirCombobox(String idComboBox, List liste, String hashMapId)	{
1039
		HashMap hm = null;
1043
		HashMap hm = null;
1040
		if (hashMapId.equals("hmIdentite"))	{
1044
		if (hashMapId.equals("hmIdentite"))	{
1041
			hm = hmIdentite;
1045
			hm = hmIdentite;
1042
		} else if (hashMapId.equals("hmAdresse")){
1046
		} else if (hashMapId.equals("hmAdresse")){
1043
			hm = hmAdresse;
1047
			hm = hmAdresse;
1044
		} else {
1048
		} else {
1045
			hm = hmInfosNat;
1049
			hm = hmInfosNat;
1046
		}
1050
		}
1047
		
1051
		
1048
		ListStore<Valeur> store = ((ComboBox) hm.get(idComboBox)).getStore();
1052
		ListStore<Valeur> store = ((ComboBox) hm.get(idComboBox)).getStore();
1049
		
1053
		
1050
		store.removeAll();
1054
		store.removeAll();
1051
		store.add(liste);
1055
		store.add(liste);
1052
		((ComboBox) hm.get(idComboBox)).setStore(store);
1056
		((ComboBox) hm.get(idComboBox)).setStore(store);
1053
	}
1057
	}
1054
	
1058
	
1055
	private void gererEtatActivationBouton()	{
1059
	private void gererEtatActivationBouton()	{
1056
	/*	if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie() == false)	{			
1060
	/*	if (((Utilisateur) Registry.get(RegistreId.UTILISATEUR_COURANT)).isIdentifie() == false)	{			
1057
			enregistrer.setEnabled(false);
1061
			enregistrer.setEnabled(false);
1058
			enregistrerEtRevenir.setEnabled(false);
1062
			enregistrerEtRevenir.setEnabled(false);
1059
		} else	{
1063
		} else	{
1060
			enregistrer.setEnabled(true);
1064
			enregistrer.setEnabled(true);
1061
			enregistrerEtRevenir.setEnabled(true);
1065
			enregistrerEtRevenir.setEnabled(true);
1062
		}*/
1066
		}*/
1063
	}
1067
	}
1064
	
1068
	
1065
	public void binderPersonne(Personne personne)	{
1069
	public void binderPersonne(Personne personne)	{
1066
		binding = new FormBinding(getFormulaire());
1070
		binding = new FormBinding(getFormulaire());
1067
		
1071
		
1068
		personneSelectionnee = personne;
1072
		personneSelectionnee = personne;
1069
		
1073
		
1070
		FieldBinding f = new FieldBinding((RadioGroup) hmIdentite.get("rbgDeces"), null);
1074
		FieldBinding f = new FieldBinding((RadioGroup) hmIdentite.get("rbgDeces"), null);
1071
		binding.autoBind();
1075
		binding.autoBind();
1072
		binding.removeFieldBinding(f);
1076
		binding.removeFieldBinding(f);
1073
		
1077
		
1074
		binding.bind(personneSelectionnee);
1078
		binding.bind(personneSelectionnee);
1075
		layout();
1079
		layout();
1076
	}
1080
	}
1077
 
1081
 
1078
	private String obtenirValeurCombo(String strComboName)	{
1082
	private String obtenirValeurCombo(String strComboName)	{
1079
		String strValeur = "";
1083
		String strValeur = "";
1080
		Valeur valeur;
1084
		Valeur valeur;
1081
		
1085
		
1082
		ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur(strComboName);
1086
		ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur(strComboName);
1083
		if (combo == null)	{
1087
		if (combo == null)	{
1084
			combo = hmAdresse.getComboBoxValeur(strComboName);
1088
			combo = hmAdresse.getComboBoxValeur(strComboName);
1085
		}
1089
		}
1086
		strValeur = combo.getRawValue();
1090
		strValeur = combo.getRawValue();
1087
		valeur = combo.getValue();
1091
		valeur = combo.getValue();
1088
		if (valeur != null)	{
1092
		if (valeur != null)	{
1089
			strValeur = valeur.getId();
1093
			strValeur = valeur.getId();
1090
		}
1094
		}
1091
		
1095
		
1092
		return strValeur;
1096
		return strValeur;
1093
	}
1097
	}
1094
 
1098
 
1095
	public boolean soumettreFormulaire() {
1099
	public boolean soumettreFormulaire() {
1096
		tiPubli.collecter();
1100
		tiPubli.collecter();
1097
		if (verifierFormulaire())	{
1101
		if (verifierFormulaire())	{
1098
			tiPubli.soumettre();
1102
			tiPubli.soumettre();
1099
			mediateur.enregistrerPersonne(this, personneSelectionnee);
1103
			mediateur.enregistrerPersonne(this, personneSelectionnee);
1100
			return true;
1104
			return true;
1101
		}
1105
		}
1102
		else return false;
1106
		else return false;
1103
	}
1107
	}
1104
 
1108
 
1105
	public boolean verifierFormulaire() {
1109
	public boolean verifierFormulaire() {
1106
		boolean success = true;
1110
		boolean success = true;
1107
		LinkedList<String> lstMessageErreur = new LinkedList<String>();
1111
		LinkedList<String> lstMessageErreur = new LinkedList<String>();
1108
		
1112
		
1109
		String strTfNom = (String) hmIdentite.getTextField("tfNom").getValue();
1113
		String strTfNom = (String) hmIdentite.getTextField("tfNom").getValue();
1110
		if ((strTfNom == null)||(strTfNom.trim().equals("")))	{
1114
		if ((strTfNom == null)||(strTfNom.trim().equals("")))	{
1111
			lstMessageErreur.add("Le nom n'a pas été saisi");
1115
			lstMessageErreur.add("Le nom n'a pas été saisi");
1112
		} else {
1116
		} else {
1113
			strTfNom = UtilString.ucFirst(strTfNom);
1117
			strTfNom = UtilString.ucFirst(strTfNom);
1114
			personneSelectionnee.set("nom", strTfNom);
1118
			personneSelectionnee.set("nom", strTfNom);
1115
		}
1119
		}
1116
		
1120
		
1117
		String strTfPrenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
1121
		String strTfPrenom = (String) hmIdentite.getTextField("tfPrenom").getValue();
1118
		personneSelectionnee.set("prenom", UtilString.ucFirst(strTfPrenom));
1122
		personneSelectionnee.set("prenom", UtilString.ucFirst(strTfPrenom));
1119
		
1123
		
1120
		//Préparer les données
1124
		//Préparer les données
1121
		ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur("cbSexe");
1125
		ComboBox<Valeur> combo = hmIdentite.getComboBoxValeur("cbSexe");
1122
		Valeur valeur;
1126
		Valeur valeur;
1123
		String strValeur = "";
1127
		String strValeur = "";
1124
		
1128
		
1125
		valeur = combo.getValue();
1129
		valeur = combo.getValue();
1126
		if (valeur!=null)	{
1130
		if (valeur!=null)	{
1127
			personneSelectionnee.set("ce_sexe", valeur.getId());
1131
			personneSelectionnee.set("ce_sexe", valeur.getId());
1128
		}
1132
		}
1129
		
1133
		
1130
		strValeur = obtenirValeurCombo("cbPrefixe");
1134
		strValeur = obtenirValeurCombo("cbPrefixe");
1131
		personneSelectionnee.set("ce_truk_prefix", strValeur);
1135
		personneSelectionnee.set("ce_truk_prefix", strValeur);
1132
		
1136
		
1133
		strValeur = obtenirValeurCombo("cbSuffixe"); 
1137
		strValeur = obtenirValeurCombo("cbSuffixe"); 
1134
		personneSelectionnee.set("ce_truk_suffix", strValeur);
1138
		personneSelectionnee.set("ce_truk_suffix", strValeur);
1135
		
1139
		
1136
		String nomAutre = hmIdentite.getChampMultiValeurs("nomAutre").getValeurs();
1140
		String nomAutre = hmIdentite.getChampMultiValeurs("nomAutre").getValeurs();
1137
		personneSelectionnee.set("truk_nom_autre", nomAutre);
1141
		personneSelectionnee.set("truk_nom_autre", nomAutre);
1138
		
1142
		
1139
		String abreviationAutre = hmIdentite.getChampMultiValeurs("abreviationAutre").getValeurs();
1143
		String abreviationAutre = hmIdentite.getChampMultiValeurs("abreviationAutre").getValeurs();
1140
		personneSelectionnee.set("truk_abreviation_autre", abreviationAutre);
1144
		personneSelectionnee.set("truk_abreviation_autre", abreviationAutre);
1141
		
1145
		
1142
		personneSelectionnee.set("truk_courriel", hmIdentite.getChampMultiValeurs("courriels").getValeurs());
1146
		personneSelectionnee.set("truk_courriel", hmIdentite.getChampMultiValeurs("courriels").getValeurs());
1143
		
1147
		
1144
		
1148
		
1145
		//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
1149
		//Pour le nom complet, on enregistre dans la bdd la valeur du prefixe/suffixe et non l'id
1146
		String strPrefixe = "";
1150
		String strPrefixe = "";
1147
		combo = hmIdentite.getComboBoxValeur("cbPrefixe");
1151
		combo = hmIdentite.getComboBoxValeur("cbPrefixe");
1148
		valeur = combo.getValue();
1152
		valeur = combo.getValue();
1149
		if (valeur != null)	{
1153
		if (valeur != null)	{
1150
			strPrefixe = valeur.getNom();
1154
			strPrefixe = valeur.getNom();
1151
		} else {
1155
		} else {
1152
			strPrefixe = combo.getRawValue();
1156
			strPrefixe = combo.getRawValue();
1153
		}
1157
		}
1154
		
1158
		
1155
		String strSuffixe = "";
1159
		String strSuffixe = "";
1156
		combo = hmIdentite.getComboBox("cbSuffixe");
1160
		combo = hmIdentite.getComboBox("cbSuffixe");
1157
		valeur = combo.getValue();
1161
		valeur = combo.getValue();
1158
		if (valeur != null)	{
1162
		if (valeur != null)	{
1159
			strSuffixe = valeur.getNom() + " ";
1163
			strSuffixe = valeur.getNom() + " ";
1160
		} else {
1164
		} else {
1161
			strSuffixe = combo.getRawValue() +" ";
1165
			strSuffixe = combo.getRawValue() +" ";
1162
		}
1166
		}
1163
		
1167
		
1164
		personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe);
1168
		personneSelectionnee.setFmtNomComplet(strPrefixe, strSuffixe);
1165
 
1169
 
1166
		/** NAISSANCE **/
1170
		/** NAISSANCE **/
1167
		String valeurDateNaissance = (String) hmIdentite.getTextField("tfDateNaissance").getValue();
1171
		String valeurDateNaissance = (String) hmIdentite.getTextField("tfDateNaissance").getValue();
1168
		traiterDate("naissance", valeurDateNaissance, personneSelectionnee, lstMessageErreur);
1172
		traiterDate("naissance", valeurDateNaissance, personneSelectionnee, lstMessageErreur);
1169
		
1173
		
1170
		/** DECES **/
1174
		/** DECES **/
1171
		Radio rbEstDecedee = hmIdentite.getRadio("rbEstDecedee");
1175
		Radio rbEstDecedee = hmIdentite.getRadio("rbEstDecedee");
1172
		if (rbEstDecedee.getValue() == true) {
1176
		if (rbEstDecedee.getValue() == true) {
1173
			// date
1177
			// date
1174
			String valeurDateDeces = (String) hmIdentite.getTextField("tfDateDeces").getValue();	
1178
			String valeurDateDeces = (String) hmIdentite.getTextField("tfDateDeces").getValue();	
1175
			traiterDate("décès", valeurDateDeces, personneSelectionnee, lstMessageErreur);
1179
			traiterDate("décès", valeurDateDeces, personneSelectionnee, lstMessageErreur);
1176
			// lieu
1180
			// lieu
1177
			String decesLieu = (String) hmIdentite.getTextField("tfLieuDeces").getValue();
1181
			String decesLieu = (String) hmIdentite.getTextField("tfLieuDeces").getValue();
1178
			personneSelectionnee.setDecesLieu(decesLieu);
1182
			personneSelectionnee.setDecesLieu(decesLieu);
1179
		} else {
1183
		} else {
1180
			personneSelectionnee.setNonDecedee();
1184
			personneSelectionnee.setNonDecedee();
1181
		}
1185
		}
1182
		
1186
		
1183
		strValeur = obtenirValeurCombo("cbPays");		
1187
		strValeur = obtenirValeurCombo("cbPays");		
1184
		personneSelectionnee.set("ce_truk_pays", strValeur);
1188
		personneSelectionnee.set("ce_truk_pays", strValeur);
1185
		
1189
		
1186
		success = hmIdentite.getChampMultiValeursMultiTypes("telephones").estValide(true);
1190
		success = hmIdentite.getChampMultiValeursMultiTypes("telephones").estValide(true);
1187
		personneSelectionnee.set("truk_telephone", hmIdentite.getChampMultiValeursMultiTypes("telephones").getValeurs());
1191
		personneSelectionnee.set("truk_telephone", hmIdentite.getChampMultiValeursMultiTypes("telephones").getValeurs());
1188
		
1192
		
1189
		String logoUrls = hmIdentite.getChampMultiValeursImage("logos").getValeurs();
1193
		String logoUrls = hmIdentite.getChampMultiValeursImage("logos").getValeurs();
1190
		personneSelectionnee.set("truk_logo", logoUrls);
1194
		personneSelectionnee.set("truk_logo", logoUrls);
1191
		
1195
		
1192
		personneSelectionnee.set("truk_url", hmIdentite.getChampMultiValeurs("sites").getValeurs());
1196
		personneSelectionnee.set("truk_url", hmIdentite.getChampMultiValeurs("sites").getValeurs());
1193
		
1197
		
1194
		//Infos Naturalistes
1198
		//Infos Naturalistes
1195
		String recolte = ((ChampMultiValeursMultiTypesPaginable) hmInfosNat.get("recolte")).getValeurs();
1199
		String recolte = ((ChampMultiValeursMultiTypesPaginable) hmInfosNat.get("recolte")).getValeurs();
1196
		personneSelectionnee.set("truk_recolte", recolte);
1200
		personneSelectionnee.set("truk_recolte", recolte);
1197
		
1201
		
1198
		String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs();
1202
		String specialite = ((ChampMultiValeurs) hmInfosNat.get("specialite")).getValeurs();
1199
		personneSelectionnee.set("ce_truk_specialite", specialite);
1203
		personneSelectionnee.set("ce_truk_specialite", specialite);
1200
		
1204
		
1201
		lstMessageErreur.addAll(tiPubli.verifier());
1205
		lstMessageErreur.addAll(tiPubli.verifier());
1202
		
1206
		
1203
		if (lstMessageErreur.size() != 0)	{
1207
		if (lstMessageErreur.size() != 0)	{
1204
			String strMessagesErreur = "<span><br />";
1208
			String strMessagesErreur = "<span><br />";
1205
			Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
1209
			Iterator<String> itMessagesErreur = lstMessageErreur.iterator();
1206
			while (itMessagesErreur.hasNext())	{
1210
			while (itMessagesErreur.hasNext())	{
1207
				strMessagesErreur += "<br /> - " + itMessagesErreur.next();
1211
				strMessagesErreur += "<br /> - " + itMessagesErreur.next();
1208
			}
1212
			}
1209
			strMessagesErreur += "</span>";
1213
			strMessagesErreur += "</span>";
1210
			
1214
			
1211
 			MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
1215
 			MessageBox.alert("Erreurs", "Les erreurs suivantes ont été commises : \n" + strMessagesErreur, null);
1212
 			success = false;
1216
 			success = false;
1213
		}
1217
		}
1214
		
1218
		
1215
		return success;
1219
		return success;
1216
	}
1220
	}
1217
	
1221
	
1218
	private void traiterDate(String typeDate, String date, Personne personneSelectionnee, LinkedList<String> lstMessageErreur) {
1222
	private void traiterDate(String typeDate, String date, Personne personneSelectionnee, LinkedList<String> lstMessageErreur) {
1219
		
1223
		
1220
		String valeurDate = date;
1224
		String valeurDate = date;
1221
		
1225
		
1222
		if (!UtilString.isEmpty(valeurDate)){
1226
		if (!UtilString.isEmpty(valeurDate)){
1223
			String jour = "";
1227
			String jour = "";
1224
			String mois = "";
1228
			String mois = "";
1225
			String annee = "";
1229
			String annee = "";
1226
			String dateComplete = "";
1230
			String dateComplete = "";
1227
			String messageErreur = null;
1231
			String messageErreur = null;
1228
			
1232
			
1229
			/**  JJ/MM/AAAA  **/
1233
			/**  JJ/MM/AAAA  **/
1230
			if (valeurDate.matches("\\d{2}/\\d{2}/\\d{4}")) {
1234
			if (valeurDate.matches("\\d{2}/\\d{2}/\\d{4}")) {
1231
				jour = valeurDate.substring(0,2);
1235
				jour = valeurDate.substring(0,2);
1232
				mois = valeurDate.substring(3,5);
1236
				mois = valeurDate.substring(3,5);
1233
				annee = valeurDate.substring(6,10);
1237
				annee = valeurDate.substring(6,10);
1234
				if (jour.equals("00") || mois.equals("00") || annee.equals("0000")) {
1238
				if (jour.equals("00") || mois.equals("00") || annee.equals("0000")) {
1235
					messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.";
1239
					messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.";
1236
				} else {
1240
				} else {
1237
					dateComplete = annee+"-"+mois+"-"+jour;
1241
					dateComplete = annee+"-"+mois+"-"+jour;
1238
				}
1242
				}
1239
				
1243
				
1240
				
1244
				
1241
			/**  MM/AAAA  **/
1245
			/**  MM/AAAA  **/
1242
			} else if (valeurDate.matches("\\d{2}/\\d{4}")) {
1246
			} else if (valeurDate.matches("\\d{2}/\\d{4}")) {
1243
				jour = "00";
1247
				jour = "00";
1244
				mois = valeurDate.substring(0,2);
1248
				mois = valeurDate.substring(0,2);
1245
				annee = valeurDate.substring(3,7);
1249
				annee = valeurDate.substring(3,7);
1246
				if (mois.equals("00") || annee.equals("0000")) {
1250
				if (mois.equals("00") || annee.equals("0000")) {
1247
					messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.";
1251
					messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.";
1248
				} else {
1252
				} else {
1249
					dateComplete = annee+"-"+mois+"-"+jour;
1253
					dateComplete = annee+"-"+mois+"-"+jour;
1250
				}
1254
				}
1251
				
1255
				
1252
			}
1256
			}
1253
			
1257
			
1254
			/**  AAAA  **/
1258
			/**  AAAA  **/
1255
			else if (valeurDate.matches("\\d{4}"))	{
1259
			else if (valeurDate.matches("\\d{4}"))	{
1256
				if (valeurDate.equals("0000")) {
1260
				if (valeurDate.equals("0000")) {
1257
					messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.";
1261
					messageErreur = "La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.";
1258
				}
1262
				}
1259
				else {
1263
				else {
1260
					dateComplete = valeurDate + "-00-00";
1264
					dateComplete = valeurDate + "-00-00";
1261
					
1265
					
1262
				}
1266
				}
1263
			}
1267
			}
1264
			else {
1268
			else {
1265
				lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.");
1269
				lstMessageErreur.add("La date de "+typeDate+" n'est pas au format JJ/MM/AAAA ou MM/AAAA ou AAAA.");
1266
			}
1270
			}
1267
			if (messageErreur == null) {
1271
			if (messageErreur == null) {
1268
				if (typeDate=="naissance") personneSelectionnee.set("naissance_date", dateComplete);
1272
				if (typeDate=="naissance") personneSelectionnee.set("naissance_date", dateComplete);
1269
				else if (typeDate=="décès") {
1273
				else if (typeDate=="décès") {
1270
					personneSelectionnee.set("deces_date", dateComplete);
1274
					personneSelectionnee.set("deces_date", dateComplete);
1271
					personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE);
1275
					personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE);
1272
				}
1276
				}
1273
			} else {
1277
			} else {
1274
				lstMessageErreur.add(messageErreur);
1278
				lstMessageErreur.add(messageErreur);
1275
			}
1279
			}
1276
			
1280
			
1277
			if(typeDate.equals("décès")) {				
1281
			if(typeDate.equals("décès")) {				
1278
				String valeurDateDeces = hmIdentite.getTextField("tfDateDeces").getRawValue();
1282
				String valeurDateDeces = hmIdentite.getTextField("tfDateDeces").getRawValue();
1279
				String valeurDateNaissance = hmIdentite.getTextField("tfDateNaissance").getRawValue();
1283
				String valeurDateNaissance = hmIdentite.getTextField("tfDateNaissance").getRawValue();
1280
				
1284
				
1281
				if(valeurDateDeces != null && valeurDateNaissance != null &&
1285
				if(valeurDateDeces != null && valeurDateNaissance != null &&
1282
						!valeurDateDeces.isEmpty() && !valeurDateNaissance.isEmpty()) {
1286
						!valeurDateDeces.isEmpty() && !valeurDateNaissance.isEmpty()) {
1283
					Date dateNaissance = parserDate(valeurDateNaissance);
1287
					Date dateNaissance = parserDate(valeurDateNaissance);
1284
					Date dateDeces = parserDate(valeurDateDeces);
1288
					Date dateDeces = parserDate(valeurDateDeces);
1285
					
1289
					
1286
					if(dateDeces.compareTo(dateNaissance) < 0) {
1290
					if(dateDeces.compareTo(dateNaissance) < 0) {
1287
						lstMessageErreur.add("La date de décès ne peut pas précéder la date de naissance");
1291
						lstMessageErreur.add("La date de décès ne peut pas précéder la date de naissance");
1288
					}
1292
					}
1289
				}
1293
				}
1290
			}
1294
			}
1291
		/** Date vide **/
1295
		/** Date vide **/
1292
		} else {
1296
		} else {
1293
			if (typeDate=="naissance") {
1297
			if (typeDate=="naissance") {
1294
				personneSelectionnee.setNaissanceDate(null);
1298
				personneSelectionnee.setNaissanceDate(null);
1295
			} else if (typeDate=="décès") {
1299
			} else if (typeDate=="décès") {
1296
				personneSelectionnee.setDecesDate(null);
1300
				personneSelectionnee.setDecesDate(null);
1297
				personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE);
1301
				personneSelectionnee.set("ce_deces", personneSelectionnee.ETRE_DECEDE);
1298
			}
1302
			}
1299
		}
1303
		}
1300
		
1304
		
1301
	}
1305
	}
1302
	
1306
	
1303
	private Date parserDate(String valeurDate) {	
1307
	private Date parserDate(String valeurDate) {	
1304
		Date dateParsee = new Date();
1308
		Date dateParsee = new Date();
1305
		String[] composantsDate = valeurDate.split("/");
1309
		String[] composantsDate = valeurDate.split("/");
1306
		// Attention : la fonction setYear ajoute 1900 à l'année
1310
		// Attention : la fonction setYear ajoute 1900 à l'année
1307
		int annee = Integer.parseInt(composantsDate[(composantsDate.length-1)]) - 1900;
1311
		int annee = Integer.parseInt(composantsDate[(composantsDate.length-1)]) - 1900;
1308
		// Attention : les mois commencent à 0, donc janvier = 0, février = 1
1312
		// Attention : les mois commencent à 0, donc janvier = 0, février = 1
1309
		int mois = (composantsDate.length > 1) ? Integer.parseInt(composantsDate[(composantsDate.length-2)]) - 1 : 0;
1313
		int mois = (composantsDate.length > 1) ? Integer.parseInt(composantsDate[(composantsDate.length-2)]) - 1 : 0;
1310
		int jour = (composantsDate.length > 2) ? Integer.parseInt(composantsDate[0]) : 1;
1314
		int jour = (composantsDate.length > 2) ? Integer.parseInt(composantsDate[0]) : 1;
1311
		
1315
		
1312
		dateParsee.setYear(annee);	
1316
		dateParsee.setYear(annee);	
1313
		dateParsee.setMonth(mois);	
1317
		dateParsee.setMonth(mois);	
1314
		dateParsee.setDate(jour);
1318
		dateParsee.setDate(jour);
1315
					
1319
					
1316
		return dateParsee;
1320
		return dateParsee;
1317
	}
1321
	}
1318
	
1322
	
1319
	public Personne getPersonne() {
1323
	public Personne getPersonne() {
1320
		return this.personne;
1324
		return this.personne;
1321
	}
1325
	}
1322
	
1326
	
1323
	public String getPersonneId() {
1327
	public String getPersonneId() {
1324
		return this.personneId;
1328
		return this.personneId;
1325
	}
1329
	}
1326
	
1330
	
1327
	private Listener<BaseEvent> creerEcouteurNomPrenomExistant() {
1331
	private Listener<BaseEvent> creerEcouteurNomPrenomExistant() {
1328
		return new Listener<BaseEvent>() {
1332
		return new Listener<BaseEvent>() {
1329
			public void handleEvent(BaseEvent be) {
1333
			public void handleEvent(BaseEvent be) {
1330
				if(mode.equals(MODE_AJOUTER) && !verificationDoublonEffectuee) {
1334
				if(mode.equals(MODE_AJOUTER) && !verificationDoublonEffectuee) {
1331
					
1335
					
1332
					TextField<String> nom = (TextField<String>) hmIdentite.get("tfNom");
1336
					TextField<String> nom = (TextField<String>) hmIdentite.get("tfNom");
1333
					TextField<String> prenom = (TextField<String>) hmIdentite.get("tfPrenom");
1337
					TextField<String> prenom = (TextField<String>) hmIdentite.get("tfPrenom");
1334
					LabelField nomComplet = (LabelField) hmIdentite.get("nomComplet");
1338
					LabelField nomComplet = (LabelField) hmIdentite.get("nomComplet");
1335
					
1339
					
1336
					if(nom.getValue() != null && !nom.getValue().isEmpty()) {
1340
					if(nom.getValue() != null && !nom.getValue().isEmpty()) {
1337
						PersonneAsyncDao dao = new PersonneAsyncDao(PersonneForm.this);
1341
						PersonneAsyncDao dao = new PersonneAsyncDao(PersonneForm.this);
1338
						// Suppression d'éventuels doubles espaces (ou plus) et ajout d'un joker devant
1342
						// Suppression d'éventuels doubles espaces (ou plus) et ajout d'un joker devant
1339
						// (pour gérer la recherche lorsqu'on a qu'un nom de famille)
1343
						// (pour gérer la recherche lorsqu'on a qu'un nom de famille)
1340
						String nomCompletStr = "%"+nomComplet.getValue().toString().trim().replaceAll(" +", " ");
1344
						String nomCompletStr = "%"+nomComplet.getValue().toString().trim().replaceAll(" +", " ");
1341
						
1345
						
1342
						if(prenom.getValue() != null && !prenom.getValue().isEmpty()) {
1346
						if(prenom.getValue() != null && !prenom.getValue().isEmpty()) {
1343
							// Ajouter un % derrière le prénom permet de gérer facilement le cas de l'initiale
1347
							// Ajouter un % derrière le prénom permet de gérer facilement le cas de l'initiale
1344
							// et également de rechercher des noms potentiels si l'on a saisi qu'une initiale
1348
							// et également de rechercher des noms potentiels si l'on a saisi qu'une initiale
1345
							nomCompletStr = nomCompletStr.replaceAll(prenom+" ", prenom+"%");
1349
							nomCompletStr = nomCompletStr.replaceAll(prenom+" ", prenom+"%");
1346
						}
1350
						}
1347
						
1351
						
1348
						dao.testerExistencePersonne(nomCompletStr, new Callback<JSONObject, String>() {				
1352
						dao.testerExistencePersonne(nomCompletStr, new Callback<JSONObject, String>() {				
1349
							@Override
1353
							@Override
1350
							public void onSuccess(JSONObject objet) {
1354
							public void onSuccess(JSONObject objet) {
1351
								
1355
								
1352
								String message = formaterMessageAvertissementDoublon(objet);
1356
								String message = formaterMessageAvertissementDoublon(objet);
1353
								verificationDoublonEffectuee = true;
1357
								verificationDoublonEffectuee = true;
1354
								
1358
								
1355
								if(!message.isEmpty()) {
1359
								if(!message.isEmpty()) {
1356
									Window.alert(message);
1360
									Window.alert(message);
1357
								}
1361
								}
1358
							}
1362
							}
1359
							
1363
							
1360
							@Override
1364
							@Override
1361
							public void onFailure(String reason) {
1365
							public void onFailure(String reason) {
1362
								// TODO Auto-generated method stub
1366
								// TODO Auto-generated method stub
1363
							}
1367
							}
1364
						});
1368
						});
1365
					}
1369
					}
1366
				}
1370
				}
1367
			}
1371
			}
1368
		};
1372
		};
1369
	}
1373
	}
1370
	
1374
	
1371
	private String formaterMessageAvertissementDoublon(JSONObject objet) {
1375
	private String formaterMessageAvertissementDoublon(JSONObject objet) {
1372
		
1376
		
1373
		double nbPers = objet.get("nbElements").isNumber().getValue();
1377
		double nbPers = objet.get("nbElements").isNumber().getValue();
1374
		JSONArray personnes = objet.isObject().get("personnes").isArray();
1378
		JSONArray personnes = objet.isObject().get("personnes").isArray();
1375
		String message = "";
1379
		String message = "";
1376
		if(nbPers > 0) {
1380
		if(nbPers > 0) {
1377
			String pers = nbPers == 1 ? "personne" : "personnes";
1381
			String pers = nbPers == 1 ? "personne" : "personnes";
1378
			String exist = nbPers == 1 ? "existe" : "existent";
1382
			String exist = nbPers == 1 ? "existe" : "existent";
1379
			message = "Attention : "+(int)nbPers+" "+pers+" portant ce nom "+exist+" déjà"+"\n";
1383
			message = "Attention : "+(int)nbPers+" "+pers+" portant ce nom "+exist+" déjà"+"\n";
1380
			for(int i = 0; i < personnes.size(); i++) {
1384
			for(int i = 0; i < personnes.size(); i++) {
1381
				message += "- "+personnes.get(i).isObject().get("cp_fmt_nom_complet").isString().stringValue();
1385
				message += "- "+personnes.get(i).isObject().get("cp_fmt_nom_complet").isString().stringValue();
1382
				if(personnes.get(i).isObject().get("cp_ville") != null && personnes.get(i).isObject().get("cp_ville").isString() != null) {
1386
				if(personnes.get(i).isObject().get("cp_ville") != null && personnes.get(i).isObject().get("cp_ville").isString() != null) {
1383
					message += " à "+personnes.get(i).isObject().get("cp_ville").isString().stringValue();
1387
					message += " à "+personnes.get(i).isObject().get("cp_ville").isString().stringValue();
1384
				}
1388
				}
1385
				
1389
				
1386
				if(personnes.get(i).isObject().get("cp_naissance_date") != null 
1390
				if(personnes.get(i).isObject().get("cp_naissance_date") != null 
1387
					&& personnes.get(i).isObject().get("cp_naissance_date").isString()!= null
1391
					&& personnes.get(i).isObject().get("cp_naissance_date").isString()!= null
1388
					&& !personnes.get(i).isObject().get("cp_naissance_date").isString().stringValue().equals("0000-00-00")) {
1392
					&& !personnes.get(i).isObject().get("cp_naissance_date").isString().stringValue().equals("0000-00-00")) {
1389
					String dateChaine = personnes.get(i).isObject().get("cp_naissance_date").isString().stringValue();
1393
					String dateChaine = personnes.get(i).isObject().get("cp_naissance_date").isString().stringValue();
1390
					
1394
					
1391
					String dateNaissance = "";
1395
					String dateNaissance = "";
1392
					// Quelque fois on ne possède que l'année de naissance de la personne,
1396
					// Quelque fois on ne possède que l'année de naissance de la personne,
1393
					// dans ce cas là la date est de la forme XXXX-00-00
1397
					// dans ce cas là la date est de la forme XXXX-00-00
1394
					if(dateChaine.endsWith("-00-00")) {
1398
					if(dateChaine.endsWith("-00-00")) {
1395
						dateNaissance = dateChaine.substring(0, 4);
1399
						dateNaissance = dateChaine.substring(0, 4);
1396
					} else {
1400
					} else {
1397
						dateNaissance = UtilDate.formaterEnStringFormatFr(UtilString.formaterEnDate(dateChaine));
1401
						dateNaissance = UtilDate.formaterEnStringFormatFr(UtilString.formaterEnDate(dateChaine));
1398
					}
1402
					}
1399
 
1403
 
1400
					message += ", date de naissance : "+dateNaissance;
1404
					message += ", date de naissance : "+dateNaissance;
1401
				}
1405
				}
1402
				message += "\n";
1406
				message += "\n";
1403
			}
1407
			}
1404
		}
1408
		}
1405
		
1409
		
1406
		return message;
1410
		return message;
1407
	}
1411
	}
1408
}
1412
}