Subversion Repositories eFlore/Applications.coel

Rev

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

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