Subversion Repositories eFlore/Applications.cel

Rev

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

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