Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 2737 Rev 2833
1
package org.tela_botanica.client.vues.observation;
1
package org.tela_botanica.client.vues.observation;
2
 
2
 
3
// TODO Detecter redim et supprimer ajuster
3
// TODO Detecter redim et supprimer ajuster
4
 
4
 
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.List;
8
import java.util.List;
9
import java.util.Map;
9
import java.util.Map;
10
 
10
 
11
import org.tela_botanica.client.CarnetEnLigneMediateur;
11
import org.tela_botanica.client.CarnetEnLigneMediateur;
12
import org.tela_botanica.client.i18n.Msg;
12
import org.tela_botanica.client.i18n.Msg;
13
import org.tela_botanica.client.interfaces.Rafraichissable;
13
import org.tela_botanica.client.interfaces.Rafraichissable;
14
import org.tela_botanica.client.modeles.dao.ImageInformationRepartitionAsynchroneDAO;
14
import org.tela_botanica.client.modeles.dao.ImageInformationRepartitionAsynchroneDAO;
15
import org.tela_botanica.client.modeles.dao.ListeReferentielChampsEtendusDAO;
15
import org.tela_botanica.client.modeles.dao.ListeReferentielChampsEtendusDAO;
16
import org.tela_botanica.client.modeles.dao.ListeReferentielLocaliteAsynchroneDAO;
16
import org.tela_botanica.client.modeles.dao.ListeReferentielLocaliteAsynchroneDAO;
17
import org.tela_botanica.client.modeles.dao.ListeReferentielNomAsynchroneDAO;
17
import org.tela_botanica.client.modeles.dao.ListeReferentielNomAsynchroneDAO;
18
import org.tela_botanica.client.modeles.dao.ListeReferentielPersoAsynchroneDAO;
18
import org.tela_botanica.client.modeles.dao.ListeReferentielPersoAsynchroneDAO;
19
import org.tela_botanica.client.modeles.objets.ChampEtendu;
19
import org.tela_botanica.client.modeles.objets.ChampEtendu;
20
import org.tela_botanica.client.modeles.objets.Configuration;
20
import org.tela_botanica.client.modeles.objets.Configuration;
21
import org.tela_botanica.client.modeles.objets.EntiteGeographiqueObservation;
21
import org.tela_botanica.client.modeles.objets.EntiteGeographiqueObservation;
22
import org.tela_botanica.client.modeles.objets.ListeObservation;
22
import org.tela_botanica.client.modeles.objets.ListeObservation;
23
import org.tela_botanica.client.modeles.objets.Observation;
23
import org.tela_botanica.client.modeles.objets.Observation;
24
import org.tela_botanica.client.modeles.objets.Ontologies;
24
import org.tela_botanica.client.modeles.objets.Ontologies;
25
import org.tela_botanica.client.modeles.objets.ReferentielLocalite;
25
import org.tela_botanica.client.modeles.objets.ReferentielLocalite;
26
import org.tela_botanica.client.modeles.objets.ReferentielNom;
26
import org.tela_botanica.client.modeles.objets.ReferentielNom;
27
import org.tela_botanica.client.modeles.objets.ListeReferentielPerso.TypesReferentiels;
27
import org.tela_botanica.client.modeles.objets.ListeReferentielPerso.TypesReferentiels;
28
import org.tela_botanica.client.observation.ObservationMediateur;
28
import org.tela_botanica.client.observation.ObservationMediateur;
29
import org.tela_botanica.client.util.ChampSaisieEtendu;
29
import org.tela_botanica.client.util.ChampSaisieEtendu;
30
import org.tela_botanica.client.util.FormulaireSaisieChampEtendu;
30
import org.tela_botanica.client.util.FormulaireSaisieChampEtendu;
31
import org.tela_botanica.client.util.Util;
31
import org.tela_botanica.client.util.Util;
32
import org.tela_botanica.client.util.autocompletion.AutoCompletionComboBox;
32
import org.tela_botanica.client.util.autocompletion.AutoCompletionComboBox;
33
 
33
 
34
import com.google.gwt.core.client.Callback;
34
import com.google.gwt.core.client.Callback;
35
import com.google.gwt.event.dom.client.ClickEvent;
35
import com.google.gwt.event.dom.client.ClickEvent;
36
import com.google.gwt.event.dom.client.ClickHandler;
36
import com.google.gwt.event.dom.client.ClickHandler;
37
import com.google.gwt.http.client.Response;
37
import com.google.gwt.http.client.Response;
38
import com.google.gwt.user.client.Timer;
38
import com.google.gwt.user.client.Timer;
39
import com.google.gwt.user.client.Window;
39
import com.google.gwt.user.client.Window;
40
import com.google.gwt.user.client.ui.HTML;
40
import com.google.gwt.user.client.ui.HTML;
41
import com.google.gwt.user.client.ui.PopupPanel;
41
import com.google.gwt.user.client.ui.PopupPanel;
42
import com.gwtext.client.core.EventCallback;
42
import com.gwtext.client.core.EventCallback;
43
import com.gwtext.client.core.EventObject;
43
import com.gwtext.client.core.EventObject;
44
import com.gwtext.client.core.Ext;
44
import com.gwtext.client.core.Ext;
45
import com.gwtext.client.core.ExtElement;
45
import com.gwtext.client.core.ExtElement;
46
import com.gwtext.client.core.ListenerConfig;
46
import com.gwtext.client.core.ListenerConfig;
47
import com.gwtext.client.core.Position;
47
import com.gwtext.client.core.Position;
48
import com.gwtext.client.widgets.BoxComponent;
48
import com.gwtext.client.widgets.BoxComponent;
49
import com.gwtext.client.widgets.Button;
49
import com.gwtext.client.widgets.Button;
50
import com.gwtext.client.widgets.Container;
50
import com.gwtext.client.widgets.Container;
51
import com.gwtext.client.widgets.DatePicker;
51
import com.gwtext.client.widgets.DatePicker;
52
import com.gwtext.client.widgets.Panel;
52
import com.gwtext.client.widgets.Panel;
53
import com.gwtext.client.widgets.ToolTip;
53
import com.gwtext.client.widgets.ToolTip;
54
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
54
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
55
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
55
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
56
import com.gwtext.client.widgets.event.DatePickerListenerAdapter;
56
import com.gwtext.client.widgets.event.DatePickerListenerAdapter;
57
import com.gwtext.client.widgets.event.PanelListenerAdapter;
57
import com.gwtext.client.widgets.event.PanelListenerAdapter;
58
import com.gwtext.client.widgets.form.ComboBox;
58
import com.gwtext.client.widgets.form.ComboBox;
59
import com.gwtext.client.widgets.form.DateField;
59
import com.gwtext.client.widgets.form.DateField;
60
import com.gwtext.client.widgets.form.Field;
60
import com.gwtext.client.widgets.form.Field;
61
import com.gwtext.client.widgets.form.FormPanel;
61
import com.gwtext.client.widgets.form.FormPanel;
62
import com.gwtext.client.widgets.form.Label;
62
import com.gwtext.client.widgets.form.Label;
63
import com.gwtext.client.widgets.form.MultiFieldPanel;
63
import com.gwtext.client.widgets.form.MultiFieldPanel;
64
import com.gwtext.client.widgets.form.TextArea;
64
import com.gwtext.client.widgets.form.TextArea;
65
import com.gwtext.client.widgets.form.TextField;
65
import com.gwtext.client.widgets.form.TextField;
66
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
66
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
67
import com.gwtext.client.widgets.form.event.TextFieldListenerAdapter;
67
import com.gwtext.client.widgets.form.event.TextFieldListenerAdapter;
68
import com.gwtext.client.widgets.layout.AnchorLayoutData;
68
import com.gwtext.client.widgets.layout.AnchorLayoutData;
69
import com.gwtext.client.widgets.layout.ColumnLayout;
69
import com.gwtext.client.widgets.layout.ColumnLayout;
70
import com.gwtext.client.widgets.layout.ColumnLayoutData;
70
import com.gwtext.client.widgets.layout.ColumnLayoutData;
71
import com.gwtext.client.widgets.layout.FormLayout;
71
import com.gwtext.client.widgets.layout.FormLayout;
72
import com.gwtext.client.widgets.layout.RowLayout;
72
import com.gwtext.client.widgets.layout.RowLayout;
73
import com.gwtext.client.data.Record;
73
import com.gwtext.client.data.Record;
74
 
74
 
75
/**
75
/**
76
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
76
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
77
 * @author aurelien
77
 * @author aurelien
78
 *
78
 *
79
 */
79
 */
