Subversion Repositories eFlore/Applications.cel

Rev

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

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