Subversion Repositories eFlore/Applications.cel

Rev

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

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