80
public class FormulaireSaisieObservationVue extends Panel implements Rafraichissable  {
80
public class FormulaireSaisieObservationVue extends Panel implements Rafraichissable  {
81
 
81
 
82
 
82
 
83
	/**
83
	/**
84
	 * Le médiateur associé à la vue
84
	 * Le médiateur associé à la vue
85
	 */
85
	 */
86
	private ObservationMediateur	observationMediateur		= null;
86
	private ObservationMediateur	observationMediateur		= null;
87
 
87
 
88
	FormPanel panneauFormulaire = null;
88
	FormPanel panneauFormulaire = null;
89
 
89
 
90
	private DateField date = null;
90
	private DateField date = null;
91
	private AutoCompletionComboBox lieudit = null;
91
	private AutoCompletionComboBox lieudit = null;
92
	private AutoCompletionComboBox station = null;
92
	private AutoCompletionComboBox station = null;
93
	private AutoCompletionComboBox milieu = null;
93
	private AutoCompletionComboBox milieu = null;
94
	private TextField comment = null;
94
	private TextField comment = null;
95
	private AutoCompletionComboBox  localite = null;
95
	private AutoCompletionComboBox  localite = null;
96
	
96
	
97
	private String codeLocalite = null;
97
	private String codeLocalite = null;
98
	private String pays = null;
98
	private String pays = null;
99
	
99
	
100
	private AutoCompletionComboBox  espece = null;
100
	private AutoCompletionComboBox  espece = null;
101
	private Map<String, ReferentielNom> referentielNom = null;
101
	private Map<String, ReferentielNom> referentielNom = null;
102
	private Map<String, ReferentielLocalite> referentielLocalite = null;
102
	private Map<String, ReferentielLocalite> referentielLocalite = null;
103
	
103
	
104
	private String numeroNom = null;
104
	private String numeroNom = null;
105
	private String numeroOrdre = null;
105
	private String numeroOrdre = null;
106
	private String referentielTaxo = null;
106
	private String referentielTaxo = null;
107
	private String referentielGeo = null;
107
	private String referentielGeo = null;
108
	
108
	
109
	private Map<String, String> avertissementPresence = new HashMap<String, String>();
109
	private Map<String, String> avertissementPresence = new HashMap<String, String>();
110
	private boolean enRequeteChrologie = false;
110
	private boolean enRequeteChrologie = false;
111
 
111
 
112
	// Pour remise a zero partielle lors d'une validation
112
	// Pour remise a zero partielle lors d'une validation
113
 
113
 
114
	private enum Champs {
114
	private enum Champs {
115
	    DATE, LIEUDIT, STATION, MILIEU, COMMENT, LOCALITE, ESPECE, TOUT, LATITUDE, LONGITUDE, ALTITUDE, ABONDANCE, CERTITUDE, REFERENTIELTAXO, PHENOLOGIE;
115
	    DATE, LIEUDIT, STATION, MILIEU, COMMENT, LOCALITE, ESPECE, TOUT, LATITUDE, LONGITUDE, ALTITUDE, ABONDANCE, CERTITUDE, REFERENTIELTAXO, PHENOLOGIE;
116
 
116
 
117
	    @Override
117
	    @Override
118
		public String toString() {
118
		public String toString() {
119
	    
119
	    
120
	    	switch(this) {
120
	    	switch(this) {
121
	    	case DATE:
121
	    	case DATE:
122
	    		return "date";
122
	    		return "date";
123
	    
123
	    
124
	    	case LOCALITE:
124
	    	case LOCALITE:
125
	    		return "localite";
125
	    		return "localite";
126
	    
126
	    
127
    		case LIEUDIT:
127
    		case LIEUDIT:
128
    			return "lieu dit";
128
    			return "lieu dit";
129
	    
129
	    
130
    		case STATION:
130
    		case STATION:
131
    			return "station";
131
    			return "station";
132
	    
132
	    
133
    		case MILIEU:
133
    		case MILIEU:
134
    			return "milieu";
134
    			return "milieu";
135
	    
135
	    
136
    		case COMMENT:
136
    		case COMMENT:
137
    			return "notes";
137
    			return "notes";
138
	    
138
	    
139
	    	case ESPECE:
139
	    	case ESPECE:
140
	    		return "espèce";
140
	    		return "espèce";
141
	    
141
	    
142
	    	case LATITUDE:
142
	    	case LATITUDE:
143
	    		return "latitude";
143
	    		return "latitude";
144
	    
144
	    
145
	    	case LONGITUDE:
145
	    	case LONGITUDE:
146
	    		return "longitude";
146
	    		return "longitude";
147
	    
147
	    
148
	    	case ALTITUDE:
148
	    	case ALTITUDE:
149
	    		return "altitude";
149
	    		return "altitude";
150
	    
150
	    
151
	    	case ABONDANCE:
151
	    	case ABONDANCE:
152
	    		return "abondance";
152
	    		return "abondance";
153
	    
153
	    
154
	    	case CERTITUDE:
154
	    	case CERTITUDE:
155
	    		return "identification";
155
	    		return "identification";
156
	    
156
	    
157
	    	case REFERENTIELTAXO:
157
	    	case REFERENTIELTAXO:
158
	    		return "referentiel";
158
	    		return "referentiel";
159
	    
159
	    
160
	    	case PHENOLOGIE:
160
	    	case PHENOLOGIE:
161
	    		return "phenologie";
161
	    		return "phenologie";
162
	    
162
	    
163
	    	case TOUT:
163
	    	case TOUT:
164
	    		return "date, localite, lieu dit, station, milieu, espèce, notes, latitude, longitude, altitude, abondance, identification, referentiel, phenologie";
164
	    		return "date, localite, lieu dit, station, milieu, espèce, notes, latitude, longitude, altitude, abondance, identification, referentiel, phenologie";
165
	    	}
165
	    	}
166
			return TOUT.toString();
166
			return TOUT.toString();
167
	    }
167
	    }
168
	};
168
	};
169
 
169
 
170
	private String formatDate = null ;
170
	private String formatDate = null ;
171
	private Button boutonOK = new Button(Msg.get("creer"));
171
	private Button boutonOK = new Button(Msg.get("creer"));
172
	private Button boutonModifier = new Button(Msg.get("modifier"));
172
	private Button boutonModifier = new Button(Msg.get("modifier"));
173
	private Button boutonSupprimer = new Button(Msg.get("supprimer"));
173
	private Button boutonSupprimer = new Button(Msg.get("supprimer"));
174
	private Button boutonReinitialiser = new Button(Msg.get("reinitialiser"));
174
	private Button boutonReinitialiser = new Button(Msg.get("reinitialiser"));
175
 
175
 
176
	private boolean selectionlocalite=false;
176
	private boolean selectionlocalite=false;
177
	private boolean selectionEspece=false;
177
	private boolean selectionEspece=false;
178
	private boolean selectionAbondance = false;
178
	private boolean selectionAbondance = false;
179
	private boolean selectionCertitude = false;
179
	private boolean selectionCertitude = false;
180
	private boolean selectionPhenologie = false;
180
	private boolean selectionPhenologie = false;
181
 
181
 
182
	private final String VALEURS_MULTIPLES = "("+Msg.get("valeurs-multiples")+")";
182
	private final String VALEURS_MULTIPLES = "("+Msg.get("valeurs-multiples")+")";
183
	private final String modeleMessageModif = "localite:lieu-dit:station:milieu:latitude:longitude:altitude:date:espece:notes:abondance:identification:referentiel:phenologie";
183
	private final String modeleMessageModif = "localite:lieu-dit:station:milieu:latitude:longitude:altitude:date:espece:notes:abondance:identification:referentiel:phenologie";
184
	private boolean localiteModifiee = false;
184
	private boolean localiteModifiee = false;
185
	private boolean lieuDitModifie = false;
185
	private boolean lieuDitModifie = false;
186
	private boolean stationModifiee = false;
186
	private boolean stationModifiee = false;
187
	private boolean milieuModifie = false;
187
	private boolean milieuModifie = false;
188
	private boolean dateModifiee = false;
188
	private boolean dateModifiee = false;
189
	private boolean especeModifiee = false;
189
	private boolean especeModifiee = false;
190
	private boolean commModifie = false;
190
	private boolean commModifie = false;
191
	private boolean abondanceModifiee = false;
191
	private boolean abondanceModifiee = false;
192
	private boolean certitudeModifiee = false;
192
	private boolean certitudeModifiee = false;
193
	private boolean referentielTaxoModifie = false;
193
	private boolean referentielTaxoModifie = false;
194
	private boolean phenologieModifiee = false;;
194
	private boolean phenologieModifiee = false;;
195
 
195
 
196
	private final int KEY_ALT = 18;
196
	private final int KEY_ALT = 18;
197
	private final int KEY_BACKSPACE = 8;
197
	private final int KEY_BACKSPACE = 8;
198
	private final int KEY_CTRL = 17;
198
	private final int KEY_CTRL = 17;
199
	private final int KEY_DELETE = 46;
199
	private final int KEY_DELETE = 46;
200
	private final int KEY_DOWN = 40;
200
	private final int KEY_DOWN = 40;
201
	private final int KEY_END = 35;
201
	private final int KEY_END = 35;
202
	private final int KEY_ENTER = 13;
202
	private final int KEY_ENTER = 13;
203
	private final int KEY_ESCAPE = 27;
203
	private final int KEY_ESCAPE = 27;
204
	private final int KEY_HOME = 36;
204
	private final int KEY_HOME = 36;
205
	private final int KEY_LEFT = 37;
205
	private final int KEY_LEFT = 37;
206
	private final int KEY_PAGEDOWN = 34;
206
	private final int KEY_PAGEDOWN = 34;
207
	private final int KEY_PAGEUP = 33;
207
	private final int KEY_PAGEUP = 33;
208
	private final int KEY_RIGHT = 39;
208
	private final int KEY_RIGHT = 39;
209
	private final int KEY_SHIFT = 16;
209
	private final int KEY_SHIFT = 16;
210
	private final int KEY_TAB = 9;
210
	private final int KEY_TAB = 9;
211
	private final int KEY_UP = 38;
211
	private final int KEY_UP = 38;
212
 
212
 
213
	/**
213
	/**
214
	 * Booleen d'instanciation
214
	 * Booleen d'instanciation
215
	 */
215
	 */
216
	boolean estInstancie = false ;
216
	boolean estInstancie = false ;
217
 
217
 
218
	private Panel panneauIntermediaire;
218
	private Panel panneauIntermediaire;
219
 
219
 
220
	private Panel panneauPremierColonne;
220
	private Panel panneauPremierColonne;
221
 
221
 
222
	private Panel panneauSecondeColonne;
222
	private Panel panneauSecondeColonne;
223
 
223
 
224
	private TextField longitude;
224
	private TextField longitude;
225
 
225
 
226
	private TextField latitude;
226
	private TextField latitude;
227
 
227
 
228
	private TextField altitude;
228
	private TextField altitude;
229
 
229
 
230
	private MultiFieldPanel htmllocalitePanel = null;
230
	private MultiFieldPanel htmllocalitePanel = null;
231
 
231
 
232
	private MultiFieldPanel coordPanel;
232
	private MultiFieldPanel coordPanel;
233
 
233
 
234
	private TextField coordonnees;
234
	private TextField coordonnees;
235
 
235
 
236
	private Label lienSelectionlocalite = null;
236
	private Label lienSelectionlocalite = null;
237
 
237
 
238
	private HTML afficherFormulaireLatLon;
238
	private HTML afficherFormulaireLatLon;
239
 
239
 
240
	private HTML basculerverscarto;
240
	private HTML basculerverscarto;
241
 
241
 
242
	private boolean longlatAjoutee;
242
	private boolean longlatAjoutee;
243
 
243
 
244
	private boolean latModifiee;
244
	private boolean latModifiee;
245
 
245
 
246
	private boolean longModifiee;
246
	private boolean longModifiee;
247
 
247
 
248
	private boolean altModifiee;
248
	private boolean altModifiee;
249
 
249
 
250
	protected boolean recherchelocaliteEnCours = false;
250
	protected boolean recherchelocaliteEnCours = false;
251
 
251
 
252
	private Timer tCoord;
252
	private Timer tCoord;
253
 
253
 
254
	private ComboBox selecteurAbondance = null;
254
	private ComboBox selecteurAbondance = null;
255
 
255
 
256
	private ComboBox selecteurCertitude = null;
256
	private ComboBox selecteurCertitude = null;
257
 
257
 
258
	private ComboBox selecteurReferentielTaxo = null;
258
	private ComboBox selecteurReferentielTaxo = null;
259
 
259
 
260
	private ComboBox selecteurStadePheno = null;
260
	private ComboBox selecteurStadePheno = null;
261
 
261
 
262
	private boolean selectionMultiple = false;
262
	private boolean selectionMultiple = false;
263
 
263
 
264
	private HTML lienAfficherChampsEtendus = null;
264
	private HTML lienAfficherChampsEtendus = null;
265
	private HTML lienAjouterChampsEtendus = null;
265
	private HTML lienAjouterChampsEtendus = null;
266
 
266
 
267
	Panel conteneurChampEtenduGauche = null;
267
	Panel conteneurChampEtenduGauche = null;
268
	Panel conteneurChampEtenduDroite = null;
268
	Panel conteneurChampEtenduDroite = null;
269
 
269
 
270
	private boolean afficherChampsEtendus = false;
270
	private boolean afficherChampsEtendus = false;
271
	private boolean afficherLienAjoutChampsEtendus = false;
271
	private boolean afficherLienAjoutChampsEtendus = false;
272
	private boolean premierAffichage = true;
272
	private boolean premierAffichage = true;
273
 
273
 
274
	private PopupPanel popUpAjoutChampEtendu = new PopupPanel();
274
	private PopupPanel popUpAjoutChampEtendu = new PopupPanel();
275
	
275
	
276
	private Map<String, ChampSaisieEtendu> listeChampsEtendus;
276
	private Map<String, ChampSaisieEtendu> listeChampsEtendus;
277
 
277
 
278
	/**
278
	/**
279
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
279
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
280
	 */
280
	 */
281
	@SuppressWarnings("unused")
281
	@SuppressWarnings("unused")
282
	private FormulaireSaisieObservationVue()
282
	private FormulaireSaisieObservationVue()
283
	{
283
	{
284
		super() ;
284
		super() ;
285
	}
285
	}
286
 
286
 
287
	/**
287
	/**
288
	 * Constructeur avec argument
288
	 * Constructeur avec argument
289
	 * @param im
289
	 * @param im
290
	 */
290
	 */
291
	public FormulaireSaisieObservationVue(ObservationMediateur obs)
291
	public FormulaireSaisieObservationVue(ObservationMediateur obs)
292
	{
292
	{
293
		super(Msg.get("saisie"));
293
		super(Msg.get("saisie"));
294
		// on associe le médiateur
294
		// on associe le médiateur
295
		observationMediateur = obs ;
295
		observationMediateur = obs ;
296
 
296
 
297
		referentielTaxo = obs.getRefTaxSelectionne().getCode();
297
		referentielTaxo = obs.getRefTaxSelectionne().getCode();
298
	     
298
	     
299
		panneauFormulaire = new FormPanel(Position.RIGHT);
299
		panneauFormulaire = new FormPanel(Position.RIGHT);
300
		panneauFormulaire.setBorder(false);
300
		panneauFormulaire.setBorder(false);
301
 
301
 
302
		// Panneau intermediaire qui contient deux colonnes de formulaire
302
		// Panneau intermediaire qui contient deux colonnes de formulaire
303
		panneauIntermediaire = new Panel();
303
		panneauIntermediaire = new Panel();
304
 
304
 
305
		if (Window.getClientWidth()> Window.getClientHeight()) {
305
		if (Window.getClientWidth()> Window.getClientHeight()) {
306
			panneauIntermediaire.setLayout(new ColumnLayout());
306
			panneauIntermediaire.setLayout(new ColumnLayout());
307
		}
307
		}
308
		else {
308
		else {
309
			panneauIntermediaire.setLayout(new RowLayout());
309
			panneauIntermediaire.setLayout(new RowLayout());
310
		}
310
		}
311
 
311
 
312
		panneauIntermediaire.setBorder(false);
312
		panneauIntermediaire.setBorder(false);
313
 
313
 
314
		//création du panneau formulaire de gauche auquels on ajoute les champs
314
		//création du panneau formulaire de gauche auquels on ajoute les champs
315
		panneauPremierColonne = new Panel();
315
		panneauPremierColonne = new Panel();
316
		panneauPremierColonne.setLayout(new FormLayout());
316
		panneauPremierColonne.setLayout(new FormLayout());
317
		panneauPremierColonne.setBorder(false);
317
		panneauPremierColonne.setBorder(false);
318
 
318
 
319
		//création du panneau formulaire de droite
319
		//création du panneau formulaire de droite
320
	    panneauSecondeColonne = new Panel();
320
	    panneauSecondeColonne = new Panel();
321
		panneauSecondeColonne.setLayout(new FormLayout());
321
		panneauSecondeColonne.setLayout(new FormLayout());
322
		panneauSecondeColonne.setBorder(false);
322
		panneauSecondeColonne.setBorder(false);
323
 
323
 
324
		this.setPaddings(5) ;
324
		this.setPaddings(5) ;
325
 
325
 
326
		// Accesskey pour debugging
326
		// Accesskey pour debugging
327
		localite = new AutoCompletionComboBox(Msg.get("localite"), ListeReferentielLocaliteAsynchroneDAO.getUrlReferentielLocalites()) {			
327
		localite = new AutoCompletionComboBox(Msg.get("localite"), ListeReferentielLocaliteAsynchroneDAO.getUrlReferentielLocalites()) {			
328
			@Override
328
			@Override
329
			protected Map<String, String> parserResultatRequete(Response response) {
329
			protected Map<String, String> parserResultatRequete(Response response) {
330
				referentielLocalite = Util.parserRetourReferentielLocaliteIndexeParNom(response);
330
				referentielLocalite = Util.parserRetourReferentielLocaliteIndexeParNom(response);
331
				return Util.convertirListeReferentielLocaliteVersMap(referentielLocalite);
331
				return Util.convertirListeReferentielLocaliteVersMap(referentielLocalite);
332
			}
332
			}
333
			
333
			
334
			@Override
334
			@Override
335
			public void onSelectionValeur() {
335
			public void onSelectionValeur() {
336
				localiteModifiee = true;
336
				localiteModifiee = true;
337
				surSelectionLocalite();
337
				surSelectionLocalite();
338
				verifierPresenceTaxonSaisi();
338
				verifierPresenceTaxonSaisi();
339
			}
339
			}
340
			
340
			
341
			@Override
341
			@Override
342
			protected void onModificationValeur() {
342
			protected void onModificationValeur() {
343
				localiteModifiee = true;	
343
				localiteModifiee = true;	
344
				verifierPresenceTaxonSaisi();
344
				verifierPresenceTaxonSaisi();
345
			}
345
			}
346
 
346
 
347
			@Override
347
			@Override
348
			public void onValidationSaisie() {
348
			public void onValidationSaisie() {
349
				validerSaisie(Champs.LOCALITE);
349
				validerSaisie(Champs.LOCALITE);
350
			}
350
			}
351
		};
351
		};
352
 
352
 
353
 
353
 
354
		//création du lien "Accès carto" dans le formulaire;
354
		//création du lien "Accès carto" dans le formulaire;
355
		basculerverscarto = new HTML(" <a id=\"lien_carto\" title=\""+Msg.get("aide-lien-localiser")+"\" href=\"#\" tabindex=\"2\">"+Msg.get("localiser-zone")+"</a>");
355
		basculerverscarto = new HTML(" <a id=\"lien_carto\" title=\""+Msg.get("aide-lien-localiser")+"\" href=\"#\" tabindex=\"2\">"+Msg.get("localiser-zone")+"</a>");
356
		basculerverscarto.addStyleName("lien_actif");
356
		basculerverscarto.addStyleName("lien_actif");
357
 
357
 
358
		//création info bulle sur le lien "accès carto"
358
		//création info bulle sur le lien "accès carto"
359
		ToolTip tip2 = new ToolTip();
359
		ToolTip tip2 = new ToolTip();
360
		tip2.setHtml(Msg.get("aide-lien-localiser"));
360
		tip2.setHtml(Msg.get("aide-lien-localiser"));
361
		tip2.applyTo(basculerverscarto.getElement());
361
		tip2.applyTo(basculerverscarto.getElement());
362
 
362
 
363
		//Sur une meme ligne, ajout de plusieurs champs
363
		//Sur une meme ligne, ajout de plusieurs champs
364
		htmllocalitePanel = new MultiFieldPanel();
364
		htmllocalitePanel = new MultiFieldPanel();
365
 
365
 
366
		int largeurlocalite = Window.getClientWidth()/4;
366
		int largeurlocalite = Window.getClientWidth()/4;
367
		htmllocalitePanel.addToRow(localite, largeurlocalite);
367
		htmllocalitePanel.addToRow(localite, largeurlocalite);
368
		htmllocalitePanel.addToRow(basculerverscarto, 160);
368
		htmllocalitePanel.addToRow(basculerverscarto, 160);
369
 
369
 
370
		htmllocalitePanel.setBorder(false);
370
		htmllocalitePanel.setBorder(false);
371
		htmllocalitePanel.setId("x-localite-panel");
371
		htmllocalitePanel.setId("x-localite-panel");
372
 
372
 
373
		panneauPremierColonne.add(htmllocalitePanel);
373
		panneauPremierColonne.add(htmllocalitePanel);
374
 
374
 
375
	    station = new AutoCompletionComboBox(Msg.get("station"), ListeReferentielPersoAsynchroneDAO.getUrlReferentielPerso(TypesReferentiels.REFERENTIEL_STATION)) {			
375
	    station = new AutoCompletionComboBox(Msg.get("station"), ListeReferentielPersoAsynchroneDAO.getUrlReferentielPerso(TypesReferentiels.REFERENTIEL_STATION)) {			
376
			@Override
376
			@Override
377
			protected Map<String, String> parserResultatRequete(Response response) {
377
			protected Map<String, String> parserResultatRequete(Response response) {
378
				return Util.parserRetourReferentielPerso(response);
378
				return Util.parserRetourReferentielPerso(response);
379
			}
379
			}
380
			
380
			
381
			@Override
381
			@Override
382
			public void onSelectionValeur() {
382
			public void onSelectionValeur() {
383
				stationModifiee = true;
383
				stationModifiee = true;
384
			}
384
			}
385
			
385
			
386
			@Override
386
			@Override
387
			protected void onModificationValeur() {
387
			protected void onModificationValeur() {
388
				stationModifiee = true;	
388
				stationModifiee = true;	
389
			}
389
			}
390
 
390
 
391
			@Override
391
			@Override
392
			public void onValidationSaisie() {
392
			public void onValidationSaisie() {
393
				validerSaisie(Champs.STATION);
393
				validerSaisie(Champs.STATION);
394
			}
394
			}
395
 
395
 
396
			@Override
396
			@Override
397
			protected String preTraiterUrlRequete(String urlRequete, String valeur) {
397
			protected String preTraiterUrlRequete(String urlRequete, String valeur) {
398
				return ListeReferentielPersoAsynchroneDAO.formaterUrlRequeteAutoCompletionPerso(urlRequete, valeur);
398
				return ListeReferentielPersoAsynchroneDAO.formaterUrlRequeteAutoCompletionPerso(urlRequete, valeur);
399
			}  
399
			}  
400
		};
400
		};
401
	    panneauPremierColonne.add(station, new AnchorLayoutData("95%"));
401
	    panneauPremierColonne.add(station, new AnchorLayoutData("95%"));
402
 
402
 
403
		latitude = new TextField(Msg.get("lat"), "lat");
403
		latitude = new TextField(Msg.get("lat"), "lat");
404
		latitude.setGrowMax(70);
404
		latitude.setGrowMax(70);
405
		latitude.setAllowBlank(true);
405
		latitude.setAllowBlank(true);
406
 
406
 
407
	    longitude = new TextField(Msg.get("lon"), "lon");
407
	    longitude = new TextField(Msg.get("lon"), "lon");
408
	    longitude.setGrowMax(70);
408
	    longitude.setGrowMax(70);
409
		longitude.setAllowBlank(true);
409
		longitude.setAllowBlank(true);
410
 
410
 
411
		altitude = new TextField(Msg.get("alt"), "alt");
411
		altitude = new TextField(Msg.get("alt"), "alt");
412
		altitude.setGrowMax(70);
412
		altitude.setGrowMax(70);
413
		altitude.setAllowBlank(true);
413
		altitude.setAllowBlank(true);
414
 
414
 
415
		lienSelectionlocalite = new Label("");
415
		lienSelectionlocalite = new Label("");
416
 
416
 
417
 
417
 
418
		lienSelectionlocalite.setId("conteneur_selection_localite");
418
		lienSelectionlocalite.setId("conteneur_selection_localite");
419
		lienSelectionlocalite.setStyleName("conteneur_selection_localite");
419
		lienSelectionlocalite.setStyleName("conteneur_selection_localite");
420
		lienSelectionlocalite.addStyleName("lien_actif");
420
		lienSelectionlocalite.addStyleName("lien_actif");
421
 
421
 
422
		// Panneau de type plusieurs champs de formulaire sur une meme ligne, où seront renseignés Lat/Lon
422
		// Panneau de type plusieurs champs de formulaire sur une meme ligne, où seront renseignés Lat/Lon
423
		coordPanel = new MultiFieldPanel();
423
		coordPanel = new MultiFieldPanel();
424
		coordPanel.setPaddings(0, 0, 0, 10);
424
		coordPanel.setPaddings(0, 0, 0, 10);
425
		coordPanel.setVisible(false);
425
		coordPanel.setVisible(false);
426
 
426
 
427
		final double largeur ;
427
		final double largeur ;
428
		largeur = 120;
428
		largeur = 120;
429
 
429
 
430
		coordPanel.addToRow(latitude, new ColumnLayoutData(largeur));
430
		coordPanel.addToRow(latitude, new ColumnLayoutData(largeur));
431
		coordPanel.addToRow(longitude, new ColumnLayoutData(largeur));
431
		coordPanel.addToRow(longitude, new ColumnLayoutData(largeur));
432
		coordPanel.addToRow(lienSelectionlocalite, new ColumnLayoutData(largeur));
432
		coordPanel.addToRow(lienSelectionlocalite, new ColumnLayoutData(largeur));
433
		lienSelectionlocalite.addClass("lien_decale");
433
		lienSelectionlocalite.addClass("lien_decale");
434
		coordPanel.setBorder(false);
434
		coordPanel.setBorder(false);
435
 
435
 
436
		coordPanel.addToRow(altitude, new ColumnLayoutData(largeur));
436
		coordPanel.addToRow(altitude, new ColumnLayoutData(largeur));
437
 
437
 
438
		  //création du champs coordonnées
438
		  //création du champs coordonnées
439
		referentielGeo = Configuration.getReferentielGeo();
439
		referentielGeo = Configuration.getReferentielGeo();
440
 
440
 
441
		coordonnees = new TextField(Msg.get("coordonnees"), "", 0);
441
		coordonnees = new TextField(Msg.get("coordonnees"), "", 0);
442
		coordonnees.setMaxLength(0);
442
		coordonnees.setMaxLength(0);
443
		coordonnees.setReadOnly(true);
443
		coordonnees.setReadOnly(true);
444
		coordonnees.setCls("fieldname");
444
		coordonnees.setCls("fieldname");
445
 
445
 
446
		//création du lien "saisie X/Y" dans le formulaire
446
		//création du lien "saisie X/Y" dans le formulaire
447
		afficherFormulaireLatLon = new HTML("<span style=\"padding-left:30px;\" class=\"conteneur_lien_afficher_lat_lon\">" +
447
		afficherFormulaireLatLon = new HTML("<span style=\"padding-left:30px;\" class=\"conteneur_lien_afficher_lat_lon\">" +
448
				"<a title=\""+Msg.get("indication-formulaire-lat-lon")+"\" class=\"lien_actif\" id=\"lien_coord\" href=\"#\" tabindex=\"6\">"+Msg.get("saisie-lat-lon")+" ("+referentielGeo+")</a>" +
448
				"<a title=\""+Msg.get("indication-formulaire-lat-lon")+"\" class=\"lien_actif\" id=\"lien_coord\" href=\"#\" tabindex=\"6\">"+Msg.get("saisie-lat-lon")+" ("+referentielGeo+")</a>" +
449
				"<span><span style=\"padding-left:20px\" class=\"conteneur_lien_localiser_lat_lon\">"+
449
				"<span><span style=\"padding-left:20px\" class=\"conteneur_lien_localiser_lat_lon\">"+
450
				"<a title=\""+Msg.get("indication-formulaire-localiser")+"\" class=\"lien_actif\" id=\"lien_carto_coord\" href=\"#\" tabindex=\"7\">"+Msg.get("localiser-la-carte")+"</a>"+
450
				"<a title=\""+Msg.get("indication-formulaire-localiser")+"\" class=\"lien_actif\" id=\"lien_carto_coord\" href=\"#\" tabindex=\"7\">"+Msg.get("localiser-la-carte")+"</a>"+
451
				"</span>");
451
				"</span>");
452
 
452
 
453
			//ajout d'un listener sur le lien "saisie X/Y"
453
			//ajout d'un listener sur le lien "saisie X/Y"
454
			coordPanel.addListener(new PanelListenerAdapter() {
454
			coordPanel.addListener(new PanelListenerAdapter() {
455
 
455
 
456
				@Override
456
				@Override
457
				public void onAfterLayout(Container c) {
457
				public void onAfterLayout(Container c) {
458
					surPremierAffichageCoordPanel(largeur);
458
					surPremierAffichageCoordPanel(largeur);
459
				}
459
				}
460
			});
460
			});
461
 
461
 
462
		//Sur une meme ligne, ajout de plusieurs champs
462
		//Sur une meme ligne, ajout de plusieurs champs
463
		final MultiFieldPanel htmlPanel = new MultiFieldPanel();
463
		final MultiFieldPanel htmlPanel = new MultiFieldPanel();
464
 
464
 
465
		htmlPanel.addToRow(coordonnees, 100);
465
		htmlPanel.addToRow(coordonnees, 100);
466
		htmlPanel.addToRow(afficherFormulaireLatLon, new ColumnLayoutData(0.9));
466
		htmlPanel.addToRow(afficherFormulaireLatLon, new ColumnLayoutData(0.9));
467
		htmlPanel.setBorder(false);
467
		htmlPanel.setBorder(false);
468
		htmlPanel.setId("x-coord-panel");
468
		htmlPanel.setId("x-coord-panel");
469
 
469
 
470
		panneauPremierColonne.add(htmlPanel);
470
		panneauPremierColonne.add(htmlPanel);
471
		panneauPremierColonne.add(coordPanel);
471
		panneauPremierColonne.add(coordPanel);
472
 
472
 
473
	    date = new DateField(Msg.get("date"), "date", 250);
473
	    date = new DateField(Msg.get("date"), "date", 250);
474
	    date.setAllowBlank(true);
474
	    date.setAllowBlank(true);
475
	    formatDate = "d/m/Y";
475
	    formatDate = "d/m/Y";
476
	    date.setFormat(formatDate);
476
	    date.setFormat(formatDate);
477
	    date.setTitle(Msg.get("indication-format-date"));
477
	    date.setTitle(Msg.get("indication-format-date"));
478
	    date.setMaxValue(new Date());
478
	    date.setMaxValue(new Date());
479
	    //date.setTabIndex(5);
479
	    //date.setTabIndex(5);
480
	    panneauPremierColonne.add(date, new AnchorLayoutData("55%"));
480
	    panneauPremierColonne.add(date, new AnchorLayoutData("55%"));
481
 
481
 
482
 
482
 
483
	    final String champsListeTpl = "<div class=\"x-combo-list-item search-item-tpl\" title=\"{label}\">{label}</div>";
483
	    final String champsListeTpl = "<div class=\"x-combo-list-item search-item-tpl\" title=\"{label}\">{label}</div>";
484
 
484
 
485
	    // Selection d'un référentiel par défaut (le premier spécifié dans la config)
485
	    // Selection d'un référentiel par défaut (le premier spécifié dans la config)
486
	    referentielTaxo = Configuration.getReferentielsDispos().get(0).getCode();
486
	    referentielTaxo = Configuration.getReferentielsDispos().get(0).getCode();
487
	    selecteurReferentielTaxo = new ComboBox();
487
	    selecteurReferentielTaxo = new ComboBox();
488
	    selecteurReferentielTaxo.setCls("champ-separation");
488
	    selecteurReferentielTaxo.setCls("champ-separation");
489
	    selecteurReferentielTaxo.setLabel(Msg.get("referentiel"));
489
	    selecteurReferentielTaxo.setLabel(Msg.get("referentiel"));
490
	    selecteurReferentielTaxo.setStore(Ontologies.getValeursReferentiel());
490
	    selecteurReferentielTaxo.setStore(Ontologies.getValeursReferentiel());
491
	    selecteurReferentielTaxo.setValue(referentielTaxo);
491
	    selecteurReferentielTaxo.setValue(referentielTaxo);
492
	    selecteurReferentielTaxo.setDisplayField("label") ;
492
	    selecteurReferentielTaxo.setDisplayField("label") ;
493
	    selecteurReferentielTaxo.setValueField("valeur");
493
	    selecteurReferentielTaxo.setValueField("valeur");
494
	    selecteurReferentielTaxo.setEditable(false);
494
	    selecteurReferentielTaxo.setEditable(false);
495
	    selecteurReferentielTaxo.setHideTrigger(false);
495
	    selecteurReferentielTaxo.setHideTrigger(false);
496
	    selecteurReferentielTaxo.setForceSelection(true);
496
	    selecteurReferentielTaxo.setForceSelection(true);
497
	    selecteurReferentielTaxo.setTpl(champsListeTpl);
497
	    selecteurReferentielTaxo.setTpl(champsListeTpl);
498
	    
498
	    
499
		espece = new AutoCompletionComboBox(Msg.get("espece"), ListeReferentielNomAsynchroneDAO.getBaseUrlReferentielNom()) {			
499
		espece = new AutoCompletionComboBox(Msg.get("espece"), ListeReferentielNomAsynchroneDAO.getBaseUrlReferentielNom()) {			
500
			@Override
500
			@Override
501
			protected Map<String, String> parserResultatRequete(Response response) {
501
			protected Map<String, String> parserResultatRequete(Response response) {
502
				// TODO: bien penser à l'unicité des clés, ici on suppose que 
502
				// TODO: bien penser à l'unicité des clés, ici on suppose que 
503
				// genre espèce auteur suffit mais quelquefois on peut avoir des doublons
503
				// genre espèce auteur suffit mais quelquefois on peut avoir des doublons
504
				referentielNom = Util.parserRetourReferentielNomIndexeParNom(response);
504
				referentielNom = Util.parserRetourReferentielNomIndexeParNom(response);
505
				return Util.convertirListeReferentielNomVersMap(referentielNom);
505
				return Util.convertirListeReferentielNomVersMap(referentielNom);
506
			}
506
			}
507
			
507
			
508
			@Override
508
			@Override
509
			public void onSelectionValeur() {
509
			public void onSelectionValeur() {
510
				especeModifiee = true;
510
				especeModifiee = true;
511
				surSelectionEspece();
511
				surSelectionEspece();
512
				verifierPresenceTaxonSaisi();
512
				verifierPresenceTaxonSaisi();
513
			}
513
			}
514
			
514
			
515
			@Override
515
			@Override
516
			protected void onModificationValeur() {
516
			protected void onModificationValeur() {
517
				especeModifiee = true;	
517
				especeModifiee = true;	
518
				// Pour éviter qu'un mauvais nn ne soit gardé lors d'une modification
518
				// Pour éviter qu'un mauvais nn ne soit gardé lors d'une modification
519
				// vers un nom ne faisant pas partie du référentiel
519
				// vers un nom ne faisant pas partie du référentiel
520
				numeroNom = null;
520
				numeroNom = null;
521
				if(referentielNom.containsKey(espece.getText())) {
521
				if(referentielNom.containsKey(espece.getText())) {
522
					numeroNom = referentielNom.get(espece.getText()).getNumeroNom();
522
					numeroNom = referentielNom.get(espece.getText()).getNumeroNom();
523
				}
523
				}
524
				verifierPresenceTaxonSaisi();
524
				verifierPresenceTaxonSaisi();
525
			}
525
			}
526
 
526
 
527
			@Override
527
			@Override
528
			public void onValidationSaisie() {
528
			public void onValidationSaisie() {
529
				validerSaisie(Champs.ESPECE);
529
				validerSaisie(Champs.ESPECE);
530
			}  
530
			}  
531
			
531
			
532
			@Override
532
			@Override
533
			protected String preTraiterUrlRequete(String urlRequete, String valeur) {
533
			protected String preTraiterUrlRequete(String urlRequete, String valeur) {
534
				return ListeReferentielNomAsynchroneDAO.formaterUrlAutoCompletionReferentielNom(urlRequete, referentielTaxo, valeur);
534
				return ListeReferentielNomAsynchroneDAO.formaterUrlAutoCompletionReferentielNom(urlRequete, referentielTaxo, valeur);
535
			}
535
			}
536
			
536
			
537
			@Override
537
			@Override
538
			protected String preTraiterValeurAvantAffichage(String valeur) {
538
			protected String preTraiterValeurAvantAffichage(String valeur) {
539
				ReferentielNom nomValeur = referentielNom.get(valeur);
539
				ReferentielNom nomValeur = referentielNom.get(valeur);
540
				String valeurAffichee = nomValeur.getNom();
540
				String valeurAffichee = nomValeur.getNom();
541
				// Pour afficher les noms retenus en gras
541
				// Pour afficher les noms retenus en gras
542
				if (nomValeur.estRetenu()) {
542
				if (nomValeur.estRetenu()) {
543
					valeurAffichee = "<span class=\"nomRetenu\">"+nomValeur.getNom().trim()+"</span>";
543
					valeurAffichee = "<span class=\"nomRetenu\">"+nomValeur.getNom().trim()+"</span>";
544
				}
544
				}
545
				return valeurAffichee;
545
				return valeurAffichee;
546
			}
546
			}
547
	    };
547
	    };
548
 
548
 
549
	    Panel panelSeparationPp = new Panel();
549
	    Panel panelSeparationPp = new Panel();
550
	    panelSeparationPp.setHeight(15);
550
	    panelSeparationPp.setHeight(15);
551
	    panelSeparationPp.setBorder(false);
551
	    panelSeparationPp.setBorder(false);
552
 
552
 
553
	    panneauPremierColonne.add(panelSeparationPp);
553
	    panneauPremierColonne.add(panelSeparationPp);
554
	    panneauPremierColonne.add(selecteurReferentielTaxo, new AnchorLayoutData("85%"));
554
	    panneauPremierColonne.add(selecteurReferentielTaxo, new AnchorLayoutData("85%"));
555
	    panneauPremierColonne.add(espece, new AnchorLayoutData("95%"));
555
	    panneauPremierColonne.add(espece, new AnchorLayoutData("95%"));
556
 
556
 
557
	    selecteurAbondance = new ComboBox();
557
	    selecteurAbondance = new ComboBox();
558
	    selecteurAbondance.setCls("champ-separation");
558
	    selecteurAbondance.setCls("champ-separation");
559
	    selecteurAbondance.setLabel(Msg.get("abondance"));
559
	    selecteurAbondance.setLabel(Msg.get("abondance"));
560
	    selecteurAbondance.setStore(Ontologies.getValeursAbondance());
560
	    selecteurAbondance.setStore(Ontologies.getValeursAbondance());
561
	    selecteurAbondance.setDisplayField("label") ;
561
	    selecteurAbondance.setDisplayField("label") ;
562
	    selecteurAbondance.setValueField("valeur");
562
	    selecteurAbondance.setValueField("valeur");
563
	    selecteurAbondance.setEditable(true);
563
	    selecteurAbondance.setEditable(true);
564
	    selecteurAbondance.setHideTrigger(false);
564
	    selecteurAbondance.setHideTrigger(false);
565
	    selecteurAbondance.setForceSelection(false);
565
	    selecteurAbondance.setForceSelection(false);
566
	    selecteurAbondance.setTpl(champsListeTpl);
566
	    selecteurAbondance.setTpl(champsListeTpl);
567
	    panneauPremierColonne.add(selecteurAbondance,  new AnchorLayoutData("95%"));
567
	    panneauPremierColonne.add(selecteurAbondance,  new AnchorLayoutData("95%"));
568
	    
568
	    
569
	    lieudit = new AutoCompletionComboBox(Msg.get("lieu-dit"), ListeReferentielPersoAsynchroneDAO.getUrlReferentielPerso(TypesReferentiels.REFERENTIEL_LIEU_DIT)) {			
569
	    lieudit = new AutoCompletionComboBox(Msg.get("lieu-dit"), ListeReferentielPersoAsynchroneDAO.getUrlReferentielPerso(TypesReferentiels.REFERENTIEL_LIEU_DIT)) {			
570
			@Override
570
			@Override
571
			protected Map<String, String> parserResultatRequete(Response response) {
571
			protected Map<String, String> parserResultatRequete(Response response) {
572
				return Util.parserRetourReferentielPerso(response);
572
				return Util.parserRetourReferentielPerso(response);
573
			}
573
			}
574
			
574
			
575
			@Override
575
			@Override
576
			public void onSelectionValeur() {
576
			public void onSelectionValeur() {
577
				lieuDitModifie = true;
577
				lieuDitModifie = true;
578
			}
578
			}
579
			
579
			
580
			@Override
580
			@Override
581
			protected void onModificationValeur() {
581
			protected void onModificationValeur() {
582
				lieuDitModifie = true;	
582
				lieuDitModifie = true;	
583
			}
583
			}
584
 
584
 
585
			@Override
585
			@Override
586
			public void onValidationSaisie() {
586
			public void onValidationSaisie() {
587
				validerSaisie(Champs.LIEUDIT);
587
				validerSaisie(Champs.LIEUDIT);
588
			}  
588
			}  
589
			
589
			
590
			@Override
590
			@Override
591
			protected String preTraiterUrlRequete(String urlRequete, String valeur) {
591
			protected String preTraiterUrlRequete(String urlRequete, String valeur) {
592
				return ListeReferentielPersoAsynchroneDAO.formaterUrlRequeteAutoCompletionPerso(urlRequete, valeur);
592
				return ListeReferentielPersoAsynchroneDAO.formaterUrlRequeteAutoCompletionPerso(urlRequete, valeur);
593
			}
593
			}
594
		};
594
		};
595
	    panneauSecondeColonne.add(lieudit,  new AnchorLayoutData("95%"));
595
	    panneauSecondeColonne.add(lieudit,  new AnchorLayoutData("95%"));
596
	       
596
	       
597
	    milieu = new AutoCompletionComboBox(Msg.get("milieu"), ListeReferentielPersoAsynchroneDAO.getUrlReferentielPerso(TypesReferentiels.REFERENTIEL_MILIEU)) {			
597
	    milieu = new AutoCompletionComboBox(Msg.get("milieu"), ListeReferentielPersoAsynchroneDAO.getUrlReferentielPerso(TypesReferentiels.REFERENTIEL_MILIEU)) {			
598
			@Override
598
			@Override
599
			protected Map<String, String> parserResultatRequete(Response response) {
599
			protected Map<String, String> parserResultatRequete(Response response) {
600
				return Util.parserRetourReferentielPerso(response);
600
				return Util.parserRetourReferentielPerso(response);
601
			}
601
			}
602
			
602
			
603
			@Override
603
			@Override
604
			public void onSelectionValeur() {
604
			public void onSelectionValeur() {
605
				milieuModifie = true;
605
				milieuModifie = true;
606
			}
606
			}
607
			
607
			
608
			@Override
608
			@Override
609
			protected void onModificationValeur() {
609
			protected void onModificationValeur() {
610
				milieuModifie = true;	
610
				milieuModifie = true;	
611
			}
611
			}
612
 
612
 
613
			@Override
613
			@Override
614
			public void onValidationSaisie() {
614
			public void onValidationSaisie() {
615
				validerSaisie(Champs.MILIEU);
615
				validerSaisie(Champs.MILIEU);
616
			}  
616
			}  
617
			
617
			
618
			@Override
618
			@Override
619
			protected String preTraiterUrlRequete(String urlRequete, String valeur) {
619
			protected String preTraiterUrlRequete(String urlRequete, String valeur) {
620
				return ListeReferentielPersoAsynchroneDAO.formaterUrlRequeteAutoCompletionPerso(urlRequete, valeur);
620
				return ListeReferentielPersoAsynchroneDAO.formaterUrlRequeteAutoCompletionPerso(urlRequete, valeur);
621
			}
621
			}
622
	    };
622
	    };
623
	    panneauSecondeColonne.add(milieu,  new AnchorLayoutData("95%"));
623
	    panneauSecondeColonne.add(milieu,  new AnchorLayoutData("95%"));
624
 
624
 
625
	    comment = new TextArea(Msg.get("notes"), "comment");
625
	    comment = new TextArea(Msg.get("notes"), "comment");
626
	    comment.setAllowBlank(true);
626
	    comment.setAllowBlank(true);
627
	    comment.setHeight(50);
627
	    comment.setHeight(50);
628
 
628
 
629
	    panneauSecondeColonne.add(comment, new AnchorLayoutData("95%") );
629
	    panneauSecondeColonne.add(comment, new AnchorLayoutData("95%") );
630
 
630
 
631
	    Panel panelSeparationPs = new Panel();
631
	    Panel panelSeparationPs = new Panel();
632
	    panelSeparationPs.setHeight(39);
632
	    panelSeparationPs.setHeight(39);
633
	    panelSeparationPs.setBorder(false);
633
	    panelSeparationPs.setBorder(false);
634
 
634
 
635
	    panneauSecondeColonne.add(panelSeparationPs);
635
	    panneauSecondeColonne.add(panelSeparationPs);
636
 
636
 
637
	    selecteurCertitude = new ComboBox();
637
	    selecteurCertitude = new ComboBox();
638
	    selecteurCertitude.setLabel(Msg.get("identification"));
638
	    selecteurCertitude.setLabel(Msg.get("identification"));
639
	    selecteurCertitude.setStore(Ontologies.getValeursCertitude());
639
	    selecteurCertitude.setStore(Ontologies.getValeursCertitude());
640
	    selecteurCertitude.setDisplayField("label") ;
640
	    selecteurCertitude.setDisplayField("label") ;
641
	    selecteurCertitude.setValueField("valeur");
641
	    selecteurCertitude.setValueField("valeur");
642
	    selecteurCertitude.setEditable(true);
642
	    selecteurCertitude.setEditable(true);
643
	    selecteurCertitude.setHideTrigger(false);
643
	    selecteurCertitude.setHideTrigger(false);
644
	    selecteurCertitude.setForceSelection(false);
644
	    selecteurCertitude.setForceSelection(false);
645
	    selecteurCertitude.setTpl(champsListeTpl);
645
	    selecteurCertitude.setTpl(champsListeTpl);
646
	    panneauSecondeColonne.add(selecteurCertitude, new AnchorLayoutData("95%"));
646
	    panneauSecondeColonne.add(selecteurCertitude, new AnchorLayoutData("95%"));
647
 
647
 
648
	    selecteurStadePheno = new ComboBox();
648
	    selecteurStadePheno = new ComboBox();
649
	    selecteurStadePheno.setLabel(Msg.get("phenologie"));
649
	    selecteurStadePheno.setLabel(Msg.get("phenologie"));
650
	    selecteurStadePheno.setStore(Ontologies.getValeursPhenologie());
650
	    selecteurStadePheno.setStore(Ontologies.getValeursPhenologie());
651
	    selecteurStadePheno.setDisplayField("label") ;
651
	    selecteurStadePheno.setDisplayField("label") ;
652
	    selecteurStadePheno.setValueField("valeur");
652
	    selecteurStadePheno.setValueField("valeur");
653
	    selecteurStadePheno.setEditable(true);
653
	    selecteurStadePheno.setEditable(true);
654
	    selecteurStadePheno.setHideTrigger(false);
654
	    selecteurStadePheno.setHideTrigger(false);
655
	    selecteurStadePheno.setForceSelection(false);
655
	    selecteurStadePheno.setForceSelection(false);
656
	    selecteurStadePheno.setTpl(champsListeTpl);
656
	    selecteurStadePheno.setTpl(champsListeTpl);
657
	    panneauSecondeColonne.add(selecteurStadePheno, new AnchorLayoutData("95%"));
657
	    panneauSecondeColonne.add(selecteurStadePheno, new AnchorLayoutData("95%"));
658
 
658
 
659
	    if (Window.getClientWidth() > Window.getClientHeight() || Window.getClientWidth() < 800) {
659
	    if (Window.getClientWidth() > Window.getClientHeight() || Window.getClientWidth() < 800) {
660
			panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
660
			panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
661
			panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
661
			panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
662
	    }
662
	    }
663
	    else {
663
	    else {
664
			panneauIntermediaire.add(panneauPremierColonne);
664
			panneauIntermediaire.add(panneauPremierColonne);
665
			panneauIntermediaire.add(panneauSecondeColonne);   
665
			panneauIntermediaire.add(panneauSecondeColonne);   
666
	    }
666
	    }
667
 
667
 
668
		panneauFormulaire.add(panneauIntermediaire);
668
		panneauFormulaire.add(panneauIntermediaire);
669
		
669
		
670
		if (Ext.isIE()) {
670
		if (Ext.isIE()) {
671
			panneauPremierColonne.setButtonAlign(Position.RIGHT);
671
			panneauPremierColonne.setButtonAlign(Position.RIGHT);
672
			panneauPremierColonne.addButton(boutonOK);
672
			panneauPremierColonne.addButton(boutonOK);
673
			panneauPremierColonne.addButton(boutonModifier);
673
			panneauPremierColonne.addButton(boutonModifier);
674
			panneauPremierColonne.addButton(boutonSupprimer);
674
			panneauPremierColonne.addButton(boutonSupprimer);
675
			panneauSecondeColonne.setButtonAlign(Position.LEFT);
675
			panneauSecondeColonne.setButtonAlign(Position.LEFT);
676
			panneauPremierColonne.addButton(boutonReinitialiser);
676
			panneauPremierColonne.addButton(boutonReinitialiser);
677
		}
677
		}
678
		else {
678
		else {
679
			panneauFormulaire.addButton(boutonOK);
679
			panneauFormulaire.addButton(boutonOK);
680
			panneauFormulaire.addButton(boutonModifier);
680
			panneauFormulaire.addButton(boutonModifier);
681
			panneauFormulaire.addButton(boutonSupprimer);
681
			panneauFormulaire.addButton(boutonSupprimer);
682
			panneauFormulaire.addButton(boutonReinitialiser);
682
			panneauFormulaire.addButton(boutonReinitialiser);
683
		}
683
		}
684
 
684
 
685
		this.add(panneauFormulaire) ;
685
		this.add(panneauFormulaire) ;
686
 
686
 
687
		this.setAutoScroll(true);
687
		this.setAutoScroll(true);
688
 
688
 
689
 
689
 
690
		panneauFormulaire.addListener(new PanelListenerAdapter() {
690
		panneauFormulaire.addListener(new PanelListenerAdapter() {
691
	        @Override
691
	        @Override
692
			public void onResize(BoxComponent component, int adjWidth, int adjHeight, int rawWidth, int rawHeight) {
692
			public void onResize(BoxComponent component, int adjWidth, int adjHeight, int rawWidth, int rawHeight) {
693
	        	panneauIntermediaire.setWidth(rawWidth);
693
	        	panneauIntermediaire.setWidth(rawWidth);
694
	        	panneauIntermediaire.setHeight(rawHeight);
694
	        	panneauIntermediaire.setHeight(rawHeight);
695
	        
695
	        
696
	        	panneauPremierColonne.doLayout();
696
	        	panneauPremierColonne.doLayout();
697
	        	panneauSecondeColonne.doLayout();
697
	        	panneauSecondeColonne.doLayout();
698
	        		        
698
	        		        
699
	        	htmllocalitePanel.doLayout();
699
	        	htmllocalitePanel.doLayout();
700
	        	htmlPanel.doLayout();
700
	        	htmlPanel.doLayout();
701
	        	
701
	        	
702
				redimensionnerChampsEtendus();
702
				redimensionnerChampsEtendus();
703
	        
703
	        
704
	        	doLayout();
704
	        	doLayout();
705
	        }
705
	        }
706
	    });
706
	    });
707
 
707
 
708
		lienAfficherChampsEtendus = new HTML(Msg.get("afficher-champs-etendus"));
708
		lienAfficherChampsEtendus = new HTML(Msg.get("afficher-champs-etendus"));
709
		lienAfficherChampsEtendus.setStyleName("img-curseur-depl");
709
		lienAfficherChampsEtendus.setStyleName("img-curseur-depl");
710
		lienAfficherChampsEtendus.setStyleName("lienAfficherChampsEtendus");
710
		lienAfficherChampsEtendus.setStyleName("lienAfficherChampsEtendus");
711
		lienAfficherChampsEtendus.setVisible(false);
711
		lienAfficherChampsEtendus.setVisible(false);
712
 
712
 
713
		lienAfficherChampsEtendus.addClickHandler(new ClickHandler() {
713
		lienAfficherChampsEtendus.addClickHandler(new ClickHandler() {
714
			@Override
714
			@Override
715
			public void onClick(ClickEvent event) {
715
			public void onClick(ClickEvent event) {
716
				if(afficherChampsEtendus) {
716
				if(afficherChampsEtendus) {
717
					afficherChampsEtendus = false;
717
					afficherChampsEtendus = false;
718
					if(conteneurChampEtenduGauche != null && conteneurChampEtenduDroite != null) {
718
					if(conteneurChampEtenduGauche != null && conteneurChampEtenduDroite != null) {
719
						conteneurChampEtenduGauche.hide();
719
						conteneurChampEtenduGauche.hide();
720
						conteneurChampEtenduDroite.hide();
720
						conteneurChampEtenduDroite.hide();
721
					}
721
					}
722
					lienAfficherChampsEtendus.setText(Msg.get("afficher-champs-etendus"));
722
					lienAfficherChampsEtendus.setText(Msg.get("afficher-champs-etendus"));
723
 
723
 
724
				} else {
724
				} else {
725
					afficherChampsEtendus = true;
725
					afficherChampsEtendus = true;
726
					if(conteneurChampEtenduGauche != null && conteneurChampEtenduDroite != null) {
726
					if(conteneurChampEtenduGauche != null && conteneurChampEtenduDroite != null) {
727
						conteneurChampEtenduGauche.show();
727
						conteneurChampEtenduGauche.show();
728
						conteneurChampEtenduDroite.show();
728
						conteneurChampEtenduDroite.show();
729
						redimensionnerChampsEtendus();
729
						redimensionnerChampsEtendus();
730
					}
730
					}
731
					lienAfficherChampsEtendus.setText(Msg.get("cacher-champs-etendus"));
731
					lienAfficherChampsEtendus.setText(Msg.get("cacher-champs-etendus"));
732
				}
732
				}
733
			}
733
			}
734
		});
734
		});
735
		
735
		
736
		if(Configuration.saisieChampsEtendusActivee()) {
736
		if(Configuration.saisieChampsEtendusActivee()) {
737
			// Chargement du cache des correspondances cles/labels du catalogue
737
			// Chargement du cache des correspondances cles/labels du catalogue
738
			ListeReferentielChampsEtendusDAO lrceDao = new ListeReferentielChampsEtendusDAO(null);
738
			ListeReferentielChampsEtendusDAO lrceDao = new ListeReferentielChampsEtendusDAO(null);
739
			lrceDao.obtenirGroupesChampsEtendus(this);
739
			lrceDao.obtenirGroupesChampsEtendus(this);
740
			lrceDao.obtenirCatalogueChampsEtendus(this);
740
			lrceDao.obtenirCatalogueChampsEtendus(this);
741
			
741
			
742
			lienAjouterChampsEtendus = new HTML(Msg.get("ajouter-champ-etendu"));
742
			lienAjouterChampsEtendus = new HTML(Msg.get("ajouter-champ-etendu"));
743
			lienAjouterChampsEtendus.addStyleName("lienAjouterChampEtendu");
743
			lienAjouterChampsEtendus.addStyleName("lienAjouterChampEtendu");
744
			lienAjouterChampsEtendus.setVisible(true);
744
			lienAjouterChampsEtendus.setVisible(true);
745
			panneauPremierColonne.add(lienAjouterChampsEtendus);
745
			panneauPremierColonne.add(lienAjouterChampsEtendus);
746
			gererLienAjoutChampsEtendus();
746
			gererLienAjoutChampsEtendus();
747
		}
747
		}
748
		
748
		
749
		panneauPremierColonne.add(lienAfficherChampsEtendus);
749
		panneauPremierColonne.add(lienAfficherChampsEtendus);
750
		panneauPremierColonne.addListener(new PanelListenerAdapter() {
750
		panneauPremierColonne.addListener(new PanelListenerAdapter() {
751
			@Override
751
			@Override
752
			public void onAfterLayout(Container c) {
752
			public void onAfterLayout(Container c) {
753
				if(premierAffichage) {
753
				if(premierAffichage) {
754
					lienAfficherChampsEtendus.setVisible(false);
754
					lienAfficherChampsEtendus.setVisible(false);
755
					premierAffichage = false;
755
					premierAffichage = false;
756
				}
756
				}
757
			}
757
			}
758
		});
758
		});
759
 
759
 
760
		ajouterListeners() ;
760
		ajouterListeners() ;
761
		ajouterToolTipsBoutons();
761
		ajouterToolTipsBoutons();
762
		saisieTabindex();
762
		saisieTabindex();
763
	}
763
	}
764
	
764
	
765
	protected void surSelectionEspece() {
765
	protected void surSelectionEspece() {
766
		ReferentielNom nom = referentielNom.get(espece.getText());
766
		ReferentielNom nom = referentielNom.get(espece.getText());
767
		numeroNom = nom.getNumeroNom();
767
		numeroNom = nom.getNumeroNom();
768
		selectionEspece = true;
768
		selectionEspece = true;
769
		observationMediateur.obtenirImageInformationExternes(referentielTaxo, numeroNom);
769
		observationMediateur.obtenirImageInformationExternes(referentielTaxo, numeroNom);
770
	}
770
	}
771
	
771
	
772
	protected void surSelectionLocalite() {
772
	protected void surSelectionLocalite() {
773
		ReferentielLocalite infosLoc = referentielLocalite.get(localite.getText());
773
		ReferentielLocalite infosLoc = referentielLocalite.get(localite.getText());
774
        codeLocalite = infosLoc.getCodeLocalite();
774
        codeLocalite = infosLoc.getCodeLocalite();
775
        selectionlocalite=true;
775
        selectionlocalite=true;
776
	}
776
	}
777
 
777
 
778
	private void gererLienAjoutChampsEtendus() {	
778
	private void gererLienAjoutChampsEtendus() {	
779
		popUpAjoutChampEtendu.setStylePrimaryName("popup_champ_etendu");
779
		popUpAjoutChampEtendu.setStylePrimaryName("popup_champ_etendu");
780
		lienAjouterChampsEtendus.addClickHandler(new ClickHandler() {
780
		lienAjouterChampsEtendus.addClickHandler(new ClickHandler() {
781
			@Override
781
			@Override
782
			public void onClick(ClickEvent event) {
782
			public void onClick(ClickEvent event) {
783
				FormulaireSaisieChampEtendu formChamp = new FormulaireSaisieChampEtendu() {	
783
				FormulaireSaisieChampEtendu formChamp = new FormulaireSaisieChampEtendu() {	
784
					
784
					
785
					@Override
785
					@Override
786
					public void surValidation(ChampSaisieEtendu champ) {
786
					public void surValidation(ChampSaisieEtendu champ) {
787
						ajouterChampEtenduAuFormulaire(champ, true);
787
						ajouterChampEtenduAuFormulaire(champ, true);
788
						popUpAjoutChampEtendu.clear();
788
						popUpAjoutChampEtendu.clear();
789
						popUpAjoutChampEtendu.hide();
789
						popUpAjoutChampEtendu.hide();
790
					}
790
					}
791
					
791
					
792
					@Override
792
					@Override
793
					public void surAjout(ChampSaisieEtendu champ) {
793
					public void surAjout(ChampSaisieEtendu champ) {
794
						ajouterChampEtenduAuFormulaire(champ, false);
794
						ajouterChampEtenduAuFormulaire(champ, false);
795
					}
795
					}
796
 
796
 
797
					@Override
797
					@Override
798
					public void surAnnulation() {
798
					public void surAnnulation() {
799
						popUpAjoutChampEtendu.clear();
799
						popUpAjoutChampEtendu.clear();
800
						popUpAjoutChampEtendu.hide();
800
						popUpAjoutChampEtendu.hide();
801
					}
801
					}
802
 
802
 
803
					@Override
803
					@Override
804
					public void surAjoutMultiple(List<ChampSaisieEtendu> champs) {
804
					public void surAjoutMultiple(List<ChampSaisieEtendu> champs) {
805
						for (Iterator<ChampSaisieEtendu> iterator = champs.iterator(); iterator.hasNext();) {
805
						for (Iterator<ChampSaisieEtendu> iterator = champs.iterator(); iterator.hasNext();) {
806
							ChampSaisieEtendu champSaisieEtendu = (ChampSaisieEtendu) iterator.next();
806
							ChampSaisieEtendu champSaisieEtendu = (ChampSaisieEtendu) iterator.next();
807
							ajouterChampEtenduAuFormulaire(champSaisieEtendu, false);
807
							ajouterChampEtenduAuFormulaire(champSaisieEtendu, false);
808
						}
808
						}
809
					}
809
					}
810
 
810
 
811
					@Override
811
					@Override
812
					public void surValidationMultiple(List<ChampSaisieEtendu> champs) {
812
					public void surValidationMultiple(List<ChampSaisieEtendu> champs) {
813
						for (Iterator<ChampSaisieEtendu> iterator = champs.iterator(); iterator.hasNext();) {
813
						for (Iterator<ChampSaisieEtendu> iterator = champs.iterator(); iterator.hasNext();) {
814
							ChampSaisieEtendu champSaisieEtendu = (ChampSaisieEtendu) iterator.next();
814
							ChampSaisieEtendu champSaisieEtendu = (ChampSaisieEtendu) iterator.next();
815
							ajouterChampEtenduAuFormulaire(champSaisieEtendu, false);
815
							ajouterChampEtenduAuFormulaire(champSaisieEtendu, false);
816
						}
816
						}
817
						popUpAjoutChampEtendu.clear();
817
						popUpAjoutChampEtendu.clear();
818
						popUpAjoutChampEtendu.hide();
818
						popUpAjoutChampEtendu.hide();
819
					}
819
					}
820
				};
820
				};
821
				popUpAjoutChampEtendu.add(formChamp);
821
				popUpAjoutChampEtendu.add(formChamp);
822
				popUpAjoutChampEtendu.center();		
822
				popUpAjoutChampEtendu.center();		
823
				popUpAjoutChampEtendu.setModal(true);
823
				popUpAjoutChampEtendu.setModal(true);
824
				popUpAjoutChampEtendu.show();
824
				popUpAjoutChampEtendu.show();
825
				formChamp.redimensionner(popUpAjoutChampEtendu.getOffsetWidth() - 13);
825
				formChamp.redimensionner(popUpAjoutChampEtendu.getOffsetWidth() - 13);
826
			}
826
			}
827
		});
827
		});
828
	}
828
	}
829
	
829
	
830
	private void ajouterChampEtenduAuFormulaire(ChampSaisieEtendu nChamp, boolean fermerPopup) {
830
	private void ajouterChampEtenduAuFormulaire(ChampSaisieEtendu nChamp, boolean fermerPopup) {
831
		ChampEtendu chet = new ChampEtendu(nChamp.getCle(), nChamp.getLabel(), "");
831
		ChampEtendu chet = new ChampEtendu(nChamp.getCle(), nChamp.getLabel(), "");
832
		Map<String, ChampEtendu> champsEt = getValeursChampsEtendus();
832
		Map<String, ChampEtendu> champsEt = getValeursChampsEtendus();
833
		if(!champsEt.containsKey(chet.getCle())) {
833
		if(!champsEt.containsKey(chet.getCle())) {
834
			champsEt.put(chet.getCle(), chet);
834
			champsEt.put(chet.getCle(), chet);
835
			afficherChampsEtendus = true;
835
			afficherChampsEtendus = true;
836
			if(fermerPopup) {
836
			if(fermerPopup) {
837
				afficherChampsEtendus(champsEt, chet);
837
				afficherChampsEtendus(champsEt, chet);
838
				popUpAjoutChampEtendu.clear();
838
				popUpAjoutChampEtendu.clear();
839
				popUpAjoutChampEtendu.hide();
839
				popUpAjoutChampEtendu.hide();
840
			} else {
840
			} else {
841
				afficherChampsEtendus(champsEt, null);
841
				afficherChampsEtendus(champsEt, null);
842
			}
842
			}
843
		} else {
843
		} else {
844
			String[] stParams = {chet.getLabel()};
844
			String[] stParams = {chet.getLabel()};
845
			Window.alert(Msg.get("indication-champ-etendu-existe-deja", stParams));
845
			Window.alert(Msg.get("indication-champ-etendu-existe-deja", stParams));
846
		}
846
		}
847
	}
847
	}
848
 
848
 
849
	private void ajouterToolTipsBoutons() {
849
	private void ajouterToolTipsBoutons() {
850
		boutonOK.setTitle(Msg.get("indication-bouton-creer-obs"));
850
		boutonOK.setTitle(Msg.get("indication-bouton-creer-obs"));
851
		boutonModifier.setTitle(Msg.get("indication-bouton-modifier-obs"));
851
		boutonModifier.setTitle(Msg.get("indication-bouton-modifier-obs"));
852
		boutonSupprimer.setTitle(Msg.get("indication-bouton-supprimer-obs"));
852
		boutonSupprimer.setTitle(Msg.get("indication-bouton-supprimer-obs"));
853
		boutonReinitialiser.setTitle(Msg.get("indication-bouton-reinitialiser-obs"));
853
		boutonReinitialiser.setTitle(Msg.get("indication-bouton-reinitialiser-obs"));
854
	}
854
	}
855
 
855
 
856
	private void surPremierAffichageCoordPanel(final double largeur) {
856
	private void surPremierAffichageCoordPanel(final double largeur) {
857
		ExtElement lienCoord = Ext.get("lien_coord");
857
		ExtElement lienCoord = Ext.get("lien_coord");
858
		lienCoord.removeAllListeners();
858
		lienCoord.removeAllListeners();
859
		lienCoord.addListener("click", new EventCallback() {
859
		lienCoord.addListener("click", new EventCallback() {
860
			@Override
860
			@Override
861
			public void execute(EventObject e) {
861
			public void execute(EventObject e) {
862
 
862
 
863
				coordPanel.setVisible(!coordPanel.isVisible());
863
				coordPanel.setVisible(!coordPanel.isVisible());
864
 
864
 
865
				if(Ext.isIE()) {
865
				if(Ext.isIE()) {
866
					latitude.focus();
866
					latitude.focus();
867
				}
867
				}
868
 
868
 
869
				CarnetEnLigneMediateur.fireResize();
869
				CarnetEnLigneMediateur.fireResize();
870
			}
870
			}
871
		}) ;
871
		}) ;
872
 
872
 
873
		ExtElement lienCartoCoord = Ext.get("lien_carto_coord");
873
		ExtElement lienCartoCoord = Ext.get("lien_carto_coord");
874
		lienCartoCoord.removeAllListeners();
874
		lienCartoCoord.removeAllListeners();
875
		lienCartoCoord.addListener("click", new EventCallback() {
875
		lienCartoCoord.addListener("click", new EventCallback() {
876
			@Override
876
			@Override
877
			public void execute(EventObject e) {
877
			public void execute(EventObject e) {
878
				obtenirInformationCoord();
878
				obtenirInformationCoord();
879
			}
879
			}
880
		}) ;
880
		}) ;
881
 
881
 
882
		ExtElement lienCarto = Ext.get("lien_carto");
882
		ExtElement lienCarto = Ext.get("lien_carto");
883
		lienCarto.removeAllListeners();
883
		lienCarto.removeAllListeners();
884
		lienCarto.addListener("click", new EventCallback() {
884
		lienCarto.addListener("click", new EventCallback() {
885
 
885
 
886
			@Override
886
			@Override
887
			public void execute(EventObject e) {
887
			public void execute(EventObject e) {
888
 
888
 
889
				if(localite.getText() != null && !localite.getText().equals("")) {
889
				if(localite.getText() != null && !localite.getText().equals("")) {
890
					obtenirInformationLocalite();
890
					obtenirInformationLocalite();
891
					longlatAjoutee = true;
891
					longlatAjoutee = true;
892
				} else {
892
				} else {
893
					Window.alert(Msg.get("indication-localite-vide-invalide"));
893
					Window.alert(Msg.get("indication-localite-vide-invalide"));
894
				}
894
				}
895
			}
895
			}
896
		});
896
		});
897
 
897
 
898
		if(!Ext.isIE() && Window.getClientWidth() < 1200) {
898
		if(!Ext.isIE() && Window.getClientWidth() < 1200) {
899
 
899
 
900
			int largeurN = (int)largeur;
900
			int largeurN = (int)largeur;
901
 
901
 
902
			latitude.setWidth(largeurN+"px");
902
			latitude.setWidth(largeurN+"px");
903
			longitude.setWidth(largeurN+"px");
903
			longitude.setWidth(largeurN+"px");
904
			lienSelectionlocalite.setWidth(largeurN+"px");
904
			lienSelectionlocalite.setWidth(largeurN+"px");
905
		}
905
		}
906
	}
906
	}
907
 
907
 
908
	private void ajouterListeners()
908
	private void ajouterListeners()
909
	{
909
	{
910
		// Listener completion communne
910
		// Listener completion communne
911
		final Rafraichissable r = this;
911
		final Rafraichissable r = this;
912
		  
912
		  
913
		ListenerConfig listenerConfiglocalite=new ListenerConfig();
913
		ListenerConfig listenerConfiglocalite=new ListenerConfig();
914
		listenerConfiglocalite.setDelay(200);
914
		listenerConfiglocalite.setDelay(200);
915
		listenerConfiglocalite.setStopPropagation(false);
915
		listenerConfiglocalite.setStopPropagation(false);
916
		listenerConfiglocalite.setStopEvent(false);
916
		listenerConfiglocalite.setStopEvent(false);
917
 
917
 
918
	    date.addListener(new DatePickerListenerAdapter() {
918
	    date.addListener(new DatePickerListenerAdapter() {
919
 
919
 
920
			@Override
920
			@Override
921
			public void onSelect(DatePicker dataPicker, Date date) {
921
			public void onSelect(DatePicker dataPicker, Date date) {
922
				dateModifiee = true;
922
				dateModifiee = true;
923
			}
923
			}
924
	    });
924
	    });
925
 
925
 
926
	    ListenerConfig listenerConfigAutocompletion=new ListenerConfig();
926
	    ListenerConfig listenerConfigAutocompletion=new ListenerConfig();
927
	    listenerConfigAutocompletion.setDelay(200);
927
	    listenerConfigAutocompletion.setDelay(200);
928
	    listenerConfigAutocompletion.setStopPropagation(false);
928
	    listenerConfigAutocompletion.setStopPropagation(false);
929
	    listenerConfigAutocompletion.setStopEvent(false);
929
	    listenerConfigAutocompletion.setStopEvent(false);
930
 
930
 
931
		ListenerConfig listenerConfigEspece=new ListenerConfig();
931
		ListenerConfig listenerConfigEspece=new ListenerConfig();
932
		listenerConfigEspece.setDelay(10);
932
		listenerConfigEspece.setDelay(10);
933
		listenerConfigEspece.setStopPropagation(false);
933
		listenerConfigEspece.setStopPropagation(false);
934
		listenerConfigEspece.setStopEvent(false);
934
		listenerConfigEspece.setStopEvent(false);
935
 
935
 
936
		tCoord = new Timer() {
936
		tCoord = new Timer() {
937
 
937
 
938
			@Override
938
			@Override
939
			public void run() {
939
			public void run() {
940
	        	double[] coord = coordonneesValides();
940
	        	double[] coord = coordonneesValides();
941
	        	if(!recherchelocaliteEnCours && coord != null && (longModifiee || latModifiee)) {
941
	        	if(!recherchelocaliteEnCours && coord != null && (longModifiee || latModifiee)) {
942
	        		recherchelocaliteEnCours = true;
942
	        		recherchelocaliteEnCours = true;
943
	        		Ext.get(lienSelectionlocalite.getElement()).mask(Msg.get("recherche"));
943
	        		Ext.get(lienSelectionlocalite.getElement()).mask(Msg.get("recherche"));
944
	        		observationMediateur.obtenirInformationCoord(r,coord[0], coord[1]);
944
	        		observationMediateur.obtenirInformationCoord(r,coord[0], coord[1]);
945
	        	}
945
	        	}
946
			}
946
			}
947
 
947
 
948
		};
948
		};
949
 
949
 
950
	    ajouterListenerChampEvenementsClavier(date);
950
	    ajouterListenerChampEvenementsClavier(date);
951
		ajouterListenerChampEvenementsClavier(selecteurReferentielTaxo);
951
		ajouterListenerChampEvenementsClavier(selecteurReferentielTaxo);
952
		ajouterListenerChampEvenementsClavier(comment);
952
		ajouterListenerChampEvenementsClavier(comment);
953
		ajouterListenerChampEvenementsClavier(latitude);
953
		ajouterListenerChampEvenementsClavier(latitude);
954
		ajouterListenerChampEvenementsClavier(longitude);
954
		ajouterListenerChampEvenementsClavier(longitude);
955
		ajouterListenerChampEvenementsClavier(altitude);
955
		ajouterListenerChampEvenementsClavier(altitude);
956
		ajouterListenerChampEvenementsClavier(selecteurAbondance);
956
		ajouterListenerChampEvenementsClavier(selecteurAbondance);
957
		ajouterListenerChampEvenementsClavier(selecteurCertitude);
957
		ajouterListenerChampEvenementsClavier(selecteurCertitude);
958
		ajouterListenerChampEvenementsClavier(selecteurStadePheno);
958
		ajouterListenerChampEvenementsClavier(selecteurStadePheno);
959
		ajouterListenerChampsCombobox();
959
		ajouterListenerChampsCombobox();
960
 
960
 
961
		boutonOK.addListener(new ButtonListenerAdapter() {
961
		boutonOK.addListener(new ButtonListenerAdapter() {
962
			@Override
962
			@Override
963
			public void onClick(Button button, EventObject e) {
963
			public void onClick(Button button, EventObject e) {
964
				ajouterObservation();
964
				ajouterObservation();
965
			}
965
			}
966
		});
966
		});
967
 
967
 
968
		boutonModifier.addListener(new ButtonListenerAdapter() {
968
		boutonModifier.addListener(new ButtonListenerAdapter() {
969
			@Override
969
			@Override
970
			public void onClick(Button button, EventObject e) {
970
			public void onClick(Button button, EventObject e) {
971
				if(selectionMultiple) {
971
				if(selectionMultiple) {
972
					modifierObservationEnMasse();
972
					modifierObservationEnMasse();
973
				} else {
973
				} else {
974
					modifierObservation() ;
974
					modifierObservation() ;
975
				}
975
				}
976
			}
976
			}
977
		});
977
		});
978
 
978
 
979
		boutonSupprimer.addListener(new ButtonListenerAdapter() {
979
		boutonSupprimer.addListener(new ButtonListenerAdapter() {
980
			@Override
980
			@Override
981
			public void onClick(Button button, EventObject e) {
981
			public void onClick(Button button, EventObject e) {
982
				if(!selectionMultiple) {
982
				if(!selectionMultiple) {
983
					supprimerObservation();
983
					supprimerObservation();
984
				} else {
984
				} else {
985
					observationMediateur.supprimerObservations();
985
					observationMediateur.supprimerObservations();
986
				}
986
				}
987
			}
987
			}
988
		});
988
		});
989
 
989
 
990
		boutonReinitialiser.addListener(new ButtonListenerAdapter() {
990
		boutonReinitialiser.addListener(new ButtonListenerAdapter() {
991
			@Override
991
			@Override
992
			public void onClick(Button button, EventObject e) {
992
			public void onClick(Button button, EventObject e) {
993
					setSelectionMultiple(false);
993
					setSelectionMultiple(false);
994
					raz();
994
					raz();
995
			}
995
			}
996
		});
996
		});
997
 
997
 
998
		this.addListener(new ContainerListenerAdapter() {
998
		this.addListener(new ContainerListenerAdapter() {
999
			@Override
999
			@Override
1000
			public void onAfterLayout(Container self) {
1000
			public void onAfterLayout(Container self) {
1001
				localite.focus();
1001
				localite.focus();
1002
			}
1002
			}
1003
		});
1003
		});
1004
	}
1004
	}
1005
 
1005
 
1006
	private void ajouterListenerChampsCombobox() {
1006
	private void ajouterListenerChampsCombobox() {
1007
		selecteurReferentielTaxo.addListener(new ComboBoxListenerAdapter() {
1007
		selecteurReferentielTaxo.addListener(new ComboBoxListenerAdapter() {
1008
             @Override
1008
             @Override
1009
			public void onSelect(ComboBox comboBox, Record record, int index) {
1009
			public void onSelect(ComboBox comboBox, Record record, int index) {
1010
            	 referentielTaxo = record.getAsString("valeur");
1010
            	 referentielTaxo = record.getAsString("valeur");
1011
                 observationMediateur.setRefTaxSelectionne(index);
1011
                 observationMediateur.setRefTaxSelectionne(index);
1012
                 referentielTaxoModifie = true;
1012
                 referentielTaxoModifie = true;
1013
             }
1013
             }
1014
         });
1014
         });
1015
 
1015
 
1016
		selecteurAbondance.addListener(new ComboBoxListenerAdapter() {
1016
		selecteurAbondance.addListener(new ComboBoxListenerAdapter() {
1017
			@Override
1017
			@Override
1018
			public void onSelect(ComboBox comboBox, Record record, int index) {
1018
			public void onSelect(ComboBox comboBox, Record record, int index) {
1019
                 selectionAbondance=true;
1019
                 selectionAbondance=true;
1020
                 abondanceModifiee = true;
1020
                 abondanceModifiee = true;
1021
             }
1021
             }
1022
         });
1022
         });
1023
 
1023
 
1024
		selecteurCertitude.addListener(new ComboBoxListenerAdapter() {
1024
		selecteurCertitude.addListener(new ComboBoxListenerAdapter() {
1025
 
1025
 
1026
			@Override
1026
			@Override
1027
			public void onSelect(ComboBox comboBox, Record record, int index) {
1027
			public void onSelect(ComboBox comboBox, Record record, int index) {
1028
                 selectionCertitude=true;
1028
                 selectionCertitude=true;
1029
                 certitudeModifiee = true;
1029
                 certitudeModifiee = true;
1030
             }
1030
             }
1031
         });
1031
         });
1032
 
1032
 
1033
		selecteurStadePheno.addListener(new ComboBoxListenerAdapter() {
1033
		selecteurStadePheno.addListener(new ComboBoxListenerAdapter() {
1034
			@Override
1034
			@Override
1035
			public void onSelect(ComboBox comboBox, Record record, int index) {
1035
			public void onSelect(ComboBox comboBox, Record record, int index) {
1036
                 selectionPhenologie=true;
1036
                 selectionPhenologie=true;
1037
                 phenologieModifiee = true;
1037
                 phenologieModifiee = true;
1038
             }
1038
             }
1039
         });
1039
         });
1040
	}
1040
	}
1041
 
1041
 
1042
	private void ajouterListenerChampEvenementsClavier(final TextField champ) {
1042
	private void ajouterListenerChampEvenementsClavier(final TextField champ) {
1043
		champ.addKeyPressListener(new EventCallback() {
1043
		champ.addKeyPressListener(new EventCallback() {
1044
			@Override
1044
			@Override
1045
			public void execute(EventObject e) {
1045
			public void execute(EventObject e) {
1046
				surEvenementClavier(e, champ);
1046
				surEvenementClavier(e, champ);
1047
			}
1047
			}
1048
	    });
1048
	    });
1049
	}
1049
	}
1050
 
1050
 
1051
	private void ajouterListenerChampEvenementsClavier(final TextField champ, final ListenerConfig config) {
1051
	private void ajouterListenerChampEvenementsClavier(final TextField champ, final ListenerConfig config) {
1052
		champ.addKeyPressListener(new EventCallback() {
1052
		champ.addKeyPressListener(new EventCallback() {
1053
			@Override
1053
			@Override
1054
			public void execute(EventObject e) {
1054
			public void execute(EventObject e) {
1055
				surEvenementClavier(e, champ);
1055
				surEvenementClavier(e, champ);
1056
			}
1056
			}
1057
	    }, config);
1057
	    }, config);
1058
	}
1058
	}
1059
 
1059
 
1060
	private void surEvenementClavier(EventObject e, TextField champ) {
1060
	private void surEvenementClavier(EventObject e, TextField champ) {
1061
		switch(e.getKey()) {
1061
		switch(e.getKey()) {
1062
			case KEY_ALT:
1062
			case KEY_ALT:
1063
			case KEY_CTRL:
1063
			case KEY_CTRL:
1064
			case KEY_DOWN:
1064
			case KEY_DOWN:
1065
			case KEY_END:
1065
			case KEY_END:
1066
			case KEY_ESCAPE:
1066
			case KEY_ESCAPE:
1067
			case KEY_HOME:
1067
			case KEY_HOME:
1068
			case KEY_LEFT:
1068
			case KEY_LEFT:
1069
			case KEY_PAGEDOWN:
1069
			case KEY_PAGEDOWN:
1070
			case KEY_PAGEUP:
1070
			case KEY_PAGEUP:
1071
			case KEY_RIGHT:
1071
			case KEY_RIGHT:
1072
			case KEY_SHIFT:
1072
			case KEY_SHIFT:
1073
			case KEY_TAB:
1073
			case KEY_TAB:
1074
			case KEY_UP:
1074
			case KEY_UP:
1075
	        break;
1075
	        break;
1076
 
1076
 
1077
		    case KEY_ENTER:
1077
		    case KEY_ENTER:
1078
		    	surEvenementClavierToucheEntree(champ);
1078
		    	surEvenementClavierToucheEntree(champ);
1079
		    	break;
1079
		    	break;
1080
 
1080
 
1081
	        default:
1081
	        default:
1082
	        	gererEvenementClavierDefaut(champ);
1082
	        	gererEvenementClavierDefaut(champ);
1083
	        break;
1083
	        break;
1084
		}
1084
		}
1085
	}
1085
	}
1086
 
1086
 
1087
	private void surEvenementClavierToucheEntree(TextField champ) {
1087
	private void surEvenementClavierToucheEntree(TextField champ) {
1088
		//TODO: faire un switch ou une enum
1088
		//TODO: faire un switch ou une enum
1089
		if(champ.equals(selecteurStadePheno)) {
1089
		if(champ.equals(selecteurStadePheno)) {
1090
			if(!selectionPhenologie) {
1090
			if(!selectionPhenologie) {
1091
  	    		validerSaisie(Champs.PHENOLOGIE); 
1091
  	    		validerSaisie(Champs.PHENOLOGIE); 
1092
	    	} else {
1092
	    	} else {
1093
	    		selectionPhenologie = false;
1093
	    		selectionPhenologie = false;
1094
	    	}
1094
	    	}
1095
		}
1095
		}
1096
 
1096
 
1097
		if(champ.equals(selecteurCertitude)) {
1097
		if(champ.equals(selecteurCertitude)) {
1098
			if(!selectionCertitude) {
1098
			if(!selectionCertitude) {
1099
		    		validerSaisie(Champs.CERTITUDE); 
1099
		    		validerSaisie(Champs.CERTITUDE); 
1100
	    	} else {
1100
	    	} else {
1101
	    		selectionCertitude = false;
1101
	    		selectionCertitude = false;
1102
	    	}
1102
	    	}
1103
		}
1103
		}
1104
 
1104
 
1105
		if(champ.equals(selecteurAbondance)) {
1105
		if(champ.equals(selecteurAbondance)) {
1106
			if(!selectionAbondance) {
1106
			if(!selectionAbondance) {
1107
		    	validerSaisie(Champs.ABONDANCE); 
1107
		    	validerSaisie(Champs.ABONDANCE); 
1108
	    	} else {
1108
	    	} else {
1109
	    		selectionAbondance = false;
1109
	    		selectionAbondance = false;
1110
	    	}
1110
	    	}
1111
		}
1111
		}
1112
 
1112
 
1113
		if(champ.equals(longitude)) {
1113
		if(champ.equals(longitude)) {
1114
			validerSaisie(Champs.LONGITUDE);
1114
			validerSaisie(Champs.LONGITUDE);
1115
		}
1115
		}
1116
 
1116
 
1117
		if(champ.equals(latitude)) {  	    	    
1117
		if(champ.equals(latitude)) {  	    	    
1118
	    	validerSaisie(Champs.LATITUDE);
1118
	    	validerSaisie(Champs.LATITUDE);
1119
		}
1119
		}
1120
 
1120
 
1121
		if(champ.equals(altitude)) {  	    	    
1121
		if(champ.equals(altitude)) {  	    	    
1122
	    	validerSaisie(Champs.ALTITUDE);
1122
	    	validerSaisie(Champs.ALTITUDE);
1123
		}
1123
		}
1124
 
1124
 
1125
		if(champ.equals(espece)) {
1125
		if(champ.equals(espece)) {
1126
			if(selectionEspece) {
1126
			if(selectionEspece) {
1127
	    		especeModifiee = true;
1127
	    		especeModifiee = true;
1128
	    		selectionEspece=false;
1128
	    		selectionEspece=false;
1129
	    	}
1129
	    	}
1130
	    	else {
1130
	    	else {
1131
	    		validerSaisie(Champs.ESPECE); 	    	    
1131
	    		validerSaisie(Champs.ESPECE); 	    	    
1132
	    	}
1132
	    	}
1133
		}
1133
		}
1134
 
1134
 
1135
		if(champ.equals(selecteurReferentielTaxo)) {
1135
		if(champ.equals(selecteurReferentielTaxo)) {
1136
			validerSaisie(Champs.REFERENTIELTAXO);
1136
			validerSaisie(Champs.REFERENTIELTAXO);
1137
		}
1137
		}
1138
 
1138
 
1139
		if(champ.equals(date)) {
1139
		if(champ.equals(date)) {
1140
			validerSaisie(Champs.DATE);
1140
			validerSaisie(Champs.DATE);
1141
		}
1141
		}
1142
 
1142
 
1143
		if(champ.equals(localite)) {
1143
		if(champ.equals(localite)) {
1144
			if(champ.equals(localite)) {
1144
			if(champ.equals(localite)) {
1145
				if (selectionlocalite) {
1145
				if (selectionlocalite) {
1146
		    		 localiteModifiee= true;
1146
		    		 localiteModifiee= true;
1147
		    		 selectionlocalite=false;
1147
		    		 selectionlocalite=false;
1148
		    	 }
1148
		    	 }
1149
		    	else {
1149
		    	else {
1150
		    		validerSaisie(Champs.LOCALITE);
1150
		    		validerSaisie(Champs.LOCALITE);
1151
		    	 }
1151
		    	 }
1152
			}
1152
			}
1153
		}
1153
		}
1154
	}
1154
	}
1155
 
1155
 
1156
	private void gererEvenementClavierDefaut(TextField champ) {
1156
	private void gererEvenementClavierDefaut(TextField champ) {
1157
		//TODO: faire un switch ou une enum
1157
		//TODO: faire un switch ou une enum
1158
		if(champ.equals(selecteurStadePheno)) {
1158
		if(champ.equals(selecteurStadePheno)) {
1159
			selecteurStadePheno.setRawValue(selecteurStadePheno.getRawValue());
1159
			selecteurStadePheno.setRawValue(selecteurStadePheno.getRawValue());
1160
			selecteurStadePheno.setValue(selecteurStadePheno.getRawValue());
1160
			selecteurStadePheno.setValue(selecteurStadePheno.getRawValue());
1161
			phenologieModifiee = true;
1161
			phenologieModifiee = true;
1162
			selectionPhenologie = false;
1162
			selectionPhenologie = false;
1163
		}
1163
		}
1164
 
1164
 
1165
		if(champ.equals(selecteurCertitude)) {
1165
		if(champ.equals(selecteurCertitude)) {
1166
			selecteurCertitude.setRawValue(selecteurCertitude.getRawValue());
1166
			selecteurCertitude.setRawValue(selecteurCertitude.getRawValue());
1167
	    	selecteurCertitude.setValue(selecteurCertitude.getRawValue());
1167
	    	selecteurCertitude.setValue(selecteurCertitude.getRawValue());
1168
	    	certitudeModifiee = true;
1168
	    	certitudeModifiee = true;
1169
	    	selectionCertitude = false;
1169
	    	selectionCertitude = false;
1170
		}
1170
		}
1171
 
1171
 
1172
		if(champ.equals(selecteurAbondance)) {
1172
		if(champ.equals(selecteurAbondance)) {
1173
			selecteurAbondance.setRawValue(selecteurAbondance.getRawValue());
1173
			selecteurAbondance.setRawValue(selecteurAbondance.getRawValue());
1174
	    	selecteurAbondance.setValue(selecteurAbondance.getRawValue());
1174
	    	selecteurAbondance.setValue(selecteurAbondance.getRawValue());
1175
	    	abondanceModifiee = true;
1175
	    	abondanceModifiee = true;
1176
	    	selectionAbondance = false;
1176
	    	selectionAbondance = false;
1177
		}
1177
		}
1178
 
1178
 
1179
		if(champ.equals(longitude)) {
1179
		if(champ.equals(longitude)) {
1180
			longModifiee = true;
1180
			longModifiee = true;
1181
        	tCoord.cancel();
1181
        	tCoord.cancel();
1182
        	tCoord.schedule(250);
1182
        	tCoord.schedule(250);
1183
		}
1183
		}
1184
 
1184
 
1185
		if(champ.equals(latitude)) {  	    	    
1185
		if(champ.equals(latitude)) {  	    	    
1186
			latModifiee = true;
1186
			latModifiee = true;
1187
	      	tCoord.cancel();
1187
	      	tCoord.cancel();
1188
	      	tCoord.schedule(250);
1188
	      	tCoord.schedule(250);
1189
		}
1189
		}
1190
 
1190
 
1191
		if(champ.equals(altitude)) {  	    	    
1191
		if(champ.equals(altitude)) {  	    	    
1192
			altModifiee = true;  
1192
			altModifiee = true;  
1193
		}
1193
		}
1194
 
1194
 
1195
		if(champ.equals(comment)) {
1195
		if(champ.equals(comment)) {
1196
			commModifie = true;
1196
			commModifie = true;
1197
		}
1197
		}
1198
 
1198
 
1199
		if(champ.equals(espece)) {
1199
		if(champ.equals(espece)) {
1200
			numeroNom="";
1200
			numeroNom="";
1201
	    	especeModifiee = true;
1201
	    	especeModifiee = true;
1202
		}
1202
		}
1203
 
1203
 
1204
		if(champ.equals(selecteurReferentielTaxo)) {
1204
		if(champ.equals(selecteurReferentielTaxo)) {
1205
			referentielTaxoModifie = true;
1205
			referentielTaxoModifie = true;
1206
		}
1206
		}
1207
 
1207
 
1208
		if(champ.equals(date)) {
1208
		if(champ.equals(date)) {
1209
			dateModifiee = true;
1209
			dateModifiee = true;
1210
		}
1210
		}
1211
 
1211
 
1212
		if(champ.equals(localite)) {
1212
		if(champ.equals(localite)) {
1213
			codeLocalite="";
1213
			codeLocalite="";
1214
	    	localite.collapse();
1214
	    	localite.collapse();
1215
	    	localiteModifiee= true;
1215
	    	localiteModifiee= true;
1216
		}
1216
		}
1217
	}
1217
	}
1218
 
1218
 
1219
	/**
1219
	/**
1220
	 * Validation de la saisie
1220
	 * Validation de la saisie
1221
	 */
1221
	 */
1222
 
1222
 
1223
	private void validerSaisie(Champs champs) {
1223
	private void validerSaisie(Champs champs) {
1224
		if(!selectionMultiple) {
1224
		if(!selectionMultiple) {
1225
			ajouterObservation();
1225
			ajouterObservation();
1226
			raz(champs);
1226
			raz(champs);
1227
		} else {
1227
		} else {
1228
			modifierObservationEnMasse();
1228
			modifierObservationEnMasse();
1229
		}
1229
		}
1230
	}
1230
	}
1231
 
1231
 
1232
	/**
1232
	/**
1233
	 * Desactive visuellement ce panneau
1233
	 * Desactive visuellement ce panneau
1234
	 */
1234
	 */
1235
	public void desactiverPanneau()
1235
	public void desactiverPanneau()
1236
	{
1236
	{
1237
		this.setDisabled(true) ;
1237
		this.setDisabled(true) ;
1238
	}
1238
	}
1239
 
1239
 
1240
	/**
1240
	/**
1241
	 * Active visuellement ce panneau
1241
	 * Active visuellement ce panneau
1242
	 */
1242
	 */
1243
	public void activerPanneau()
1243
	public void activerPanneau()
1244
	{
1244
	{
1245
		this.setDisabled(false) ;
1245
		this.setDisabled(false) ;
1246
	}
1246
	}
1247
 
1247
 
1248
	@Override
1248
	@Override
1249
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
1249
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
1250
 
1250
 
1251
		// On recoit une observation dont on veut afficher le detail
1251
		// On recoit une observation dont on veut afficher le detail
1252
		if(nouvelleDonnees instanceof Observation)
1252
		if(nouvelleDonnees instanceof Observation)
1253
		{
1253
		{
1254
			Observation obs = (Observation)nouvelleDonnees ;
1254
			Observation obs = (Observation)nouvelleDonnees ;
1255
			setSelectionMultiple(false);
1255
			setSelectionMultiple(false);
1256
			afficherDetailsObservation(obs) ;
1256
			afficherDetailsObservation(obs) ;
1257
		}
1257
		}
1258
 
1258
 
1259
		if(nouvelleDonnees instanceof ListeObservation) {
1259
		if(nouvelleDonnees instanceof ListeObservation) {
1260
 
1260
 
1261
			ListeObservation listeObs = (ListeObservation)nouvelleDonnees;
1261
			ListeObservation listeObs = (ListeObservation)nouvelleDonnees;
1262
			setSelectionMultiple(true);
1262
			setSelectionMultiple(true);
1263
			calculerAfficherDifferences(listeObs);
1263
			calculerAfficherDifferences(listeObs);
1264
		}
1264
		}
1265
 
1265
 
1266
		if(nouvelleDonnees instanceof String)
1266
		if(nouvelleDonnees instanceof String)
1267
		{
1267
		{
1268
			String str = (String)nouvelleDonnees ;
1268
			String str = (String)nouvelleDonnees ;
1269
			observationMediateur.obtenirNombreObservation() ;
1269
			observationMediateur.obtenirNombreObservation() ;
1270
		}
1270
		}
1271
 
1271
 
1272
		if(nouvelleDonnees instanceof String[]) {
1272
		if(nouvelleDonnees instanceof String[]) {
1273
			String[] anumNom = (String[])nouvelleDonnees ;
1273
			String[] anumNom = (String[])nouvelleDonnees ;
1274
			numeroNom = anumNom[1];
1274
			numeroNom = anumNom[1];
1275
			espece.setValue(anumNom[0]);
1275
			espece.setValue(anumNom[0]);
1276
		}
1276
		}
1277
 
1277
 
1278
		if(nouvelleDonnees instanceof EntiteGeographiqueObservation)
1278
		if(nouvelleDonnees instanceof EntiteGeographiqueObservation)
1279
		{
1279
		{
1280
			EntiteGeographiqueObservation infosComm = (EntiteGeographiqueObservation)nouvelleDonnees ;
1280
			EntiteGeographiqueObservation infosComm = (EntiteGeographiqueObservation)nouvelleDonnees ;
1281
			if(recherchelocaliteEnCours) {
1281
			if(recherchelocaliteEnCours) {
1282
				afficherIndicationlocalite(infosComm);
1282
				afficherIndicationlocalite(infosComm);
1283
			} else {
1283
			} else {
1284
				rafraichirlocaliteEtCoord(infosComm);
1284
				rafraichirlocaliteEtCoord(infosComm);
1285
			}
1285
			}
1286
		}
1286
		}
1287
	}
1287
	}
