Subversion Repositories eFlore/Applications.cel

Rev

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

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