Subversion Repositories eFlore/Applications.cel

Rev

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

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