1288
 
1288
 
1289
	private void afficherIndicationlocalite(
1289
	private void afficherIndicationlocalite(
1290
			final EntiteGeographiqueObservation infosCom) {
1290
			final EntiteGeographiqueObservation infosCom) {
1291
 
1291
 
1292
		String nlocalite = "";
1292
		String nlocalite = "";
1293
		if(infosCom != null && infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().trim().isEmpty()) {
1293
		if(infosCom != null && infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().trim().isEmpty()) {
1294
			nlocalite += infosCom.getZoneGeo();
1294
			nlocalite += infosCom.getZoneGeo();
1295
			if(infosCom.getIdZoneGeo() != null && !infosCom.getIdZoneGeo().trim().isEmpty()) {
1295
			if(infosCom.getIdZoneGeo() != null && !infosCom.getIdZoneGeo().trim().isEmpty()) {
1296
				if(Util.estUnDepartement(infosCom.getIdZoneGeo())) {
1296
				if(Util.estUnDepartement(infosCom.getIdZoneGeo())) {
1297
					nlocalite += " ("+Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo())+")";
1297
					nlocalite += " ("+Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo())+")";
1298
				} else if(infosCom.getPays() != null && !infosCom.getPays().trim().isEmpty()) {
1298
				} else if(infosCom.getPays() != null && !infosCom.getPays().trim().isEmpty()) {
1299
					nlocalite += " ("+infosCom.getPays()+")";
1299
					nlocalite += " ("+infosCom.getPays()+")";
1300
				}
1300
				}
1301
			} else if(infosCom.getPays() != null && !infosCom.getPays().trim().isEmpty()) {
1301
			} else if(infosCom.getPays() != null && !infosCom.getPays().trim().isEmpty()) {
1302
				nlocalite += " ("+infosCom.getPays()+")";
1302
				nlocalite += " ("+infosCom.getPays()+")";
1303
			}
1303
			}
1304
 
1304
 
1305
			lienSelectionlocalite.setHtml("<a id=\"lien_selection_localite\" tabindex=\"9\">"+nlocalite+"</a>");
1305
			lienSelectionlocalite.setHtml("<a id=\"lien_selection_localite\" tabindex=\"9\">"+nlocalite+"</a>");
1306
			lienSelectionlocalite.setStyleName("img-curseur-depl");
1306
			lienSelectionlocalite.setStyleName("img-curseur-depl");
1307
 
1307
 
1308
			Ext.get("lien_selection_localite").addListener("click",new EventCallback() {
1308
			Ext.get("lien_selection_localite").addListener("click",new EventCallback() {
1309
				@Override
1309
				@Override
1310
				public void execute(EventObject e) {
1310
				public void execute(EventObject e) {
1311
					rafraichirlocalite(infosCom);
1311
					rafraichirlocalite(infosCom);
1312
				}
1312
				}
1313
			});
1313
			});
1314
 
1314
 
1315
			Ext.get("lien_selection_localite").addListener("keypress",new EventCallback() {
1315
			Ext.get("lien_selection_localite").addListener("keypress",new EventCallback() {
1316
				@Override
1316
				@Override
1317
				public void execute(EventObject e) {
1317
				public void execute(EventObject e) {
1318
					if(e.getCharCode() == KEY_ENTER) {
1318
					if(e.getCharCode() == KEY_ENTER) {
1319
						rafraichirlocalite(infosCom);
1319
						rafraichirlocalite(infosCom);
1320
					}
1320
					}
1321
				}
1321
				}
1322
			});
1322
			});
1323
 
1323
 
1324
			Ext.get("lien_selection_localite").addListener("focus",new EventCallback() {
1324
			Ext.get("lien_selection_localite").addListener("focus",new EventCallback() {
1325
				@Override
1325
				@Override
1326
				public void execute(EventObject e) {
1326
				public void execute(EventObject e) {
1327
					Ext.get("lien_selection_localite").toggleClass("lien_sel");
1327
					Ext.get("lien_selection_localite").toggleClass("lien_sel");
1328
				}
1328
				}
1329
			});
1329
			});
1330
 
1330
 
1331
			Ext.get("lien_selection_localite").addListener("blur",new EventCallback() {
1331
			Ext.get("lien_selection_localite").addListener("blur",new EventCallback() {
1332
				@Override
1332
				@Override
1333
				public void execute(EventObject e) {
1333
				public void execute(EventObject e) {
1334
					Ext.get("lien_selection_localite").toggleClass("lien_sel");
1334
					Ext.get("lien_selection_localite").toggleClass("lien_sel");
1335
				}
1335
				}
1336
			});
1336
			});
1337
 
1337
 
1338
		} else {
1338
		} else {
1339
			if(recherchelocaliteEnCours) {
1339
			if(recherchelocaliteEnCours) {
1340
				lienSelectionlocalite.setHtml("<span id=\"aucune_selection_localite\"> "+Msg.get("erreur-localisation")+" </span>");
1340
				lienSelectionlocalite.setHtml("<span id=\"aucune_selection_localite\"> "+Msg.get("erreur-localisation")+" </span>");
1341
			} else {
1341
			} else {
1342
				lienSelectionlocalite.setHtml("<span id=\"aucune_selection_localite\"> </span>");
1342
				lienSelectionlocalite.setHtml("<span id=\"aucune_selection_localite\"> </span>");
1343
			}
1343
			}
1344
		}
1344
		}
1345
 
1345
 
1346
		Ext.get(lienSelectionlocalite.getElement()).unmask();
1346
		Ext.get(lienSelectionlocalite.getElement()).unmask();
1347
		recherchelocaliteEnCours = false;
1347
		recherchelocaliteEnCours = false;
1348
	}
1348
	}
1349
 
1349
 
1350
	private void rafraichirlocalite(EntiteGeographiqueObservation infosCom) {
1350
	private void rafraichirlocalite(EntiteGeographiqueObservation infosCom) {
1351
		String nlocalite = "";
1351
		String nlocalite = "";
1352
 
1352
 
1353
		if(infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().equals("")) {
1353
		if(infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().equals("")) {
1354
			nlocalite += infosCom.getZoneGeo();
1354
			nlocalite += infosCom.getZoneGeo();
1355
		}
1355
		}
1356
		
1356
		
1357
		if(infosCom.getIdZoneGeo() != null && Util.estUnDepartement(infosCom.getIdZoneGeo())) {
1357
		if(infosCom.getIdZoneGeo() != null && Util.estUnDepartement(infosCom.getIdZoneGeo())) {
1358
			String codeGeoFormate = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
1358
			String codeGeoFormate = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
1359
			nlocalite += " ("+codeGeoFormate+")";
1359
			nlocalite += " ("+codeGeoFormate+")";
1360
			codeLocalite = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
1360
			codeLocalite = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
1361
		} else if(infosCom.getPays() != null && !infosCom.getPays().trim().isEmpty()) {
1361
		} else if(infosCom.getPays() != null && !infosCom.getPays().trim().isEmpty()) {
1362
			nlocalite += " ("+infosCom.getPays()+")";
1362
			nlocalite += " ("+infosCom.getPays()+")";
1363
		}
1363
		}
1364
		
1364
		
1365
		if (!nlocalite.isEmpty()) {
1365
		if (!nlocalite.isEmpty()) {
1366
			// Vide ou null, on remplace !
1366
			// Vide ou null, on remplace !
1367
			if(localite.getText() == null || localite.getText().trim().isEmpty()) {
1367
			if(localite.getText() == null || localite.getText().trim().isEmpty()) {
1368
				localite.setValue(nlocalite);
1368
				localite.setValue(nlocalite);
1369
			} else {
1369
			} else {
1370
				// Afin de pas effacer un pays précédemment saisi, si on a déjà saisi une localité
1370
				// Afin de pas effacer un pays précédemment saisi, si on a déjà saisi une localité
1371
				// avec le même nom mais avec un pays, on ne remplace rien
1371
				// avec le même nom mais avec un pays, on ne remplace rien
1372
				if(localite.getText() != null && !localite.getText().contains(nlocalite)) {
1372
				if(localite.getText() != null && !localite.getText().contains(nlocalite)) {
1373
					localite.setValue(nlocalite);
1373
					localite.setValue(nlocalite);
1374
				}
1374
				}
1375
			}
1375
			}
1376
 
1376
 
1377
			localiteModifiee = true;
1377
			localiteModifiee = true;
1378
		}
1378
		}
1379
	}
1379
	}
1380
 
1380
 
1381
	// Se déclenche au retour de la "localisation sur la carte"
1381
	// Se déclenche au retour de la "localisation sur la carte"
1382
	private void rafraichirlocaliteEtCoord(EntiteGeographiqueObservation infosCom) {
1382
	private void rafraichirlocaliteEtCoord(EntiteGeographiqueObservation infosCom) {
1383
		
1383
		
1384
		rafraichirlocalite(infosCom);
1384
		rafraichirlocalite(infosCom);
1385
		if(infosCom.getLat() != null && !infosCom.getLat().equals("")) {
1385
		if(infosCom.getLat() != null && !infosCom.getLat().equals("")) {
1386
			latitude.setValue(Util.tronquerNombrePourAffichage("" + infosCom.getLat(), 5));
1386
			latitude.setValue(Util.tronquerNombrePourAffichage("" + infosCom.getLat(), 5));
1387
		}
1387
		}
1388
 
1388
 
1389
		if(infosCom.getLon() != null && !infosCom.getLon().equals("")) {
1389
		if(infosCom.getLon() != null && !infosCom.getLon().equals("")) {
1390
			longitude.setValue(Util.tronquerNombrePourAffichage("" + infosCom.getLon(), 5));
1390
			longitude.setValue(Util.tronquerNombrePourAffichage("" + infosCom.getLon(), 5));
1391
		}
1391
		}
1392
 
1392
 
1393
		latModifiee = true;
1393
		latModifiee = true;
1394
		longModifiee = true;
1394
		longModifiee = true;
1395
 
1395
 
1396
		coordPanel.setVisible(true);
1396
		coordPanel.setVisible(true);
1397
	}
1397
	}
1398
 
1398
 
1399
	public void ajouterObservation() {
1399
	public void ajouterObservation() {
1400
 
1400
 
1401
		if(date.getRawValue() != null && !date.getRawValue().equals("") && !Util.verifierDateFormatCel(date.getRawValue())) {
1401
		if(date.getRawValue() != null && !date.getRawValue().equals("") && !Util.verifierDateFormatCel(date.getRawValue())) {
1402
			Window.alert(Msg.get("indication-date-invalide"));
1402
			Window.alert(Msg.get("indication-date-invalide"));
1403
			date.setInvalidText(Msg.get("date-invalide"));
1403
			date.setInvalidText(Msg.get("date-invalide"));
1404
			return;
1404
			return;
1405
		}
1405
		}
1406
 
1406
 
1407
		affecterCodeLocaliteOuPays();
1407
		affecterCodeLocaliteOuPays();
1408
 
1408
 
1409
		String dateObs = Util.remplacerSeparateursDateFormatCel(date.getRawValue());
1409
		String dateObs = Util.remplacerSeparateursDateFormatCel(date.getRawValue());
1410
 
1410
 
1411
		Observation obs=new Observation(espece.getText(),numeroNom,localite.getText(),codeLocalite,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);
1411
		Observation obs=new Observation(espece.getText(),numeroNom,localite.getText(),codeLocalite,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);
1412
 
1412
 
1413
		String[] coords = getValeurCoordonnees();
1413
		String[] coords = getValeurCoordonnees();
1414
		obs.setPays(pays);
1414
		obs.setPays(pays);
1415
		obs.setLatitude(coords[0]);
1415
		obs.setLatitude(coords[0]);
1416
		obs.setLongitude(coords[1]);
1416
		obs.setLongitude(coords[1]);
1417
		obs.setAltitude(altitude.getText());
1417
		obs.setAltitude(altitude.getText());
1418
 
1418
 
1419
		obs.setAbondance(getAbondance());
1419
		obs.setAbondance(getAbondance());
1420
		obs.setCertitude(getCertitude());
1420
		obs.setCertitude(getCertitude());
1421
		obs.setPhenologie(getPhenologie());
1421
		obs.setPhenologie(getPhenologie());
1422
 
1422
 
1423
		obs.setReferentielTaxo(Ontologies.getInfosReferentielNomParCode(referentielTaxo).getCodeVersionComplet());
1423
		obs.setReferentielTaxo(Ontologies.getInfosReferentielNomParCode(referentielTaxo).getCodeVersionComplet());
1424
		obs.setChampsEtendus(getValeursChampsEtendus());
1424
		obs.setChampsEtendus(getValeursChampsEtendus());
1425
 
1425
 
1426
		observationMediateur.ajouterObservation(obs);
1426
		observationMediateur.ajouterObservation(obs);
1427
	}
1427
	}
1428
 
1428
 
1429
	private void modifierObservation() {
1429
	private void modifierObservation() {
1430
		if(!Window.confirm(Msg.get("question-modifier-observation")+" ?")) {
1430
		if(!Window.confirm(Msg.get("question-modifier-observation")+" ?")) {
1431
			return;
1431
			return;
1432
		}
1432
		}
1433
 
1433
 
1434
		if(date.getRawValue() != null && !date.getRawValue().equals("") && !Util.verifierDateFormatCel(date.getRawValue())) {
1434
		if(date.getRawValue() != null && !date.getRawValue().equals("") && !Util.verifierDateFormatCel(date.getRawValue())) {
1435
			Window.alert(Msg.get("indication-date-invalide"));
1435
			Window.alert(Msg.get("indication-date-invalide"));
1436
			date.setInvalidText(Msg.get("date-invalide"));
1436
			date.setInvalidText(Msg.get("date-invalide"));
1437
			return;
1437
			return;
1438
		}
1438
		}
1439
 
1439
 
1440
		affecterCodeLocaliteOuPays();
1440
		affecterCodeLocaliteOuPays();
1441
		
1441
		
1442
		String dateObs = Util.remplacerSeparateursDateFormatCel(date.getRawValue());
1442
		String dateObs = Util.remplacerSeparateursDateFormatCel(date.getRawValue());
1443
 
1443
 
1444
		Observation obs=new Observation(espece.getText(),numeroNom,localite.getText(),codeLocalite,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);
1444
		Observation obs=new Observation(espece.getText(),numeroNom,localite.getText(),codeLocalite,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);
1445
		obs.setNumeroOrdre(numeroOrdre);
1445
		obs.setNumeroOrdre(numeroOrdre);
1446
 
1446
 
1447
		String[] coords = getValeurCoordonnees();
1447
		String[] coords = getValeurCoordonnees();
1448
 
1448
 
1449
		obs.setPays(pays);
1449
		obs.setPays(pays);
1450
		obs.setLatitude(coords[0]);
1450
		obs.setLatitude(coords[0]);
1451
		obs.setLongitude(coords[1]);
1451
		obs.setLongitude(coords[1]);
1452
		obs.setAltitude(altitude.getText());
1452
		obs.setAltitude(altitude.getText());
1453
 
1453
 
1454
		obs.setAbondance(getAbondance());
1454
		obs.setAbondance(getAbondance());
1455
		obs.setCertitude(getCertitude());
1455
		obs.setCertitude(getCertitude());
1456
		obs.setPhenologie(getPhenologie());
1456
		obs.setPhenologie(getPhenologie());
1457
		obs.setReferentielTaxo(getReferentielTaxo());
1457
		obs.setReferentielTaxo(getReferentielTaxo());
1458
		obs.setChampsEtendus(getValeursChampsEtendus());
1458
		obs.setChampsEtendus(getValeursChampsEtendus());
1459
 
1459
 
1460
		observationMediateur.modifierObservation(obs);
1460
		observationMediateur.modifierObservation(obs);
1461
	}
1461
	}
1462
 
1462
 
1463
	private void affecterCodeLocaliteOuPays() {
1463
	private void affecterCodeLocaliteOuPays() {
1464
		
1464
		
1465
		codeLocalite = "";
1465
		codeLocalite = "";
1466
		pays = "";
1466
		pays = "";
1467
		
1467
		
1468
		// Soit un numéro de département, soit un code de pays à deux lettres
1468
		// Soit un numéro de département, soit un code de pays à deux lettres
1469
		String[] codeCom = localite.getText().split(" ");
1469
		String[] codeCom = localite.getText().split(" ");
1470
		if(codeCom.length > 1 && ressembleAUnCodePaysOuDepartement(codeCom[codeCom.length - 1])) {
1470
		if(codeCom.length > 1 && ressembleAUnCodePaysOuDepartement(codeCom[codeCom.length - 1])) {
1471
			String codeLoc = codeCom[codeCom.length - 1].replace('(', ' ');
1471
			String codeLoc = codeCom[codeCom.length - 1].replace('(', ' ');
1472
			codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
1472
			codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
1473
 
1473
 
1474
			if(Util.estUnDepartement(codeLoc)) {
1474
			if(Util.estUnDepartement(codeLoc)) {
1475
				codeLocalite = codeLoc ;
1475
				codeLocalite = codeLoc ;
1476
			} else {
1476
			} else {
1477
				pays = codeLoc.toUpperCase();
1477
				pays = codeLoc.toUpperCase();
1478
			}
1478
			}
1479
		}
1479
		}
1480
	}
1480
	}
1481
	
1481
	
1482
	private boolean ressembleAUnCodePaysOuDepartement(String s) {	
1482
	private boolean ressembleAUnCodePaysOuDepartement(String s) {	
1483
		String sP = s.replace("(", "").replace(")", "").trim();
1483
		String sP = s.replace("(", "").replace(")", "").trim();
1484
		
1484
		
1485
		boolean contientDesParentheses = s.contains("(") && s.contains(")");
1485
		boolean contientDesParentheses = s.contains("(") && s.contains(")");
1486
		boolean estUnCodePays = !Util.estUnNombre(sP) && (sP.length() == 2);
1486
		boolean estUnCodePays = !Util.estUnNombre(sP) && (sP.length() == 2);
1487
		boolean estUnCodeDepartement = Util.estUnNombre(sP) && (sP.length() >= 1 && sP.length() <= 5);
1487
		boolean estUnCodeDepartement = Util.estUnNombre(sP) && (sP.length() >= 1 && sP.length() <= 5);
1488
		
1488
		
1489
		return contientDesParentheses && (estUnCodePays || estUnCodeDepartement);
1489
		return contientDesParentheses && (estUnCodePays || estUnCodeDepartement);
1490
	}
1490
	}
1491
 
1491
 
1492
	private void modifierObservationEnMasse() {
1492
	private void modifierObservationEnMasse() {
1493
 
1493
 
1494
		//TODO: factoriser
1494
		//TODO: factoriser
1495
		String paysM = null;
1495
		String paysM = null;
1496
		String localiteM = null;
1496
		String localiteM = null;
1497
		String codeLocaliteM = null;
1497
		String codeLocaliteM = null;
1498
		String numNomSelM = null;
1498
		String numNomSelM = null;
1499
		String lieuDitM = null;
1499
		String lieuDitM = null;
1500
		String stationM = null;
1500
		String stationM = null;
1501
		String milieuM = null;
1501
		String milieuM = null;
1502
		String dateM = null;
1502
		String dateM = null;
1503
		String especeM = null;
1503
		String especeM = null;
1504
		String commM = null;
1504
		String commM = null;
1505
		String latM = null;
1505
		String latM = null;
1506
		String longM = null;
1506
		String longM = null;
1507
		String altM = null;
1507
		String altM = null;
1508
		String abondanceM = null;
1508
		String abondanceM = null;
1509
		String certitudeM = null;
1509
		String certitudeM = null;
1510
		String referentielTaxoM = null;
1510
		String referentielTaxoM = null;
1511
		String phenologieM = null;
1511
		String phenologieM = null;
1512
 
1512
 
1513
		String champs = modeleMessageModif;
1513
		String champs = modeleMessageModif;
1514
 
1514
 
1515
		if(localiteModifiee && ! localite.getRawValue().equals(VALEURS_MULTIPLES)) {
1515
		if(localiteModifiee && ! localite.getRawValue().equals(VALEURS_MULTIPLES)) {
1516
			
1516
			
1517
			localiteM = localite.getText();	
1517
			localiteM = localite.getText();	
1518
			
1518
			
1519
			// Soit un numéro de département, soit un code de pays à deux lettres
1519
			// Soit un numéro de département, soit un code de pays à deux lettres
1520
			String[] codeCom = localite.getText().split(" ");
1520
			String[] codeCom = localite.getText().split(" ");
1521
			if(codeCom.length > 1) {
1521
			if(codeCom.length > 1) {
1522
				String codeLoc = codeCom[1].replace('(', ' ');
1522
				String codeLoc = codeCom[1].replace('(', ' ');
1523
				codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
1523
				codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
1524
 
1524
 
1525
				if(Util.estUnDepartement(codeLoc)) {
1525
				if(Util.estUnDepartement(codeLoc)) {
1526
					codeLocaliteM = codeLoc ;
1526
					codeLocaliteM = codeLoc ;
1527
				} else {
1527
				} else {
1528
					paysM = codeLoc;
1528
					paysM = codeLoc;
1529
				}
1529
				}
1530
			}
1530
			}
1531
		}
1531
		}
1532
		else {
1532
		else {
1533
			champs = champs.replaceAll("localite", "");
1533
			champs = champs.replaceAll("localite", "");
1534
		}
1534
		}
1535
 
1535
 
1536
		if(lieuDitModifie && ! lieudit.getRawValue().equals(VALEURS_MULTIPLES)) {
1536
		if(lieuDitModifie && ! lieudit.getRawValue().equals(VALEURS_MULTIPLES)) {
1537
			lieuDitM = lieudit.getText();
1537
			lieuDitM = lieudit.getText();
1538
		} else {
1538
		} else {
1539
			champs = champs.replaceAll(":lieu-dit", "");
1539
			champs = champs.replaceAll(":lieu-dit", "");
1540
		}
1540
		}
1541
 
1541
 
1542
		if(stationModifiee && ! station.getRawValue().equals(VALEURS_MULTIPLES)) {
1542
		if(stationModifiee && ! station.getRawValue().equals(VALEURS_MULTIPLES)) {
1543
			stationM = station.getText();
1543
			stationM = station.getText();
1544
		} else {
1544
		} else {
1545
			champs = champs.replaceAll(":station", "");
1545
			champs = champs.replaceAll(":station", "");
1546
		}
1546
		}
1547
 
1547
 
1548
		if(milieuModifie && ! milieu.getRawValue().equals(VALEURS_MULTIPLES)) {
1548
		if(milieuModifie && ! milieu.getRawValue().equals(VALEURS_MULTIPLES)) {
1549
			milieuM = milieu.getText();
1549
			milieuM = milieu.getText();
1550
		} else {
1550
		} else {
1551
			champs = champs.replaceAll(":milieu", "");
1551
			champs = champs.replaceAll(":milieu", "");
1552
		}
1552
		}
1553
 
1553
 
1554
		if(dateModifiee && ! date.getRawValue().equals(VALEURS_MULTIPLES)) {
1554
		if(dateModifiee && ! date.getRawValue().equals(VALEURS_MULTIPLES)) {
1555
			dateM = date.getRawValue();
1555
			dateM = date.getRawValue();
1556
			dateM = Util.remplacerSeparateursDateFormatCel(dateM);
1556
			dateM = Util.remplacerSeparateursDateFormatCel(dateM);
1557
		} else {
1557
		} else {
1558
			champs = champs.replaceAll(":date", "");
1558
			champs = champs.replaceAll(":date", "");
1559
		}
1559
		}
1560
 
1560
 
1561
		if(especeModifiee && ! espece.getRawValue().equals(VALEURS_MULTIPLES)) {
1561
		if(especeModifiee && ! espece.getRawValue().equals(VALEURS_MULTIPLES)) {
1562
			especeM = espece.getText();
1562
			especeM = espece.getText();
1563
			numNomSelM = numeroNom;
1563
			numNomSelM = numeroNom;
1564
		} else {
1564
		} else {
1565
			champs = champs.replaceAll(":espece", "");
1565
			champs = champs.replaceAll(":espece", "");
1566
		}
1566
		}
1567
 
1567
 
1568
		if(commModifie && ! comment.getRawValue().equals(VALEURS_MULTIPLES)) {
1568
		if(commModifie && ! comment.getRawValue().equals(VALEURS_MULTIPLES)) {
1569
			commM = comment.getText();
1569
			commM = comment.getText();
1570
		} else {
1570
		} else {
1571
			champs = champs.replaceAll(":notes", "");
1571
			champs = champs.replaceAll(":notes", "");
1572
		}
1572
		}
1573
 
1573
 
1574
		if(latModifiee && ! latitude.getRawValue().equals(VALEURS_MULTIPLES)) {
1574
		if(latModifiee && ! latitude.getRawValue().equals(VALEURS_MULTIPLES)) {
1575
			latM = latitude.getText();
1575
			latM = latitude.getText();
1576
		} else {
1576
		} else {
1577
			champs = champs.replaceAll(":latitude", "");
1577
			champs = champs.replaceAll(":latitude", "");
1578
		}
1578
		}
1579
 
1579
 
1580
		if(altModifiee && ! altitude.getRawValue().equals(VALEURS_MULTIPLES)) {
1580
		if(altModifiee && ! altitude.getRawValue().equals(VALEURS_MULTIPLES)) {
1581
			altM = altitude.getText();
1581
			altM = altitude.getText();
1582
		} else {
1582
		} else {
1583
			champs = champs.replaceAll(":altitude", "");
1583
			champs = champs.replaceAll(":altitude", "");
1584
		}
1584
		}
1585
 
1585
 
1586
		if(longModifiee && ! longitude.getRawValue().equals(VALEURS_MULTIPLES)) {
1586
		if(longModifiee && ! longitude.getRawValue().equals(VALEURS_MULTIPLES)) {
1587
			longM = longitude.getText();
1587
			longM = longitude.getText();
1588
		} else {
1588
		} else {
1589
			champs = champs.replaceAll(":longitude", "");
1589
			champs = champs.replaceAll(":longitude", "");
1590
		}
1590
		}
1591
 
1591
 
1592
		if(abondanceModifiee && !selecteurAbondance.getRawValue().equals(VALEURS_MULTIPLES)) {
1592
		if(abondanceModifiee && !selecteurAbondance.getRawValue().equals(VALEURS_MULTIPLES)) {
1593
			abondanceM = getAbondance();
1593
			abondanceM = getAbondance();
1594
		} else {
1594
		} else {
1595
			champs = champs.replaceAll(":abondance", "");
1595
			champs = champs.replaceAll(":abondance", "");
1596
		}
1596
		}
1597
 
1597
 
1598
		if(certitudeModifiee && !selecteurCertitude.getRawValue().equals(VALEURS_MULTIPLES)) {
1598
		if(certitudeModifiee && !selecteurCertitude.getRawValue().equals(VALEURS_MULTIPLES)) {
1599
			certitudeM = getCertitude();
1599
			certitudeM = getCertitude();
1600
		} else {
1600
		} else {
1601
			champs = champs.replaceAll(":identification", "");
1601
			champs = champs.replaceAll(":identification", "");
1602
		}
1602
		}
1603
 
1603
 
1604
		if(referentielTaxoModifie && !selecteurReferentielTaxo.getRawValue().equals(VALEURS_MULTIPLES)) {
1604
		if(referentielTaxoModifie && !selecteurReferentielTaxo.getRawValue().equals(VALEURS_MULTIPLES)) {
1605
			referentielTaxoM = getReferentielTaxo();
1605
			referentielTaxoM = getReferentielTaxo();
1606
		} else {
1606
		} else {
1607
			champs = champs.replaceAll(":referentiel", "");
1607
			champs = champs.replaceAll(":referentiel", "");
1608
		}
1608
		}
1609
 
1609
 
1610
		if(phenologieModifiee && !selecteurStadePheno.getRawValue().equals(VALEURS_MULTIPLES)) {
1610
		if(phenologieModifiee && !selecteurStadePheno.getRawValue().equals(VALEURS_MULTIPLES)) {
1611
			phenologieM = getPhenologie();
1611
			phenologieM = getPhenologie();
1612
		} else {
1612
		} else {
1613
			champs = champs.replaceAll(":phenologie", "");
1613
			champs = champs.replaceAll(":phenologie", "");
1614
		}
1614
		}
1615
		
1615
		
1616
		// TODO : trouver un meilleur système que ça pour gérer le message
1616
		// TODO : trouver un meilleur système que ça pour gérer le message
1617
		// affiché
1617
		// affiché
1618
		String[] champsSt = champs.split(":");
1618
		String[] champsSt = champs.split(":");
1619
		String champsTraduits = "";
1619
		String champsTraduits = "";
1620
		for (int i = 0; i < champsSt.length; i++) {
1620
		for (int i = 0; i < champsSt.length; i++) {
1621
			// TODO: vérifier pourquoi des fois la chaîne est vide
1621
			// TODO: vérifier pourquoi des fois la chaîne est vide
1622
			// ou faire mieux, trouver un meilleur système comme écrit au dessus !
1622
			// ou faire mieux, trouver un meilleur système comme écrit au dessus !
1623
			if(!champsSt[i].trim().isEmpty()) {
1623
			if(!champsSt[i].trim().isEmpty()) {
1624
				champsTraduits += Msg.get(champsSt[i]);
1624
				champsTraduits += Msg.get(champsSt[i]);
1625
				champsTraduits += (i != champsSt.length - 1) ? ", " : "";
1625
				champsTraduits += (i != champsSt.length - 1) ? ", " : "";
1626
			}
1626
			}
1627
		}
1627
		}
1628
 
1628
 
1629
		String[] stParams = {champsTraduits};
1629
		String[] stParams = {champsTraduits};
1630
		String message = Msg.get("question-modifier-champs-observation", stParams)+" ?" ;
1630
		String message = Msg.get("question-modifier-champs-observation", stParams)+" ?" ;
1631
 
1631
 
1632
		if(champs.trim().equals("")) {
1632
		if(champs.trim().equals("")) {
1633
			Window.alert(Msg.get("indication-aucun-champ-modifie"));
1633
			Window.alert(Msg.get("indication-aucun-champ-modifie"));
1634
		} else {
1634
		} else {
1635
			Observation obs = new Observation(especeM,numNomSelM,localiteM,codeLocaliteM,lieuDitM,stationM,milieuM, commM,dateM);
1635
			Observation obs = new Observation(especeM,numNomSelM,localiteM,codeLocaliteM,lieuDitM,stationM,milieuM, commM,dateM);
1636
			obs.setPays(paysM);
1636
			obs.setPays(paysM);
1637
			obs.setNumeroOrdre(numeroOrdre);
1637
			obs.setNumeroOrdre(numeroOrdre);
1638
			obs.setLatitude(latM);
1638
			obs.setLatitude(latM);
1639
			obs.setLongitude(longM);
1639
			obs.setLongitude(longM);
1640
			obs.setAltitude(altM);
1640
			obs.setAltitude(altM);
1641
			obs.setAbondance(abondanceM);
1641
			obs.setAbondance(abondanceM);
1642
			obs.setCertitude(certitudeM);
1642
			obs.setCertitude(certitudeM);
1643
			// Afin de transmettre un ensemble cohérent on force aussi
1643
			// Afin de transmettre un ensemble cohérent on force aussi
1644
			// l'envoi du référentiel en cas de maj de l'espèce
1644
			// l'envoi du référentiel en cas de maj de l'espèce
1645
			if(especeModifiee) {
1645
			if(especeModifiee) {
1646
				referentielTaxoM = getReferentielTaxo();
1646
				referentielTaxoM = getReferentielTaxo();
1647
			}
1647
			}
1648
			obs.setReferentielTaxo(referentielTaxoM);
1648
			obs.setReferentielTaxo(referentielTaxoM);
1649
			obs.setPhenologie(phenologieM);
1649
			obs.setPhenologie(phenologieM);
1650
			if(Window.confirm(message)) {
1650
			if(Window.confirm(message)) {
1651
				observationMediateur.modifierObservationEnMasse(obs);
1651
				observationMediateur.modifierObservationEnMasse(obs);
1652
				reinitialiserValeurModifiees();
1652
				reinitialiserValeurModifiees();
1653
			}
1653
			}
1654
		}
1654
		}
1655
	}
1655
	}
1656
 
1656
 
1657
	private void supprimerObservation() {
1657
	private void supprimerObservation() {
1658
		observationMediateur.supprimerObservation(this, numeroOrdre);
1658
		observationMediateur.supprimerObservation(this, numeroOrdre);
1659
	}
1659
	}
1660
 
1660
 
1661
	public void afficherDetailsObservation(Observation obs)
1661
	public void afficherDetailsObservation(Observation obs)
1662
	{
1662
	{
1663
		raz() ;
1663
		raz() ;
1664
		String idLoc ;
1664
		String idLoc ;
1665
		if(obs.getIdentifiantLocalite() != VALEURS_MULTIPLES) {
1665
		if(obs.getIdentifiantLocalite() != VALEURS_MULTIPLES) {
1666
			idLoc = obs.getIdentifiantLocalite().replaceAll(" ","/");
1666
			idLoc = obs.getIdentifiantLocalite().replaceAll(" ","/");
1667
			idLoc = idLoc.replaceAll("%","");
1667
			idLoc = idLoc.replaceAll("%","");
1668
			idLoc = idLoc.replaceAll("\"","");
1668
			idLoc = idLoc.replaceAll("\"","");
1669
			idLoc = idLoc.replace('\\',' ');
1669
			idLoc = idLoc.replace('\\',' ');
1670
			idLoc = idLoc.trim();
1670
			idLoc = idLoc.trim();
1671
			if(idLoc.length() == 5) {
1671
			if(idLoc.length() == 5) {
1672
				idLoc = idLoc.substring(0,2);
1672
				idLoc = idLoc.substring(0,2);
1673
			}
1673
			}
1674
		} else {
1674
		} else {
1675
			idLoc = obs.getIdentifiantLocalite();
1675
			idLoc = obs.getIdentifiantLocalite();
1676
			if(idLoc.length() == 5) {
1676
			if(idLoc.length() == 5) {
1677
				idLoc = idLoc.substring(0,2);
1677
				idLoc = idLoc.substring(0,2);
1678
			}
1678
			}
1679
		}
1679
		}
1680
		
1680
		
1681
		if(obs.getIdentifiantLocalite().isEmpty() && !obs.getPays().isEmpty()) {
1681
		if(obs.getIdentifiantLocalite().isEmpty() && !obs.getPays().isEmpty()) {
1682
			idLoc = obs.getPays();
1682
			idLoc = obs.getPays();
1683
		}
1683
		}
1684
 
1684
 
1685
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null") && !obs.getDate().equals(VALEURS_MULTIPLES)) {
1685
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null") && !obs.getDate().equals(VALEURS_MULTIPLES)) {
1686
			String[] dateEtHeure = obs.getDate().split(" ", 2);
1686
			String[] dateEtHeure = obs.getDate().split(" ", 2);
1687
			if(verifierFormatDate(dateEtHeure[0])) {
1687
			if(verifierFormatDate(dateEtHeure[0])) {
1688
				date.setValue(dateEtHeure[0]) ;
1688
				date.setValue(dateEtHeure[0]) ;
1689
			}
1689
			}
1690
			else
1690
			else
1691
			{
1691
			{
1692
				date.setRawValue("");
1692
				date.setRawValue("");
1693
			}
1693
			}
1694
		} else {
1694
		} else {
1695
			date.setRawValue(VALEURS_MULTIPLES);
1695
			date.setRawValue(VALEURS_MULTIPLES);
1696
			date.clearInvalid();
1696
			date.clearInvalid();
1697
		}
1697
		}
1698
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
1698
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
1699
			lieudit.setValue(obs.getLieudit()) ;
1699
			lieudit.setValue(obs.getLieudit()) ;
1700
		}
1700
		}
1701
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
1701
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
1702
			station.setValue(obs.getStation()) ;
1702
			station.setValue(obs.getStation()) ;
1703
		}
1703
		}
1704
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
1704
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
1705
			milieu.setValue(obs.getMilieu()) ;
1705
			milieu.setValue(obs.getMilieu()) ;
1706
		}
1706
		}
1707
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
1707
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
1708
 
1708
 
1709
			comment.setRawValue(Util.remplacerSautsDeligneMalEncodes(obs.getCommentaire()));
1709
			comment.setRawValue(Util.remplacerSautsDeligneMalEncodes(obs.getCommentaire()));
1710
 
1710
 
1711
		}
1711
		}
1712
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
1712
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
1713
			if(!idLoc.equals("000null") && !idLoc.equals("")) {
1713
			if(!idLoc.equals("000null") && !idLoc.equals("")) {
1714
				if(!idLoc.equals(VALEURS_MULTIPLES)) {
1714
				if(!idLoc.equals(VALEURS_MULTIPLES)) {
1715
					localite.setValue(obs.getLocalite()+" ("+idLoc+")") ;
1715
					localite.setValue(obs.getLocalite()+" ("+idLoc+")") ;
1716
				} else {
1716
				} else {
1717
					localite.setValue(VALEURS_MULTIPLES);
1717
					localite.setValue(VALEURS_MULTIPLES);
1718
				}
1718
				}
1719
			}
1719
			}
1720
			else
1720
			else
1721
			{
1721
			{
1722
				localite.setValue(obs.getLocalite());
1722
				localite.setValue(obs.getLocalite());
1723
			}
1723
			}
1724
		}
1724
		}
1725
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
1725
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
1726
			codeLocalite = idLoc;
1726
			codeLocalite = idLoc;
1727
		}
1727
		}
1728
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
1728
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
1729
			espece.setValue(obs.getNomSaisi()) ;
1729
			espece.setValue(obs.getNomSaisi()) ;
1730
		}
1730
		}
1731
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
1731
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
1732
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
1732
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
1733
		}
1733
		}
1734
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000null")) {
1734
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000null")) {
1735
			numeroOrdre = obs.getNumeroOrdre() ;
1735
			numeroOrdre = obs.getNumeroOrdre() ;
1736
		}
1736
		}
1737
 
1737
 
1738
		if(doitAfficherLatLon(obs)) {
1738
		if(doitAfficherLatLon(obs)) {
1739
			latitude.setValue(Util.formaterNombre(obs.getLatitude())) ;
1739
			latitude.setValue(Util.formaterNombre(obs.getLatitude())) ;
1740
			longitude.setValue(Util.formaterNombre(obs.getLongitude())) ;
1740
			longitude.setValue(Util.formaterNombre(obs.getLongitude())) ;
1741
		}
1741
		}
1742
 
1742
 
1743
		if(!obs.getAltitude().isEmpty() && !obs.getAltitude().equals("null") && !obs.getAltitude().equals("000null")) {
1743
		if(!obs.getAltitude().isEmpty() && !obs.getAltitude().equals("null") && !obs.getAltitude().equals("000null")) {
1744
			altitude.setValue(Util.formaterNombre(obs.getAltitude())) ;
1744
			altitude.setValue(Util.formaterNombre(obs.getAltitude())) ;
1745
		}
1745
		}
1746
 
1746
 
1747
		selecteurAbondance.getStore().load();
1747
		selecteurAbondance.getStore().load();
1748
		selecteurAbondance.setValue(obs.getAbondance());
1748
		selecteurAbondance.setValue(obs.getAbondance());
1749
 
1749
 
1750
		selecteurCertitude.getStore().load();
1750
		selecteurCertitude.getStore().load();
1751
		selecteurCertitude.setValue(obs.getCertitude());
1751
		selecteurCertitude.setValue(obs.getCertitude());
1752
 
1752
 
1753
		selecteurStadePheno.getStore().load();
1753
		selecteurStadePheno.getStore().load();
1754
		selecteurStadePheno.setValue(obs.getPhenologie());
1754
		selecteurStadePheno.setValue(obs.getPhenologie());
1755
 
1755
 
1756
		selecteurReferentielTaxo.getStore().load();
1756
		selecteurReferentielTaxo.getStore().load();
1757
		if(obs.getReferentielTaxo() != VALEURS_MULTIPLES) {
1757
		if(obs.getReferentielTaxo() != VALEURS_MULTIPLES) {
1758
			referentielTaxo = obs.getCodeCourtReferentielTaxo();
1758
			referentielTaxo = obs.getCodeCourtReferentielTaxo();
1759
			if(referentielTaxo == null || referentielTaxo.isEmpty()) {
1759
			if(referentielTaxo == null || referentielTaxo.isEmpty()) {
1760
			    referentielTaxo = Configuration.getReferentielsDispos().get(0).getCode();
1760
			    referentielTaxo = Configuration.getReferentielsDispos().get(0).getCode();
1761
			}
1761
			}
1762
			selecteurReferentielTaxo.setValue(referentielTaxo);
1762
			selecteurReferentielTaxo.setValue(referentielTaxo);
1763
		} else {
1763
		} else {
1764
			referentielTaxo = "";
1764
			referentielTaxo = "";
1765
			selecteurReferentielTaxo.setRawValue(VALEURS_MULTIPLES);
1765
			selecteurReferentielTaxo.setRawValue(VALEURS_MULTIPLES);
1766
		}
1766
		}
1767
 
1767
 
1768
		afficherChampsEtendus(obs.getChampsEtendus(), null);
1768
		afficherChampsEtendus(obs.getChampsEtendus(), null);
1769
	}
1769
	}
1770
 
1770
 
1771
	private boolean doitAfficherLatLon(Observation obs) {
1771
	private boolean doitAfficherLatLon(Observation obs) {
1772
		return !obs.getLatitude().isEmpty() &&
1772
		return !obs.getLatitude().isEmpty() &&
1773
				!obs.getLatitude().equals("null") &&
1773
				!obs.getLatitude().equals("null") &&
1774
				!obs.getLatitude().equals("000null") &&
1774
				!obs.getLatitude().equals("000null") &&
1775
				!Util.estZero(obs.getLatitude()) &&
1775
				!Util.estZero(obs.getLatitude()) &&
1776
				!obs.getLongitude().isEmpty() &&
1776
				!obs.getLongitude().isEmpty() &&
1777
				!obs.getLongitude().equals("null") &&
1777
				!obs.getLongitude().equals("null") &&
1778
				!obs.getLongitude().equals("000null") &&
1778
				!obs.getLongitude().equals("000null") &&
1779
				!Util.estZero(obs.getLongitude());
1779
				!Util.estZero(obs.getLongitude());
1780
	}
1780
	}
1781
 
1781
 
1782
	private void viderChampsEtendus() {
1782
	private void viderChampsEtendus() {
1783
		if(listeChampsEtendus != null) {
1783
		if(listeChampsEtendus != null) {
1784
			for (Iterator<String> it = listeChampsEtendus.keySet().iterator(); it.hasNext();) {
1784
			for (Iterator<String> it = listeChampsEtendus.keySet().iterator(); it.hasNext();) {
1785
				ChampSaisieEtendu champEtendu = listeChampsEtendus.get(it.next());
1785
				ChampSaisieEtendu champEtendu = listeChampsEtendus.get(it.next());
1786
				champEtendu.destroy();
1786
				champEtendu.destroy();
1787
			}
1787
			}
1788
			if(conteneurChampEtenduGauche != null && conteneurChampEtenduDroite != null) {
1788
			if(conteneurChampEtenduGauche != null && conteneurChampEtenduDroite != null) {
1789
				conteneurChampEtenduGauche.clear();
1789
				conteneurChampEtenduGauche.clear();
1790
				conteneurChampEtenduDroite.clear();
1790
				conteneurChampEtenduDroite.clear();
1791
				panneauPremierColonne.remove(conteneurChampEtenduGauche);
1791
				panneauPremierColonne.remove(conteneurChampEtenduGauche);
1792
				panneauSecondeColonne.remove(conteneurChampEtenduDroite);
1792
				panneauSecondeColonne.remove(conteneurChampEtenduDroite);
1793
			}
1793
			}
1794
			listeChampsEtendus = null;
1794
			listeChampsEtendus = null;
1795
		}
1795
		}
1796
	}
1796
	}
1797
 
1797
 
1798
	private void afficherChampsEtendus(Map<String, ChampEtendu> champsEtendus, ChampEtendu champsAFocus) {
1798
	private void afficherChampsEtendus(Map<String, ChampEtendu> champsEtendus, ChampEtendu champsAFocus) {
1799
		champsEtendus = Util.trierListeChampsEtendus(champsEtendus);
1799
		champsEtendus = Util.trierListeChampsEtendus(champsEtendus);
1800
		viderChampsEtendus();
1800
		viderChampsEtendus();
1801
 
1801
 
1802
		FormLayout flmd = new FormLayout();
1802
		FormLayout flmd = new FormLayout();
1803
		flmd.setLabelWidth(150);
1803
		flmd.setLabelWidth(150);
1804
 
1804
 
1805
		FormLayout flmg = new FormLayout();
1805
		FormLayout flmg = new FormLayout();
1806
		flmg.setLabelWidth(150);
1806
		flmg.setLabelWidth(150);
1807
 
1807
 
1808
		conteneurChampEtenduGauche = new Panel();
1808
		conteneurChampEtenduGauche = new Panel();
1809
		conteneurChampEtenduGauche.setLayout(flmg);
1809
		conteneurChampEtenduGauche.setLayout(flmg);
1810
		conteneurChampEtenduDroite = new Panel();
1810
		conteneurChampEtenduDroite = new Panel();
1811
		conteneurChampEtenduDroite.setLayout(flmd);
1811
		conteneurChampEtenduDroite.setLayout(flmd);
1812
 
1812
 
1813
		conteneurChampEtenduGauche.setAutoWidth(true);
1813
		conteneurChampEtenduGauche.setAutoWidth(true);
1814
		conteneurChampEtenduGauche.setStyle("conteneurChampsEtendus");
1814
		conteneurChampEtenduGauche.setStyle("conteneurChampsEtendus");
1815
		conteneurChampEtenduGauche.setBodyBorder(false);
1815
		conteneurChampEtenduGauche.setBodyBorder(false);
1816
		conteneurChampEtenduDroite.setAutoWidth(true);
1816
		conteneurChampEtenduDroite.setAutoWidth(true);
1817
		conteneurChampEtenduDroite.setStyle("conteneurChampsEtendus");
1817
		conteneurChampEtenduDroite.setStyle("conteneurChampsEtendus");
1818
		conteneurChampEtenduDroite.setBodyBorder(false);
1818
		conteneurChampEtenduDroite.setBodyBorder(false);
1819
 
1819
 
1820
		// pour corriger le décalage sur le panneau induit par le lien d'affichage
1820
		// pour corriger le décalage sur le panneau induit par le lien d'affichage
1821
		conteneurChampEtenduDroite.setPaddings(42, 0, 0, 0);
1821
		conteneurChampEtenduDroite.setPaddings(42, 0, 0, 0);
1822
 
1822
 
1823
		if(champsEtendus != null && champsEtendus.size() > 0) {
1823
		if(champsEtendus != null && champsEtendus.size() > 0) {
1824
			lienAfficherChampsEtendus.setVisible(true);
1824
			lienAfficherChampsEtendus.setVisible(true);
1825
			listeChampsEtendus = new HashMap<String, ChampSaisieEtendu>(champsEtendus.size());
1825
			listeChampsEtendus = new HashMap<String, ChampSaisieEtendu>(champsEtendus.size());
1826
			HashMap<String, String> correspondancesClesLabel = ListeReferentielChampsEtendusDAO.cacheClesLabels;
1826
			HashMap<String, String> correspondancesClesLabel = ListeReferentielChampsEtendusDAO.cacheClesLabels;
1827
			boolean gauche = true;
1827
			boolean gauche = true;
1828
			for (Iterator<String> iterator = champsEtendus.keySet().iterator(); iterator.hasNext();) {
1828
			for (Iterator<String> iterator = champsEtendus.keySet().iterator(); iterator.hasNext();) {
1829
				
1829
				
1830
				String id = iterator.next();
1830
				String id = iterator.next();
1831
				ChampEtendu champ = champsEtendus.get(id);
1831
				ChampEtendu champ = champsEtendus.get(id);
1832
				
1832
				
1833
				String valeur = champ.getValeur();
1833
				String valeur = champ.getValeur();
1834
				String label = id;
1834
				String label = id;
1835
				
1835
				
1836
				// Si le champ possède un clé déjà définie par le catalogue, elle lui sera affectée
1836
				// Si le champ possède un clé déjà définie par le catalogue, elle lui sera affectée
1837
				// sinon on la formate en la "déchamotant" et en ajoutant des espaces
1837
				// sinon on la formate en la "déchamotant" et en ajoutant des espaces
1838
				if(correspondancesClesLabel.containsKey(id)) {
1838
				if(correspondancesClesLabel.containsKey(id)) {
1839
					label = correspondancesClesLabel.get(id);
1839
					label = correspondancesClesLabel.get(id);
1840
				} else {
1840
				} else {
1841
					label = Util.formaterCleChampsEtenduPourAffichage(label);
1841
					label = Util.formaterCleChampsEtenduPourAffichage(label);
1842
				}
1842
				}
1843
 
1843
 
1844
				ChampSaisieEtendu champTexteEtendu = new ChampSaisieEtendu(label, id, ListeReferentielChampsEtendusDAO.getUrlRequeteValeursChampEtendu(id));
1844
				ChampSaisieEtendu champTexteEtendu = new ChampSaisieEtendu(label, id, ListeReferentielChampsEtendusDAO.getUrlRequeteValeursChampEtendu(id));
1845
				if(champ.equals(champsAFocus)) {
1845
				if(champ.equals(champsAFocus)) {
1846
					champTexteEtendu.focus();
1846
					champTexteEtendu.focus();
1847
				}
1847
				}
1848
				
1848
				
1849
				champTexteEtendu.setId(id);
1849
				champTexteEtendu.setId(id);
1850
				champTexteEtendu.setValue(valeur);
1850
				champTexteEtendu.setValue(valeur);
1851
				if(gauche) {
1851
				if(gauche) {
1852
					conteneurChampEtenduGauche.add(champTexteEtendu);
1852
					conteneurChampEtenduGauche.add(champTexteEtendu);
1853
				} else {
1853
				} else {
1854
					conteneurChampEtenduDroite.add(champTexteEtendu);
1854
					conteneurChampEtenduDroite.add(champTexteEtendu);
1855
				}
1855
				}
1856
				listeChampsEtendus.put(id, champTexteEtendu);
1856
				listeChampsEtendus.put(id, champTexteEtendu);
1857
				gauche = !gauche;
1857
				gauche = !gauche;
1858
			}
1858
			}
1859
 
1859
 
1860
			panneauPremierColonne.add(conteneurChampEtenduGauche);
1860
			panneauPremierColonne.add(conteneurChampEtenduGauche);
1861
			panneauSecondeColonne.add(conteneurChampEtenduDroite);
1861
			panneauSecondeColonne.add(conteneurChampEtenduDroite);
1862
 
1862
 
1863
			if(!afficherChampsEtendus) {
1863
			if(!afficherChampsEtendus) {
1864
				conteneurChampEtenduGauche.setVisible(false);
1864
				conteneurChampEtenduGauche.setVisible(false);
1865
				conteneurChampEtenduDroite.setVisible(false);
1865
				conteneurChampEtenduDroite.setVisible(false);
1866
			} else {
1866
			} else {
1867
				redimensionnerChampsEtendus();
1867
				redimensionnerChampsEtendus();
1868
			}
1868
			}
1869
		} else {
1869
		} else {
1870
			lienAfficherChampsEtendus.setVisible(false);
1870
			lienAfficherChampsEtendus.setVisible(false);
1871
		}
1871
		}
1872
		doLayout();
1872
		doLayout();
1873
	}
1873
	}
1874
	
1874
	
1875
	private void redimensionnerChampsEtendus() {
1875
	private void redimensionnerChampsEtendus() {
1876
		int largeur = conteneurChampEtenduGauche.getWidth();
1876
		int largeur = conteneurChampEtenduGauche.getWidth();
1877
		if(largeur <= 0) {
1877
		if(largeur <= 0) {
1878
			Timer t = new Timer() {		
1878
			Timer t = new Timer() {		
1879
				@Override
1879
				@Override
1880
				public void run() {
1880
				public void run() {
1881
					redimensionnerChampsEtendus();
1881
					redimensionnerChampsEtendus();
1882
				}
1882
				}
1883
			};
1883
			};
1884
			t.schedule(150);
1884
			t.schedule(150);
1885
		} else {
1885
		} else {
1886
			for (Iterator<String> iterator = listeChampsEtendus.keySet().iterator(); iterator
1886
			for (Iterator<String> iterator = listeChampsEtendus.keySet().iterator(); iterator
1887
					.hasNext();) {
1887
					.hasNext();) {
1888
				ChampSaisieEtendu ch = listeChampsEtendus.get(iterator.next());
1888
				ChampSaisieEtendu ch = listeChampsEtendus.get(iterator.next());
1889
				ch.redimensionner(largeur - 15);	
1889
				ch.redimensionner(largeur - 15);	
1890
				if(ch.getFieldWidth() < ch.getLabelWidth()) {
1890
				if(ch.getFieldWidth() < ch.getLabelWidth()) {
1891
					ch.addClass("panneauModePetiteLargeur");
1891
					ch.addClass("panneauModePetiteLargeur");
1892
					ch.agrandirChamp(largeur - 82);
1892
					ch.agrandirChamp(largeur - 82);
1893
				} else {
1893
				} else {
1894
					//ch.removeClass("panneauModePetiteLargeur");
1894
					//ch.removeClass("panneauModePetiteLargeur");
1895
				}
1895
				}
1896
			}
1896
			}
1897
		}
1897
		}
1898
	}
1898
	}
1899
 
1899
 
1900
	private Map<String, ChampEtendu> getValeursChampsEtendus() {
1900
	private Map<String, ChampEtendu> getValeursChampsEtendus() {
1901
		Map<String, ChampEtendu> valeursChampsEtendus = new HashMap<String, ChampEtendu>();
1901
		Map<String, ChampEtendu> valeursChampsEtendus = new HashMap<String, ChampEtendu>();
1902
		if(listeChampsEtendus != null) {
1902
		if(listeChampsEtendus != null) {
1903
			for (Iterator<String> it = listeChampsEtendus.keySet().iterator(); it.hasNext();) {
1903
			for (Iterator<String> it = listeChampsEtendus.keySet().iterator(); it.hasNext();) {
1904
				String cle = it.next();
1904
				String cle = it.next();
1905
				ChampSaisieEtendu champTexteEtendu = listeChampsEtendus.get(cle);
1905
				ChampSaisieEtendu champTexteEtendu = listeChampsEtendus.get(cle);
1906
				String label = champTexteEtendu.getLabel();
1906
				String label = champTexteEtendu.getLabel();
1907
				String valeur = champTexteEtendu.getRawValue();
1907
				String valeur = champTexteEtendu.getRawValue();
1908
				ChampEtendu champEtendu = new ChampEtendu(cle, label, valeur);
1908
				ChampEtendu champEtendu = new ChampEtendu(cle, label, valeur);
1909
				valeursChampsEtendus.put(cle, champEtendu);
1909
				valeursChampsEtendus.put(cle, champEtendu);
1910
			}
1910
			}
1911
		}
1911
		}
1912
		return valeursChampsEtendus;
1912
		return valeursChampsEtendus;
1913
	}
1913
	}
1914
 
1914
 
1915
	public void raz()
1915
	public void raz()
1916
	{
1916
	{
1917
		raz(Champs.TOUT);
1917
		raz(Champs.TOUT);
1918
 
1918
 
1919
	}
1919
	}
1920
	public void raz(Champs champs)
1920
	public void raz(Champs champs)
1921
	{
1921
	{
1922
		switch (champs) {
1922
		switch (champs) {
1923
			case DATE:
1923
			case DATE:
1924
				date.reset() ;
1924
				date.reset() ;
1925
				break;
1925
				break;
1926
 
1926
 
1927
			case LIEUDIT:
1927
			case LIEUDIT:
1928
				lieudit.reset() ;
1928
				lieudit.reset() ;
1929
				break;
1929
				break;
1930
 
1930
 
1931
			case STATION:
1931
			case STATION:
1932
				station.reset() ;
1932
				station.reset() ;
1933
				break;
1933
				break;
1934
 
1934
 
1935
			case MILIEU:
1935
			case MILIEU:
1936
				milieu.reset() ;
1936
				milieu.reset() ;
1937
				break;
1937
				break;
1938
 
1938
 
1939
			case COMMENT:
1939
			case COMMENT:
1940
				comment.reset() ;
1940
				comment.reset() ;
1941
				break;
1941
				break;
1942
 
1942
 
1943
			case LOCALITE:
1943
			case LOCALITE:
1944
				localite.reset() ;
1944
				localite.reset() ;
1945
				codeLocalite ="";
1945
				codeLocalite ="";
1946
				pays="";
1946
				pays="";
1947
				latitude.reset();
1947
				latitude.reset();
1948
				longitude.reset();
1948
				longitude.reset();
1949
				break;
1949
				break;
1950
 
1950
 
1951
			case ESPECE:
1951
			case ESPECE:
1952
				espece.reset();
1952
				espece.reset();
1953
				numeroNom = "" ;
1953
				numeroNom = "" ;
1954
				numeroOrdre = "";
1954
				numeroOrdre = "";
1955
				break;
1955
				break;
1956
 
1956
 
1957
			case LATITUDE:
1957
			case LATITUDE:
1958
				latitude.reset();
1958
				latitude.reset();
1959
				afficherIndicationlocalite(null);
1959
				afficherIndicationlocalite(null);
1960
				break;
1960
				break;
1961
 
1961
 
1962
			case LONGITUDE:
1962
			case LONGITUDE:
1963
				longitude.reset();
1963
				longitude.reset();
1964
				afficherIndicationlocalite(null);
1964
				afficherIndicationlocalite(null);
1965
				break;
1965
				break;
1966
 
1966
 
1967
			case ALTITUDE:
1967
			case ALTITUDE:
1968
				altitude.reset();
1968
				altitude.reset();
1969
				break;
1969
				break;
1970
 
1970
 
1971
			case ABONDANCE:
1971
			case ABONDANCE:
1972
				selecteurAbondance.setValue("");
1972
				selecteurAbondance.setValue("");
1973
				break;
1973
				break;
1974
 
1974
 
1975
			case CERTITUDE:
1975
			case CERTITUDE:
1976
				selecteurCertitude.setValue("");
1976
				selecteurCertitude.setValue("");
1977
				break;
1977
				break;
1978
 
1978
 
1979
			case REFERENTIELTAXO:
1979
			case REFERENTIELTAXO:
1980
				selecteurReferentielTaxo.setValue("");
1980
				selecteurReferentielTaxo.setValue("");
1981
				break;
1981
				break;
1982
 
1982
 
1983
			case PHENOLOGIE:
1983
			case PHENOLOGIE:
1984
				selecteurStadePheno.setValue("");
1984
				selecteurStadePheno.setValue("");
1985
				break;
1985
				break;
1986
 
1986
 
1987
			case TOUT:
1987
			case TOUT:
1988
				localite.reset();
1988
				localite.reset();
1989
				date.reset() ;
1989
				date.reset() ;
1990
				lieudit.reset() ;
1990
				lieudit.reset() ;
1991
				station.reset() ;
1991
				station.reset() ;
1992
				milieu.reset() ;
1992
				milieu.reset() ;
1993
				comment.reset() ;
1993
				comment.reset() ;
1994
				milieu.reset() ;
1994
				milieu.reset() ;
1995
				latitude.reset();
1995
				latitude.reset();
1996
				longitude.reset();
1996
				longitude.reset();
1997
				altitude.reset();
1997
				altitude.reset();
1998
				pays="";
1998
				pays="";
1999
				codeLocalite ="";
1999
				codeLocalite ="";
2000
				espece.reset();
2000
				espece.reset();
2001
				selecteurAbondance.clearValue();
2001
				selecteurAbondance.clearValue();
2002
				selecteurCertitude.clearValue();
2002
				selecteurCertitude.clearValue();
2003
				selecteurReferentielTaxo.clearValue();
2003
				selecteurReferentielTaxo.clearValue();
2004
				selecteurStadePheno.clearValue();
2004
				selecteurStadePheno.clearValue();
2005
				referentielTaxo = "";
2005
				referentielTaxo = "";
2006
				numeroNom = "" ;
2006
				numeroNom = "" ;
2007
				numeroOrdre = "";
2007
				numeroOrdre = "";
2008
				afficherIndicationlocalite(null);
2008
				afficherIndicationlocalite(null);
2009
				break;
2009
				break;
2010
 
2010
 
2011
		}
2011
		}
2012
 
2012
 
2013
	}
2013
	}
2014
 
2014
 
2015
	public boolean verifierFormatDate(String date) {
2015
	public boolean verifierFormatDate(String date) {
2016
 
2016
 
2017
		String regex = "[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}" ;
2017
		String regex = "[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}" ;
2018
		if(date.matches(regex) && !date.equals("0000-00-00")) {
2018
		if(date.matches(regex) && !date.equals("0000-00-00")) {
2019
			return true ;
2019
			return true ;
2020
		}
2020
		}
2021
		else {
2021
		else {
2022
			return false;
2022
			return false;
2023
		}
2023
		}
2024
	}
2024
	}
2025
 
2025
 
2026
	public void setSelectionMultiple(boolean selectionMultiple) {
2026
	public void setSelectionMultiple(boolean selectionMultiple) {
2027
		this.selectionMultiple = selectionMultiple;
2027
		this.selectionMultiple = selectionMultiple;
2028
		if(!selectionMultiple) {
2028
		if(!selectionMultiple) {
2029
			boutonReinitialiser.enable();
2029
			boutonReinitialiser.enable();
2030
			boutonOK.enable();
2030
			boutonOK.enable();
2031
		} else {
2031
		} else {
2032
			boutonReinitialiser.disable();
2032
			boutonReinitialiser.disable();
2033
			boutonOK.disable();
2033
			boutonOK.disable();
2034
		}
2034
		}
2035
	}
2035
	}
2036
 
2036
 
2037
	public boolean getSelectionMultiple() {
2037
	public boolean getSelectionMultiple() {
2038
		return selectionMultiple;
2038
		return selectionMultiple;
2039
	}
2039
	}
2040
 
2040
 
2041
	private void calculerAfficherDifferences(ListeObservation listeObs) {
2041
	private void calculerAfficherDifferences(ListeObservation listeObs) {
2042
 
2042
 
2043
		String codeLocalite = null;
2043
		String codeLocalite = null;
2044
		String pays = null;
2044
		String pays = null;
2045
		String localite = null;
2045
		String localite = null;
2046
		String lieuDit = null;
2046
		String lieuDit = null;
2047
		String station = null;
2047
		String station = null;
2048
		String milieu = null;
2048
		String milieu = null;
2049
		String espece = null;
2049
		String espece = null;
2050
		String date = null;
2050
		String date = null;
2051
		String notes = null;
2051
		String notes = null;
2052
		String lat = null;
2052
		String lat = null;
2053
		String lon = null;
2053
		String lon = null;
2054
		String alt = null;
2054
		String alt = null;
2055
		String abondance = null;
2055
		String abondance = null;
2056
		String certitude = null;
2056
		String certitude = null;
2057
		String referentielTaxo = null;
2057
		String referentielTaxo = null;
2058
		String phenologie = null;
2058
		String phenologie = null;
2059
 
2059
 
2060
		String ordreObs = "";
2060
		String ordreObs = "";
2061
 
2061
 
2062
		for(Iterator<String> it = listeObs.keySet().iterator();it.hasNext();) {
2062
		for(Iterator<String> it = listeObs.keySet().iterator();it.hasNext();) {
2063
			Observation obsEnCours = listeObs.get(it.next());
2063
			Observation obsEnCours = listeObs.get(it.next());
2064
			pays = comparerDifferencesChamps(pays, obsEnCours.getPays());
2064
			pays = comparerDifferencesChamps(pays, obsEnCours.getPays());
2065
			codeLocalite = comparerDifferencesChamps(codeLocalite, obsEnCours.getIdentifiantLocalite());
2065
			codeLocalite = comparerDifferencesChamps(codeLocalite, obsEnCours.getIdentifiantLocalite());
2066
			localite = comparerDifferencesChamps(localite, obsEnCours.getLocalite());
2066
			localite = comparerDifferencesChamps(localite, obsEnCours.getLocalite());
2067
			lieuDit = comparerDifferencesChamps(lieuDit, obsEnCours.getLieudit());
2067
			lieuDit = comparerDifferencesChamps(lieuDit, obsEnCours.getLieudit());
2068
			station = comparerDifferencesChamps(station, obsEnCours.getStation());
2068
			station = comparerDifferencesChamps(station, obsEnCours.getStation());
2069
			milieu = comparerDifferencesChamps(milieu, obsEnCours.getMilieu());
2069
			milieu = comparerDifferencesChamps(milieu, obsEnCours.getMilieu());
2070
			espece = comparerDifferencesChamps(espece, obsEnCours.getNomSaisi());
2070
			espece = comparerDifferencesChamps(espece, obsEnCours.getNomSaisi());
2071
			date = comparerDifferencesChamps(date, obsEnCours.getDate());
2071
			date = comparerDifferencesChamps(date, obsEnCours.getDate());
2072
			notes = comparerDifferencesChamps(notes, obsEnCours.getCommentaire());
2072
			notes = comparerDifferencesChamps(notes, obsEnCours.getCommentaire());
2073
			lat = comparerDifferencesChamps(lat, obsEnCours.getLatitude());
2073
			lat = comparerDifferencesChamps(lat, obsEnCours.getLatitude());
2074
			lon = comparerDifferencesChamps(lon, obsEnCours.getLongitude());
2074
			lon = comparerDifferencesChamps(lon, obsEnCours.getLongitude());
2075
			alt = comparerDifferencesChamps(alt, obsEnCours.getAltitude());
2075
			alt = comparerDifferencesChamps(alt, obsEnCours.getAltitude());
2076
			abondance = comparerDifferencesChamps(abondance, obsEnCours.getAbondance());
2076
			abondance = comparerDifferencesChamps(abondance, obsEnCours.getAbondance());
2077
			certitude = comparerDifferencesChamps(certitude, obsEnCours.getCertitude());
2077
			certitude = comparerDifferencesChamps(certitude, obsEnCours.getCertitude());
2078
			referentielTaxo = comparerDifferencesChamps(referentielTaxo, obsEnCours.getReferentielTaxo());
2078
			referentielTaxo = comparerDifferencesChamps(referentielTaxo, obsEnCours.getReferentielTaxo());
2079
			phenologie = comparerDifferencesChamps(phenologie, obsEnCours.getPhenologie());
2079
			phenologie = comparerDifferencesChamps(phenologie, obsEnCours.getPhenologie());
2080
 
2080
 
2081
			ordreObs += obsEnCours.getNumeroOrdre()+",";
2081
			ordreObs += obsEnCours.getNumeroOrdre()+",";
2082
		}
2082
		}
2083
 
2083
 
2084
		Observation obs=new Observation(espece,numeroNom,localite,codeLocalite,lieuDit,station,milieu, notes,date);
2084
		Observation obs=new Observation(espece,numeroNom,localite,codeLocalite,lieuDit,station,milieu, notes,date);
2085
		obs.setPays(pays);
2085
		obs.setPays(pays);
2086
		obs.setNumeroOrdre(ordreObs);
2086
		obs.setNumeroOrdre(ordreObs);
2087
		obs.setLatitude(lat);
2087
		obs.setLatitude(lat);
2088
		obs.setLongitude(lon);
2088
		obs.setLongitude(lon);
2089
		obs.setAltitude(alt);
2089
		obs.setAltitude(alt);
2090
		obs.setAbondance(abondance);
2090
		obs.setAbondance(abondance);
2091
		obs.setCertitude(certitude);
2091
		obs.setCertitude(certitude);
2092
		obs.setReferentielTaxo(referentielTaxo);
2092
		obs.setReferentielTaxo(referentielTaxo);
2093
		obs.setPhenologie(phenologie);
2093
		obs.setPhenologie(phenologie);
2094
		afficherDetailsObservation(obs);
2094
		afficherDetailsObservation(obs);
2095
	}
2095
	}
2096
 
2096
 
2097
	private String comparerDifferencesChamps(String valeurActuelle, String nouvelleValeur) {
2097
	private String comparerDifferencesChamps(String valeurActuelle, String nouvelleValeur) {
2098
 
2098
 
2099
		String retour = "";
2099
		String retour = "";
2100
 
2100
 
2101
			if(valeurActuelle == null) {
2101
			if(valeurActuelle == null) {
2102
				retour = nouvelleValeur;
2102
				retour = nouvelleValeur;
2103
			} else {
2103
			} else {
2104
				if(valeurActuelle.equals(nouvelleValeur)) {
2104
				if(valeurActuelle.equals(nouvelleValeur)) {
2105
					retour = valeurActuelle;
2105
					retour = valeurActuelle;
2106
				} else {
2106
				} else {
2107
					retour = VALEURS_MULTIPLES;
2107
					retour = VALEURS_MULTIPLES;
2108
				}
2108
				}
2109
			}
2109
			}
2110
		return retour;
2110
		return retour;
2111
	}
2111
	}
2112
 
2112
 
2113
	private void reinitialiserValeurModifiees() {
2113
	private void reinitialiserValeurModifiees() {
2114
		localiteModifiee = false;
2114
		localiteModifiee = false;
2115
		lieuDitModifie = false;
2115
		lieuDitModifie = false;
2116
		stationModifiee = false;
2116
		stationModifiee = false;
2117
		milieuModifie = false;
2117
		milieuModifie = false;
2118
		dateModifiee = false;
2118
		dateModifiee = false;
2119
		especeModifiee = false;
2119
		especeModifiee = false;
2120
		commModifie = false;
2120
		commModifie = false;
2121
		latModifiee = false;
2121
		latModifiee = false;
2122
		longModifiee = false;
2122
		longModifiee = false;
2123
		altModifiee = false;
2123
		altModifiee = false;
2124
		abondanceModifiee = false;
2124
		abondanceModifiee = false;
2125
		certitudeModifiee = false;
2125
		certitudeModifiee = false;
2126
		referentielTaxoModifie = false;
2126
		referentielTaxoModifie = false;
2127
		phenologieModifiee = false;
2127
		phenologieModifiee = false;
2128
	}
2128
	}
2129
 
2129
 
2130
	public void saisieTabindex()
2130
	public void saisieTabindex()
2131
	{
2131
	{
2132
		localite.setTabIndex(1);
2132
		localite.setTabIndex(1);
2133
		lieudit.setTabIndex(3);
2133
		lieudit.setTabIndex(3);
2134
		station.setTabIndex(4);
2134
		station.setTabIndex(4);
2135
		milieu.setTabIndex(5);
2135
		milieu.setTabIndex(5);
2136
		coordonnees.setTabIndex(-1);
2136
		coordonnees.setTabIndex(-1);
2137
		coordonnees.addListener(new TextFieldListenerAdapter() {
2137
		coordonnees.addListener(new TextFieldListenerAdapter() {
2138
 
2138
 
2139
			@Override
2139
			@Override
2140
			public void onFocus(Field field) {
2140
			public void onFocus(Field field) {
2141
				if(coordPanel.isVisible()) {
2141
				if(coordPanel.isVisible()) {
2142
					latitude.focus();
2142
					latitude.focus();
2143
				} else {
2143
				} else {
2144
					Ext.get("lien_carto").focus();
2144
					Ext.get("lien_carto").focus();
2145
				}
2145
				}
2146
			}
2146
			}
2147
		});
2147
		});
2148
 
2148
 
2149
		latitude.setTabIndex(8);
2149
		latitude.setTabIndex(8);
2150
		longitude.setTabIndex(9);
2150
		longitude.setTabIndex(9);
2151
		altitude.setTabIndex(10);
2151
		altitude.setTabIndex(10);
2152
		comment.setTabIndex(11);
2152
		comment.setTabIndex(11);
2153
		date.setTabIndex(12);
2153
		date.setTabIndex(12);
2154
		espece.setTabIndex(13);
2154
		espece.setTabIndex(13);
2155
		selecteurCertitude.setTabIndex(14);
2155
		selecteurCertitude.setTabIndex(14);
2156
		selecteurAbondance.setTabIndex(15);
2156
		selecteurAbondance.setTabIndex(15);
2157
		selecteurStadePheno.setTabIndex(16);
2157
		selecteurStadePheno.setTabIndex(16);
2158
		boutonOK.setTabIndex(17);
2158
		boutonOK.setTabIndex(17);
2159
		boutonReinitialiser.setTabIndex(18);
2159
		boutonReinitialiser.setTabIndex(18);
2160
 
2160
 
2161
	}
2161
	}
2162
 
2162
 
2163
	private void obtenirInformationCoord() {
2163
	private void obtenirInformationCoord() {
2164
		if(coordonneesValides() != null) {
2164
		if(coordonneesValides() != null) {
2165
			observationMediateur.obtenirInformationCoord(coordonneesValides()[0],coordonneesValides()[1]);
2165
			observationMediateur.obtenirInformationCoord(coordonneesValides()[0],coordonneesValides()[1]);
2166
		} else {
2166
		} else {
2167
			// Centrage de la carte sur une zone correspondant plus ou moins au référentiel.
2167
			// Centrage de la carte sur une zone correspondant plus ou moins au référentiel.
2168
			// En dur car la config est tellement mal foutue que j'ai envie de me pendre.
2168
			// En dur car la config est tellement mal foutue que j'ai envie de me pendre.
2169
			String referentiel = this.getReferentielTaxo();
2169
			String referentiel = this.getReferentielTaxo();
2170
			String referentielRacine = referentiel.substring(0, referentiel.indexOf(':'));
2170
			String referentielRacine = referentiel.substring(0, referentiel.indexOf(':'));
2171
			Double lat = null, lon = null;
2171
			Double lat = null, lon = null;
2172
			int zoom = 6;
2172
			int zoom = 6;
2173
			switch(referentielRacine) {
2173
			switch(referentielRacine) {
2174
				case "bdtre" :
2174
				case "bdtre" :
2175
					lat = -21.10;
2175
					lat = -21.10;
2176
					lon = 55.30;
2176
					lon = 55.30;
2177
					zoom = 7;
2177
					zoom = 7;
2178
				break;
2178
				break;
2179
				case "isfan" :
2179
				case "isfan" :
2180
					lat = 29.28358;
2180
					lat = 29.28358;
2181
					lon = 10.21884;
2181
					lon = 10.21884;
2182
					zoom = 5;
2182
					zoom = 5;
2183
					break;
2183
					break;
2184
				case "apd" :
2184
				case "apd" :
2185
					lat = 8.75624;
2185
					lat = 8.75624;
2186
					lon = 1.80176;
2186
					lon = 1.80176;
2187
					zoom = 5;
2187
					zoom = 5;
2188
					break;
2188
					break;
2189
				case "bdtxa" :
2189
				case "bdtxa" :
2190
					lat = 14.6;
2190
					lat = 14.6;
2191
					lon = -61.08334;
2191
					lon = -61.08334;
2192
					zoom = 7;
2192
					zoom = 7;
2193
					break;
2193
					break;
2194
				case "lbf" :
2194
				case "lbf" :
2195
					lat = 33.53;
2195
					lat = 33.53;
2196
					lon = 35.30;
2196
					lon = 35.30;
2197
					zoom = 7;
2197
					zoom = 7;
2198
					break;
2198
					break;
2199
				case "bdtfx" :
2199
				case "bdtfx" :
2200
				default:
2200
				default:
2201
					lat = 47.0504;
2201
					lat = 47.0504;
2202
					lon = 2.2347;
2202
					lon = 2.2347;
2203
					zoom = 6;
2203
					zoom = 6;
2204
			}
2204
			}
2205
			if (lat != null && lon != null) {
2205
			if (lat != null && lon != null) {
2206
				// centrage sur la zone
2206
				// centrage sur la zone
2207
				EntiteGeographiqueObservation infos = new EntiteGeographiqueObservation();
2207
				EntiteGeographiqueObservation infos = new EntiteGeographiqueObservation();
2208
				infos.setLon("" + lon);
2208
				infos.setLon("" + lon);
2209
				infos.setLat("" + lat);
2209
				infos.setLat("" + lat);
2210
				infos.setZoom(zoom);
2210
				infos.setZoom(zoom);
2211
				observationMediateur.rafraichirFenetreCartoSurPoint(infos);
2211
				observationMediateur.rafraichirFenetreCartoSurPoint(infos);
2212
			} else {
2212
			} else {
2213
				// affichage par défaut au cas où on n'aurait pas trouvé de coordonnées pour centrer
2213
				// affichage par défaut au cas où on n'aurait pas trouvé de coordonnées pour centrer
2214
				observationMediateur.afficherFenetreCarto();
2214
				observationMediateur.afficherFenetreCarto();
2215
			}
2215
			}
2216
		}
2216
		}
2217
	}
2217
	}
2218
 
2218
 
2219
	private void obtenirInformationLocalite() {
2219
	private void obtenirInformationLocalite() {
2220
		String idLoc = obtenirIdLocalite();
2220
		String idLoc = obtenirIdLocalite();
2221
		observationMediateur.obtenirInformationLocalite(getlocaliteSansIdLoc(), idLoc);
2221
		observationMediateur.obtenirInformationLocalite(getlocaliteSansIdLoc(), idLoc);
2222
	}
2222
	}
2223
	
2223
	
2224
	private String obtenirIdLocalite() {
2224
	private String obtenirIdLocalite() {
2225
		String idLoc = "";
2225
		String idLoc = "";
2226
		
2226
		
2227
		// Soit un numéro de département, soit un code de pays à deux lettres
2227
		// Soit un numéro de département, soit un code de pays à deux lettres
2228
		String[] codeCom = localite.getText().split(" ");
2228
		String[] codeCom = localite.getText().split(" ");
2229
		if(codeCom.length > 1 && ressembleAUnCodePaysOuDepartement(codeCom[codeCom.length - 1])) {
2229
		if(codeCom.length > 1 && ressembleAUnCodePaysOuDepartement(codeCom[codeCom.length - 1])) {
2230
			String codeLoc = codeCom[codeCom.length - 1].replace('(', ' ');
2230
			String codeLoc = codeCom[codeCom.length - 1].replace('(', ' ');
2231
			codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
2231
			codeLoc = codeLoc.replace(')', ' ').trim().replace('\\',' ').trim();
2232
 
2232
 
2233
			if(Util.estUnNombre(codeLoc)) {
2233
			if(Util.estUnNombre(codeLoc)) {
2234
				idLoc = codeLoc ;
2234
				idLoc = codeLoc ;
2235
			} else {
2235
			} else {
2236
				idLoc = codeLoc.toUpperCase();
2236
				idLoc = codeLoc.toUpperCase();
2237
			}
2237
			}
2238
		}
2238
		}
2239
		
2239
		
2240
		return idLoc;
2240
		return idLoc;
2241
	}
2241
	}
2242
 
2242
 
2243
	public double[] coordonneesValides() {
2243
	public double[] coordonneesValides() {
2244
		try {
2244
		try {
2245
 
2245
 
2246
			double lat = Double.parseDouble(latitude.getValueAsString().replaceAll(",", "."));
2246
			double lat = Double.parseDouble(latitude.getValueAsString().replaceAll(",", "."));
2247
			double lon = Double.parseDouble(longitude.getValueAsString().replaceAll(",", "."));
2247
			double lon = Double.parseDouble(longitude.getValueAsString().replaceAll(",", "."));
2248
 
2248
 
2249
			double[] coord = {lat, lon};
2249
			double[] coord = {lat, lon};
2250
			return coord;
2250
			return coord;
2251
 
2251
 
2252
		} catch (NumberFormatException ne) {
2252
		} catch (NumberFormatException ne) {
2253
			return null;
2253
			return null;
2254
		}
2254
		}
2255
	}
2255
	}
2256
 
2256
 
2257
	private String[] getValeurCoordonnees() {
2257
	private String[] getValeurCoordonnees() {
2258
		double[] coDouble = coordonneesValides();
2258
		double[] coDouble = coordonneesValides();
2259
 
2259
 
2260
		if(coDouble != null) {
2260
		if(coDouble != null) {
2261
			String[] coord = {coDouble[0]+"",coDouble[1]+""};
2261
			String[] coord = {coDouble[0]+"",coDouble[1]+""};
2262
			return coord;
2262
			return coord;
2263
		} else {
2263
		} else {
2264
			String[] coord = {"","" };
2264
			String[] coord = {"","" };
2265
			return coord;
2265
			return coord;
2266
		}
2266
		}
2267
	}
2267
	}
2268
 
2268
 
2269
	public String getlocalite() {
2269
	public String getlocalite() {
2270
 
2270
 
2271
		String valeurlocalite = "";
2271
		String valeurlocalite = "";
2272
 
2272
 
2273
		if(localite.getText() != null) {
2273
		if(localite.getText() != null) {
2274
			valeurlocalite = localite.getText();
2274
			valeurlocalite = localite.getText();
2275
		}
2275
		}
2276
		return valeurlocalite;
2276
		return valeurlocalite;
2277
	}
2277
	}
2278
 
2278
 
2279
	public String getlocaliteSansIdLoc() {
2279
	public String getlocaliteSansIdLoc() {
2280
		return Util.supprimerChaineIdLocalite(getlocalite());
2280
		return Util.supprimerChaineIdLocalite(getlocalite());
2281
	}
2281
	}
2282
 
2282
 
2283
	private String getValeurChampListeLibre(ComboBox champ) {
2283
	private String getValeurChampListeLibre(ComboBox champ) {
2284
		String valeurChamp = champ.getValue();
2284
		String valeurChamp = champ.getValue();
2285
		String valeurChampBrute = champ.getRawValue();
2285
		String valeurChampBrute = champ.getRawValue();
2286
 
2286
 
2287
		// Test idiot qui permet de savoir si l'on utilise la valeur saisie directement ou bien la valeur
2287
		// Test idiot qui permet de savoir si l'on utilise la valeur saisie directement ou bien la valeur
2288
		// selectionnee car lors du setValue sur le keypress, gwtext ne prends pas en compte le dernier
2288
		// selectionnee car lors du setValue sur le keypress, gwtext ne prends pas en compte le dernier
2289
		// caractère
2289
		// caractère
2290
		if(valeurChampBrute.trim().length() == 0) {
2290
		if(valeurChampBrute.trim().length() == 0) {
2291
			valeurChamp = "";
2291
			valeurChamp = "";
2292
		} else {
2292
		} else {
2293
			if(valeurChamp != null && valeurChamp.length() > 0) {
2293
			if(valeurChamp != null && valeurChamp.length() > 0) {
2294
				if(valeurChamp.equals(valeurChampBrute.substring(0, valeurChampBrute.length() -1))) {
2294
				if(valeurChamp.equals(valeurChampBrute.substring(0, valeurChampBrute.length() -1))) {
2295
					valeurChamp = champ.getRawValue();
2295
					valeurChamp = champ.getRawValue();
2296
				}
2296
				}
2297
			}
2297
			}
2298
		}
2298
		}
2299
		return valeurChamp;
2299
		return valeurChamp;
2300
	}
2300
	}
2301
 
2301
 
2302
	public String getAbondance() {
2302
	public String getAbondance() {
2303
		return getValeurChampListeLibre(selecteurAbondance);
2303
		return getValeurChampListeLibre(selecteurAbondance);
2304
	}
2304
	}
2305
 
2305
 
2306
	public String getCertitude() {
2306
	public String getCertitude() {
2307
		return getValeurChampListeLibre(selecteurCertitude);
2307
		return getValeurChampListeLibre(selecteurCertitude);
2308
	}
2308
	}
2309
 
2309
 
2310
	public String getPhenologie() {
2310
	public String getPhenologie() {
2311
		return getValeurChampListeLibre(selecteurStadePheno);
2311
		return getValeurChampListeLibre(selecteurStadePheno);
2312
	}
2312
	}
2313
 
2313
 
2314
	public String getReferentielTaxo() {
2314
	public String getReferentielTaxo() {
2315
		String codeCourt = getValeurChampListeLibre(selecteurReferentielTaxo);
2315
		String codeCourt = getValeurChampListeLibre(selecteurReferentielTaxo);
2316
		return Ontologies.getInfosReferentielNomParCode(codeCourt).getCodeVersionComplet();
2316
		return Ontologies.getInfosReferentielNomParCode(codeCourt).getCodeVersionComplet();
2317
	}
2317
	}
2318
 
2318
 
2319
	public boolean localiteInitialisee() {
2319
	public boolean localiteInitialisee() {
2320
		return localiteModifiee;
2320
		return localiteModifiee;
2321
	}
2321
	}
2322
 
2322
 
2323
	public void redimensionnerFormulaire() {
2323
	public void redimensionnerFormulaire() {
2324
		afficherFormulaireLatLon.setWidth(panneauIntermediaire.getWidth()+"px");
2324
		afficherFormulaireLatLon.setWidth(panneauIntermediaire.getWidth()+"px");
2325
		panneauPremierColonne.doLayout();
2325
		panneauPremierColonne.doLayout();
2326
		panneauSecondeColonne.doLayout();
2326
		panneauSecondeColonne.doLayout();
2327
		panneauIntermediaire.doLayout();
2327
		panneauIntermediaire.doLayout();
2328
 
2328
 
2329
		doLayout();
2329
		doLayout();
2330
	}
2330
	}
2331
	
2331
	
2332
	private void verifierPresenceTaxonSaisi() {
2332
	private void verifierPresenceTaxonSaisi() {
2333
		affecterCodeLocaliteOuPays();
2333
		affecterCodeLocaliteOuPays();
2334
		if(!enRequeteChrologie && !codeLocalite.isEmpty() && numeroNom != null && !numeroNom.isEmpty()) {
2334
		if(!enRequeteChrologie && !codeLocalite.isEmpty() && numeroNom != null && !numeroNom.isEmpty()) {
2335
			enRequeteChrologie = true;
2335
			enRequeteChrologie = true;
2336
			// Pour le moment, si on a un code localité, c'est qu'on est en France
2336
			// Pour le moment, si on a un code localité, c'est qu'on est en France
2337
			final String paysStr = pays.isEmpty() ? "FR" : pays;
2337
			final String paysStr = pays.isEmpty() ? "FR" : pays;
2338
			final String cleCache = numeroNom.trim()+paysStr.trim()+codeLocalite.trim();
2338
			final String cleCache = numeroNom.trim()+paysStr.trim()+codeLocalite.trim();
2339
 
2339
 
2340
			// Pour éviter de vérifier et d'afficher plus d'une fois l'avertissement de présence
2340
			// Pour éviter de vérifier et d'afficher plus d'une fois l'avertissement de présence
2341
			if(!avertissementPresence.containsKey(numeroNom.trim()+paysStr.trim()+codeLocalite.trim())) {
2341
			if(!avertissementPresence.containsKey(cleCache)) {
2342
				// Pour l'instant c'est toujours France mais il serait bon un jour d'avoir une chorologie multi pays.
2342
				// Pour l'instant c'est toujours France mais il serait bon un jour d'avoir une chorologie multi pays.
2343
				// donc ça ne coute rien de le gérer déjà ici dans l'interface
2343
				// donc ça ne coute rien de le gérer déjà ici dans l'interface
2344
				ImageInformationRepartitionAsynchroneDAO.taxonEstPresentDansZoneGeo(referentielTaxo, numeroNom, paysStr, codeLocalite, new Callback<String, String>() {			
2344
				ImageInformationRepartitionAsynchroneDAO.taxonEstPresentDansZoneGeo(referentielTaxo, numeroNom, paysStr, codeLocalite, new Callback<String, String>() {			
2345
					@Override
2345
					@Override
2346
					public void onSuccess(String result) {
2346
					public void onSuccess(String result) {
2347
						
2347
						
2348
						// En cas d'absence d'infos sur la zone le service retourne "" (chaîne vide)
2348
						// En cas d'absence d'infos sur la zone le service retourne "" (chaîne vide)
2349
						// En cas de non signalement dans la zone, il retourne 0, 
2349
						// En cas de non signalement dans la zone, il retourne 0, 
2350
						// En cas de présence, il retourne 1 
2350
						// En cas de présence, il retourne 1 
2351
						if(result.equals("0")) {
2351
						if(result.equals("0")) {
2352
							// L'absence explicite est le seul cas qui nous interesse
2352
							// L'absence explicite est le seul cas qui nous interesse
2353
							String[] stParams = {espece.getText(), codeLocalite, Configuration.getChorologieAvertissementCourriel()};
2353
							String[] stParams = {espece.getText(), codeLocalite, Configuration.getChorologieAvertissementCourriel()};
2354
							String message = Msg.get("indication-premiere-presence", stParams);
2354
							String message = Msg.get("indication-premiere-presence", stParams);
2355
							
2355
							
2356
							Window.alert(message);
2356
							Window.alert(message);
2357
						}
2357
						}
2358
 
2358
 
2359
						avertissementPresence.put(cleCache, result);
2359
						avertissementPresence.put(cleCache, result);
2360
						enRequeteChrologie = false;
2360
						enRequeteChrologie = false;
2361
					}
2361
					}
2362
					
2362
					
2363
					@Override
2363
					@Override
2364
					public void onFailure(String reason) {
2364
					public void onFailure(String reason) {
2365
						enRequeteChrologie = false;
2365
						enRequeteChrologie = false;
2366
					}
2366
					}
2367
				});
2367
				});
2368
			} else {
2368
			} else {
2369
				enRequeteChrologie = false;
2369
				enRequeteChrologie = false;
2370
			}
2370
			}
2371
		}
2371
		}
2372
	}
2372
	}
2373
}
2373
}