Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 1551 Rev 1557
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.Iterator;
6
import java.util.Iterator;
7
 
7
 
8
import org.tela_botanica.client.CarnetEnLigneMediateur;
8
import org.tela_botanica.client.CarnetEnLigneMediateur;
9
import org.tela_botanica.client.interfaces.Rafraichissable;
9
import org.tela_botanica.client.interfaces.Rafraichissable;
10
import org.tela_botanica.client.modeles.objets.Configuration;
10
import org.tela_botanica.client.modeles.objets.Configuration;
11
import org.tela_botanica.client.modeles.objets.EntiteGeographiqueObservation;
11
import org.tela_botanica.client.modeles.objets.EntiteGeographiqueObservation;
12
import org.tela_botanica.client.modeles.objets.ListeObservation;
12
import org.tela_botanica.client.modeles.objets.ListeObservation;
13
import org.tela_botanica.client.modeles.objets.ListeReferentielCommune;
13
import org.tela_botanica.client.modeles.objets.ListeReferentielCommune;
14
import org.tela_botanica.client.modeles.objets.ListeReferentielNom;
14
import org.tela_botanica.client.modeles.objets.ListeReferentielNom;
15
import org.tela_botanica.client.modeles.objets.Observation;
15
import org.tela_botanica.client.modeles.objets.Observation;
16
import org.tela_botanica.client.modeles.objets.Ontologies;
16
import org.tela_botanica.client.modeles.objets.Ontologies;
17
import org.tela_botanica.client.modeles.objets.ReferentielCommune;
17
import org.tela_botanica.client.modeles.objets.ReferentielCommune;
18
import org.tela_botanica.client.modeles.objets.ReferentielNom;
18
import org.tela_botanica.client.modeles.objets.ReferentielNom;
19
import org.tela_botanica.client.modeles.objets.ListeReferentielPerso.TypesReferentiels;
19
import org.tela_botanica.client.modeles.objets.ListeReferentielPerso.TypesReferentiels;
20
import org.tela_botanica.client.observation.ObservationMediateur;
20
import org.tela_botanica.client.observation.ObservationMediateur;
21
import org.tela_botanica.client.util.AutoCompletionRefComboBox;
21
import org.tela_botanica.client.util.AutoCompletionRefComboBox;
22
import org.tela_botanica.client.util.Util;
22
import org.tela_botanica.client.util.Util;
23
 
23
 
24
import com.google.gwt.maps.client.geom.LatLng;
24
import com.google.gwt.maps.client.geom.LatLng;
25
import com.google.gwt.user.client.Timer;
25
import com.google.gwt.user.client.Timer;
26
import com.google.gwt.user.client.Window;
26
import com.google.gwt.user.client.Window;
27
import com.google.gwt.user.client.ui.HTML;
27
import com.google.gwt.user.client.ui.HTML;
28
import com.gwtext.client.core.EventCallback;
28
import com.gwtext.client.core.EventCallback;
29
import com.gwtext.client.core.EventObject;
29
import com.gwtext.client.core.EventObject;
30
import com.gwtext.client.core.Ext;
30
import com.gwtext.client.core.Ext;
31
import com.gwtext.client.core.ExtElement;
31
import com.gwtext.client.core.ExtElement;
32
import com.gwtext.client.core.ListenerConfig;
32
import com.gwtext.client.core.ListenerConfig;
33
import com.gwtext.client.core.Position;
33
import com.gwtext.client.core.Position;
34
import com.gwtext.client.data.ArrayReader;
34
import com.gwtext.client.data.ArrayReader;
35
import com.gwtext.client.data.FieldDef;
35
import com.gwtext.client.data.FieldDef;
36
import com.gwtext.client.data.MemoryProxy;
36
import com.gwtext.client.data.MemoryProxy;
37
import com.gwtext.client.data.RecordDef;
37
import com.gwtext.client.data.RecordDef;
38
import com.gwtext.client.data.SimpleStore;
38
import com.gwtext.client.data.SimpleStore;
39
import com.gwtext.client.data.Store;
39
import com.gwtext.client.data.Store;
40
import com.gwtext.client.data.StringFieldDef;
40
import com.gwtext.client.data.StringFieldDef;
41
import com.gwtext.client.widgets.BoxComponent;
41
import com.gwtext.client.widgets.BoxComponent;
42
import com.gwtext.client.widgets.Button;
42
import com.gwtext.client.widgets.Button;
43
import com.gwtext.client.widgets.Container;
43
import com.gwtext.client.widgets.Container;
44
import com.gwtext.client.widgets.DatePicker;
44
import com.gwtext.client.widgets.DatePicker;
45
import com.gwtext.client.widgets.Panel;
45
import com.gwtext.client.widgets.Panel;
46
import com.gwtext.client.widgets.ToolTip;
46
import com.gwtext.client.widgets.ToolTip;
47
import com.gwtext.client.widgets.Toolbar;
47
import com.gwtext.client.widgets.Toolbar;
48
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
48
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
49
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
49
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
50
import com.gwtext.client.widgets.event.DatePickerListenerAdapter;
50
import com.gwtext.client.widgets.event.DatePickerListenerAdapter;
51
import com.gwtext.client.widgets.event.PanelListenerAdapter;
51
import com.gwtext.client.widgets.event.PanelListenerAdapter;
52
import com.gwtext.client.widgets.form.ComboBox;
52
import com.gwtext.client.widgets.form.ComboBox;
53
import com.gwtext.client.widgets.form.DateField;
53
import com.gwtext.client.widgets.form.DateField;
54
import com.gwtext.client.widgets.form.Field;
54
import com.gwtext.client.widgets.form.Field;
55
import com.gwtext.client.widgets.form.FormPanel;
55
import com.gwtext.client.widgets.form.FormPanel;
56
import com.gwtext.client.widgets.form.Label;
56
import com.gwtext.client.widgets.form.Label;
57
import com.gwtext.client.widgets.form.MultiFieldPanel;
57
import com.gwtext.client.widgets.form.MultiFieldPanel;
58
import com.gwtext.client.widgets.form.TextArea;
58
import com.gwtext.client.widgets.form.TextArea;
59
import com.gwtext.client.widgets.form.TextField;
59
import com.gwtext.client.widgets.form.TextField;
60
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
60
import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
61
import com.gwtext.client.widgets.form.event.TextFieldListenerAdapter;
61
import com.gwtext.client.widgets.form.event.TextFieldListenerAdapter;
62
import com.gwtext.client.widgets.layout.AnchorLayoutData;
62
import com.gwtext.client.widgets.layout.AnchorLayoutData;
63
import com.gwtext.client.widgets.layout.ColumnLayout;
63
import com.gwtext.client.widgets.layout.ColumnLayout;
64
import com.gwtext.client.widgets.layout.ColumnLayoutData;
64
import com.gwtext.client.widgets.layout.ColumnLayoutData;
65
import com.gwtext.client.widgets.layout.FormLayout;
65
import com.gwtext.client.widgets.layout.FormLayout;
66
import com.gwtext.client.widgets.layout.RowLayout;
66
import com.gwtext.client.widgets.layout.RowLayout;
67
import com.gwtext.client.data.Record;
67
import com.gwtext.client.data.Record;
68
 
68
 
69
/**
69
/**
70
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
70
 * Panneau contenant les infos, les métadonnées et l'arbre des mots clés, il implémente l'interface rafraichissable
71
 * @author aurelien
71
 * @author aurelien
72
 *
72
 *
73
 */
73
 */
74
public class FormulaireSaisieObservationVue extends Panel implements Rafraichissable  {
74
public class FormulaireSaisieObservationVue extends Panel implements Rafraichissable  {
75
 
75
 
76
 
76
 
77
	/**
77
	/**
78
	 * Le médiateur associé à la vue
78
	 * Le médiateur associé à la vue
79
	 */
79
	 */
80
	private ObservationMediateur	observationMediateur		= null;
80
	private ObservationMediateur	observationMediateur		= null;
81
	
81
	
82
	FormPanel panneauFormulaire = null;
82
	FormPanel panneauFormulaire = null;
83
 
83
 
84
	private DateField date = null;
84
	private DateField date = null;
85
	private ComboBox lieudit = null;
85
	private ComboBox lieudit = null;
86
	private ComboBox station = null;
86
	private ComboBox station = null;
87
	private ComboBox milieu = null;
87
	private ComboBox milieu = null;
88
	private TextField comment = null;
88
	private TextField comment = null;
89
	private ComboBox  commune = null;
89
	private ComboBox  commune = null;
90
	private String departement = null;
90
	private String departement = null;
91
	private ComboBox  espece = null;
91
	private ComboBox  espece = null;
92
	private String numeroNom = null;
92
	private String numeroNom = null;
93
	private String numeroOrdre = null;
93
	private String numeroOrdre = null;
94
	private String codeInseeCommune = null;
94
	private String codeInseeCommune = null;
95
	private String referentielTaxo = null;
95
	private String referentielTaxo = null;
96
	private String referentielGeo = null;
96
	private String referentielGeo = null;
97
 
97
 
98
	// Pour remise a zero partielle lors d'une validation
98
	// Pour remise a zero partielle lors d'une validation
99
	
99
	
100
	private  enum Champs {
100
	private  enum Champs {
101
	    DATE, LIEUDIT, STATION, MILIEU, COMMENT, COMMUNE, ESPECE, TOUT, LATITUDE, LONGITUDE, ABONDANCE, CERTITUDE, REFERENTIELTAXO, PHENOLOGIE;
101
	    DATE, LIEUDIT, STATION, MILIEU, COMMENT, COMMUNE, ESPECE, TOUT, LATITUDE, LONGITUDE, ABONDANCE, CERTITUDE, REFERENTIELTAXO, PHENOLOGIE;
102
	    
102
	    
103
	    @Override
103
	    @Override
104
		public String toString() {
104
		public String toString() {
105
	    	
105
	    	
106
	    	switch(this) {
106
	    	switch(this) {
107
	    	case DATE:
107
	    	case DATE:
108
	    		return "date";
108
	    		return "date";
109
	    		
109
	    		
110
	    	case COMMUNE:
110
	    	case COMMUNE:
111
	    		return "commune";
111
	    		return "commune";
112
	    	
112
	    	
113
    		case LIEUDIT:
113
    		case LIEUDIT:
114
    			return "lieu dit";
114
    			return "lieu dit";
115
	    	
115
	    	
116
    		case STATION:
116
    		case STATION:
117
    			return "station";
117
    			return "station";
118
	    	
118
	    	
119
    		case MILIEU:
119
    		case MILIEU:
120
    			return "milieu";
120
    			return "milieu";
121
	    	
121
	    	
122
    		case COMMENT:
122
    		case COMMENT:
123
    			return "commentaire";
123
    			return "commentaire";
124
	    	
124
	    	
125
	    	case ESPECE:
125
	    	case ESPECE:
126
	    		return "espèce";
126
	    		return "espèce";
127
	    		
127
	    		
128
	    	case LATITUDE:
128
	    	case LATITUDE:
129
	    		return "latitude";
129
	    		return "latitude";
130
	    		
130
	    		
131
	    	case LONGITUDE:
131
	    	case LONGITUDE:
132
	    		return "longitude";
132
	    		return "longitude";
133
	    		
133
	    		
134
	    	case ABONDANCE:
134
	    	case ABONDANCE:
135
	    		return "abondance";
135
	    		return "abondance";
136
	    		
136
	    		
137
	    	case CERTITUDE:
137
	    	case CERTITUDE:
138
	    		return "identification";
138
	    		return "identification";
139
	    		
139
	    		
140
	    	case REFERENTIELTAXO:
140
	    	case REFERENTIELTAXO:
141
	    		return "referentiel";
141
	    		return "referentiel";
142
	    	
142
	    	
143
	    	case PHENOLOGIE:
143
	    	case PHENOLOGIE:
144
	    		return "phenologie";
144
	    		return "phenologie";
145
	    		
145
	    		
146
	    	case TOUT:
146
	    	case TOUT:
147
	    		return "date, commune, lieu dit, station, milieu, espèce, commentaire, latitude, longitude, abondance, identification, referentiel, phenologie";
147
	    		return "date, commune, lieu dit, station, milieu, espèce, commentaire, latitude, longitude, abondance, identification, referentiel, phenologie";
148
	    	}
148
	    	}
149
			return TOUT.toString();
149
			return TOUT.toString();
150
	    }
150
	    }
151
	};
151
	};
152
	
152
	
153
	private String formatDate = null ;
153
	private String formatDate = null ;
154
	private Button boutonOK = new Button("Créer");
154
	private Button boutonOK = new Button("Créer");
155
	private Button boutonAnnuler = new Button("Réinitialiser");
155
	private Button boutonAnnuler = new Button("Réinitialiser");
156
 
156
 
157
	private boolean selectionCommune=false;
157
	private boolean selectionCommune=false;
158
	private boolean selectionEspece=false;
158
	private boolean selectionEspece=false;
159
	private boolean selectionAbondance = false;
159
	private boolean selectionAbondance = false;
160
	private boolean selectionCertitude = false;
160
	private boolean selectionCertitude = false;
161
	private boolean selectionPhenologie = false;
161
	private boolean selectionPhenologie = false;
162
	
162
	
163
	private boolean modification = false ;
163
	private boolean modification = false ;
164
	private Toolbar bt = null ;
164
	private Toolbar bt = null ;
165
	
165
	
166
	private final String VALEURS_MULTIPLES = "(Valeurs multiples)";
166
	private final String VALEURS_MULTIPLES = "(Valeurs multiples)";
167
	private final String modeleMessageModif = "commune:lieu-dit:station:milieu:latitude:longitude:date:espece:commentaire:abondance:identification:referentiel:phenologie";
167
	private final String modeleMessageModif = "commune:lieu-dit:station:milieu:latitude:longitude:date:espece:commentaire:abondance:identification:referentiel:phenologie";
168
	private boolean communeModifiee = false;
168
	private boolean communeModifiee = false;
169
	private boolean lieuDitModifie = false;
169
	private boolean lieuDitModifie = false;
170
	private boolean stationModifiee = false;
170
	private boolean stationModifiee = false;
171
	private boolean milieuModifie = false;
171
	private boolean milieuModifie = false;
172
	private boolean dateModifiee = false;
172
	private boolean dateModifiee = false;
173
	private boolean especeModifiee = false;
173
	private boolean especeModifiee = false;
174
	private boolean commModifie = false;
174
	private boolean commModifie = false;
175
	private boolean abondanceModifiee = false;
175
	private boolean abondanceModifiee = false;
176
	private boolean certitudeModifiee = false;
176
	private boolean certitudeModifiee = false;
177
	private boolean referentielTaxoModifie = false;
177
	private boolean referentielTaxoModifie = false;
178
	private boolean phenologieModifiee = false;;
178
	private boolean phenologieModifiee = false;;
179
	
179
	
180
	private final int KEY_ALT = 18;
180
	private final int KEY_ALT = 18;
181
	private final int KEY_BACKSPACE = 8;
181
	private final int KEY_BACKSPACE = 8;
182
	private final int KEY_CTRL = 17;
182
	private final int KEY_CTRL = 17;
183
	private final int KEY_DELETE = 46;
183
	private final int KEY_DELETE = 46;
184
	private final int KEY_DOWN = 40;
184
	private final int KEY_DOWN = 40;
185
	private final int KEY_END = 35;
185
	private final int KEY_END = 35;
186
	private final int KEY_ENTER = 13;
186
	private final int KEY_ENTER = 13;
187
	private final int KEY_ESCAPE = 27;
187
	private final int KEY_ESCAPE = 27;
188
	private final int KEY_HOME = 36;
188
	private final int KEY_HOME = 36;
189
	private final int KEY_LEFT = 37;
189
	private final int KEY_LEFT = 37;
190
	private final int KEY_PAGEDOWN = 34;
190
	private final int KEY_PAGEDOWN = 34;
191
	private final int KEY_PAGEUP = 33;
191
	private final int KEY_PAGEUP = 33;
192
	private final int KEY_RIGHT = 39;
192
	private final int KEY_RIGHT = 39;
193
	private final int KEY_SHIFT = 16;
193
	private final int KEY_SHIFT = 16;
194
	private final int KEY_TAB = 9;
194
	private final int KEY_TAB = 9;
195
	private final int KEY_UP = 38;
195
	private final int KEY_UP = 38;
196
	
196
	
197
	
197
	
198
	/**
198
	/**
199
	 * Combobox permettant de selectionner le mode
199
	 * Combobox permettant de selectionner le mode
200
	 * modification ou bien création
200
	 * modification ou bien création
201
	 */
201
	 */
202
	private ComboBox selecteurMode = new ComboBox();
202
	private ComboBox selecteurMode = new ComboBox();
203
	
203
	
204
	Store storeMode = null ;
204
	Store storeMode = null ;
205
 
205
 
206
	/**
206
	/**
207
	 * Booleen d'instanciation
207
	 * Booleen d'instanciation
208
	 */
208
	 */
209
	boolean estInstancie = false ;
209
	boolean estInstancie = false ;
210
 
210
 
211
	private Panel panneauIntermediaire;
211
	private Panel panneauIntermediaire;
212
 
212
 
213
	private Panel panneauPremierColonne;
213
	private Panel panneauPremierColonne;
214
 
214
 
215
	private Panel panneauSecondeColonne;
215
	private Panel panneauSecondeColonne;
216
 
216
 
217
	private boolean masseModification =false ;
217
	private boolean masseModification =false ;
218
 
218
 
219
	private TextField longitude;
219
	private TextField longitude;
220
 
220
 
221
	private TextField latitude;
221
	private TextField latitude;
222
	
222
	
223
	private MultiFieldPanel htmlCommunePanel = null;
223
	private MultiFieldPanel htmlCommunePanel = null;
224
 
224
 
225
	private MultiFieldPanel coordPanel;
225
	private MultiFieldPanel coordPanel;
226
 
226
 
227
	private TextField coordonnees;
227
	private TextField coordonnees;
228
	
228
	
229
	private Label lienSelectionCommune = null;
229
	private Label lienSelectionCommune = null;
230
 
230
 
231
	private HTML afficherFormulaireLatLon;
231
	private HTML afficherFormulaireLatLon;
232
 
232
 
233
	private HTML basculerverscarto;
233
	private HTML basculerverscarto;
234
	
234
	
235
	private boolean longlatAjoutee;
235
	private boolean longlatAjoutee;
236
 
236
 
237
	private boolean latModifiee;
237
	private boolean latModifiee;
238
 
238
 
239
	private boolean longModifiee;
239
	private boolean longModifiee;
240
 
240
 
241
	protected boolean rechercheCommuneEnCours = false;
241
	protected boolean rechercheCommuneEnCours = false;
242
 
242
 
243
	private Timer tCoord;
243
	private Timer tCoord;
244
	
244
	
245
	final String resultTplRefPerso = "<div class=\"search-item-commune\">{element_referentiel}</div>"; 
245
	final String resultTplRefPerso = "<div class=\"search-item-commune\">{element_referentiel}</div>"; 
246
	
246
	
247
	private ComboBox selecteurAbondance = null; 
247
	private ComboBox selecteurAbondance = null; 
248
	
248
	
249
	private ComboBox selecteurCertitude = null; 
249
	private ComboBox selecteurCertitude = null; 
250
	
250
	
251
	private ComboBox selecteurReferentielTaxo = null;
251
	private ComboBox selecteurReferentielTaxo = null;
252
	
252
	
253
	private ComboBox selecteurStadePheno = null;
253
	private ComboBox selecteurStadePheno = null;
254
	
254
	
255
	/**
255
	/**
256
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
256
	 * Constructeur sans argument (privé car ne doit pas être utilisé)
257
	 */
257
	 */
258
	@SuppressWarnings("unused")
258
	@SuppressWarnings("unused")
259
	private FormulaireSaisieObservationVue()
259
	private FormulaireSaisieObservationVue()
260
	{
260
	{
261
		super() ;
261
		super() ;
262
	}
262
	}
263
	
263
	
264
	/**
264
	/**
265
	 * Constructeur avec argument
265
	 * Constructeur avec argument
266
	 * @param im
266
	 * @param im
267
	 */
267
	 */
268
	public FormulaireSaisieObservationVue(ObservationMediateur obs)
268
	public FormulaireSaisieObservationVue(ObservationMediateur obs)
269
	{		
269
	{		
270
		super("Saisie");
270
		super("Saisie");
271
		// on associe le médiateur
271
		// on associe le médiateur
272
		observationMediateur = obs ;
272
		observationMediateur = obs ;
273
		
273
		
274
		referentielTaxo = obs.getRefTaxSelectionne().getCode();
274
		referentielTaxo = obs.getRefTaxSelectionne().getCode();
275
	     	
275
	     	
276
		panneauFormulaire = new FormPanel(Position.RIGHT);
276
		panneauFormulaire = new FormPanel(Position.RIGHT);
277
		panneauFormulaire.setBorder(false);
277
		panneauFormulaire.setBorder(false);
278
		
278
		
279
		// Panneau intermediaire qui contient deux colonnes de formulaire
279
		// Panneau intermediaire qui contient deux colonnes de formulaire
280
		panneauIntermediaire = new Panel();  
280
		panneauIntermediaire = new Panel();  
281
		
281
		
282
		if (Window.getClientWidth()> Window.getClientHeight()) {
282
		if (Window.getClientWidth()> Window.getClientHeight()) {
283
			panneauIntermediaire.setLayout(new ColumnLayout()); 
283
			panneauIntermediaire.setLayout(new ColumnLayout()); 
284
		}
284
		}
285
		else {
285
		else {
286
			panneauIntermediaire.setLayout(new RowLayout()); 
286
			panneauIntermediaire.setLayout(new RowLayout()); 
287
		}
287
		}
288
		
288
		
289
		panneauIntermediaire.setBorder(false);
289
		panneauIntermediaire.setBorder(false);
290
 
290
 
291
		//création du panneau formulaire de gauche auquels on ajoute les champs
291
		//création du panneau formulaire de gauche auquels on ajoute les champs
292
		panneauPremierColonne = new Panel();  
292
		panneauPremierColonne = new Panel();  
293
		panneauPremierColonne.setLayout(new FormLayout());  
293
		panneauPremierColonne.setLayout(new FormLayout());  
294
		panneauPremierColonne.setBorder(false);
294
		panneauPremierColonne.setBorder(false);
295
 
295
 
296
		//création du panneau formulaire de droite
296
		//création du panneau formulaire de droite
297
	    panneauSecondeColonne = new Panel();  
297
	    panneauSecondeColonne = new Panel();  
298
		panneauSecondeColonne.setLayout(new FormLayout());  
298
		panneauSecondeColonne.setLayout(new FormLayout());  
299
		panneauSecondeColonne.setBorder(false);
299
		panneauSecondeColonne.setBorder(false);
300
				
300
				
301
		this.setPaddings(5) ;
301
		this.setPaddings(5) ;
302
	
302
	
303
		// Accesskey pour debugging
303
		// Accesskey pour debugging
304
		commune=new ComboBox("Commune","commune\" accesskey=\"1");  
304
		commune=new ComboBox("Commune","commune\" accesskey=\"1");  
305
		
305
		
306
		final String resultTplCommune = "<div class=\"search-item-commune\">{commune}</div>";  
306
		final String resultTplCommune = "<div class=\"search-item-commune\">{commune}</div>";  
307
		commune.setTpl(resultTplCommune);
307
		commune.setTpl(resultTplCommune);
308
		commune.setMode(ComboBox.REMOTE);
308
		commune.setMode(ComboBox.REMOTE);
309
		commune.setItemSelector("div.search-item-commune");
309
		commune.setItemSelector("div.search-item-commune");
310
		commune.setTypeAhead(true);  
310
		commune.setTypeAhead(true);  
311
		commune.setLoadingText("Recherche...");  
311
		commune.setLoadingText("Recherche...");  
312
		commune.setHideTrigger(true);
312
		commune.setHideTrigger(true);
313
		
313
		
314
		  //création du lien "Accès carto" dans le formulaire	
314
		  //création du lien "Accès carto" dans le formulaire	
315
		basculerverscarto = new HTML(" <a id=\"lien_carto\" href=\"#\" tabindex=\"2\">Localiser la commune</a>");
315
		basculerverscarto = new HTML(" <a id=\"lien_carto\" href=\"#\" tabindex=\"2\">Localiser la commune</a>");
316
		basculerverscarto.addStyleName("lien_actif");
316
		basculerverscarto.addStyleName("lien_actif");
317
		
317
		
318
		//création info bulle sur le lien "accès carto"
318
		//création info bulle sur le lien "accès carto"
319
		ToolTip tip2 = new ToolTip();  
319
		ToolTip tip2 = new ToolTip();  
320
		tip2.setHtml("Via une carte, obtenez les coordonnées (latitude/longitude) de votre observation ");  
320
		tip2.setHtml("Via une carte, obtenez les coordonnées (latitude/longitude) de votre observation ");  
321
		tip2.applyTo(basculerverscarto.getElement());
321
		tip2.applyTo(basculerverscarto.getElement());
322
		
322
		
323
		//Sur une meme ligne, ajout de plusieurs champs
323
		//Sur une meme ligne, ajout de plusieurs champs
324
		htmlCommunePanel = new MultiFieldPanel(); 
324
		htmlCommunePanel = new MultiFieldPanel(); 
325
		
325
		
326
		int largeurCommune = Window.getClientWidth()/4;
326
		int largeurCommune = Window.getClientWidth()/4;
327
		htmlCommunePanel.addToRow(commune, largeurCommune);
327
		htmlCommunePanel.addToRow(commune, largeurCommune);
328
		htmlCommunePanel.addToRow(basculerverscarto, 160); 
328
		htmlCommunePanel.addToRow(basculerverscarto, 160); 
329
 
329
 
330
		htmlCommunePanel.setBorder(false);
330
		htmlCommunePanel.setBorder(false);
331
		htmlCommunePanel.setId("x-commune-panel"); 
331
		htmlCommunePanel.setId("x-commune-panel"); 
332
 
332
 
333
		panneauPremierColonne.add(htmlCommunePanel);
333
		panneauPremierColonne.add(htmlCommunePanel);
334
 
334
 
335
	    station = new AutoCompletionRefComboBox("Station", "station", observationMediateur, TypesReferentiels.REFERENTIEL_STATION) {
335
	    station = new AutoCompletionRefComboBox("Station", "station", observationMediateur, TypesReferentiels.REFERENTIEL_STATION) {
336
 
336
 
337
			@Override
337
			@Override
338
			public void onModificationValeur() {
338
			public void onModificationValeur() {
339
				stationModifiee = true;
339
				stationModifiee = true;
340
			}
340
			}
341
 
341
 
342
			@Override
342
			@Override
343
			public void onValidationSaisie() {
343
			public void onValidationSaisie() {
344
				validerSaisie(Champs.STATION);
344
				validerSaisie(Champs.STATION);
345
			}  	
345
			}  	
346
	    };
346
	    };
347
	    panneauPremierColonne.add(station, new AnchorLayoutData("95%"));  
347
	    panneauPremierColonne.add(station, new AnchorLayoutData("95%"));  
348
	    
348
	    
349
		latitude = new TextField("Lat", "lat");
349
		latitude = new TextField("Lat", "lat");
350
		latitude.setGrowMax(70);
350
		latitude.setGrowMax(70);
351
		latitude.setAllowBlank(true);
351
		latitude.setAllowBlank(true);
352
	    
352
	    
353
	    longitude = new TextField("Lon", "lon");
353
	    longitude = new TextField("Lon", "lon");
354
	    longitude.setGrowMax(70);
354
	    longitude.setGrowMax(70);
355
		longitude.setAllowBlank(true);
355
		longitude.setAllowBlank(true);
356
				
356
				
357
		lienSelectionCommune = new Label("");
357
		lienSelectionCommune = new Label("");
358
		
358
		
359
		
359
		
360
		lienSelectionCommune.setId("conteneur_selection_commune");
360
		lienSelectionCommune.setId("conteneur_selection_commune");
361
		lienSelectionCommune.setStyleName("conteneur_selection_commune");
361
		lienSelectionCommune.setStyleName("conteneur_selection_commune");
362
		lienSelectionCommune.addStyleName("lien_actif");
362
		lienSelectionCommune.addStyleName("lien_actif");
363
			
363
			
364
		// Panneau de type plusieurs champs de formulaire sur une meme ligne, où seront renseignés Lat/Lon
364
		// Panneau de type plusieurs champs de formulaire sur une meme ligne, où seront renseignés Lat/Lon
365
		coordPanel = new MultiFieldPanel(); 
365
		coordPanel = new MultiFieldPanel(); 
366
		coordPanel.setPaddings(0, 0, 0, 10);
366
		coordPanel.setPaddings(0, 0, 0, 10);
367
		coordPanel.setVisible(false);
367
		coordPanel.setVisible(false);
368
		
368
		
369
		final double largeur ;
369
		final double largeur ;
370
		largeur = 120;
370
		largeur = 120;
371
				
371
				
372
		coordPanel.addToRow(latitude, new ColumnLayoutData(largeur)); 
372
		coordPanel.addToRow(latitude, new ColumnLayoutData(largeur)); 
373
		coordPanel.addToRow(longitude, new ColumnLayoutData(largeur));  
373
		coordPanel.addToRow(longitude, new ColumnLayoutData(largeur));  
374
		coordPanel.addToRow(lienSelectionCommune, new ColumnLayoutData(largeur)); 
374
		coordPanel.addToRow(lienSelectionCommune, new ColumnLayoutData(largeur)); 
375
		lienSelectionCommune.addClass("lien_decale");
375
		lienSelectionCommune.addClass("lien_decale");
376
		coordPanel.setBorder(false);
376
		coordPanel.setBorder(false);
377
		
377
		
378
		  //création du champs coordonnées	
378
		  //création du champs coordonnées	
379
		referentielGeo = Configuration.getReferentielGeo();
379
		referentielGeo = Configuration.getReferentielGeo();
380
		
380
		
381
		coordonnees = new TextField("Coordonnées", "", 0);
381
		coordonnees = new TextField("Coordonnées", "", 0);
382
		coordonnees.setMaxLength(0);
382
		coordonnees.setMaxLength(0);
383
		coordonnees.setReadOnly(true);
383
		coordonnees.setReadOnly(true);
384
		coordonnees.setCls("fieldname");
384
		coordonnees.setCls("fieldname");
385
		
385
		
386
		//création du lien "saisie X/Y" dans le formulaire
386
		//création du lien "saisie X/Y" dans le formulaire
387
		afficherFormulaireLatLon = new HTML("<span style=\"padding-left:30px;\" class=\"conteneur_lien_afficher_lat_lon\">" +
387
		afficherFormulaireLatLon = new HTML("<span style=\"padding-left:30px;\" class=\"conteneur_lien_afficher_lat_lon\">" +
388
				"<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>" +
388
				"<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>" +
389
				"<span><span style=\"padding-left:20px\" class=\"conteneur_lien_localiser_lat_lon\">"+
389
				"<span><span style=\"padding-left:20px\" class=\"conteneur_lien_localiser_lat_lon\">"+
390
				"<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>"+
390
				"<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>"+
391
				"</span>");
391
				"</span>");
392
						
392
						
393
			//ajout d'un listener sur le lien "saisie X/Y"	
393
			//ajout d'un listener sur le lien "saisie X/Y"	
394
			coordPanel.addListener(new PanelListenerAdapter() {
394
			coordPanel.addListener(new PanelListenerAdapter() {
395
				
395
				
396
				@Override
396
				@Override
397
				public void onAfterLayout(Container c) {
397
				public void onAfterLayout(Container c) {
398
					surPremierAffichageCoordPanel(largeur);
398
					surPremierAffichageCoordPanel(largeur);
399
				}
399
				}
400
			});
400
			});
401
						
401
						
402
		//Sur une meme ligne, ajout de plusieurs champs
402
		//Sur une meme ligne, ajout de plusieurs champs
403
		final MultiFieldPanel htmlPanel = new MultiFieldPanel();  
403
		final MultiFieldPanel htmlPanel = new MultiFieldPanel();  
404
		
404
		
405
		htmlPanel.addToRow(coordonnees, 100); 
405
		htmlPanel.addToRow(coordonnees, 100); 
406
		htmlPanel.addToRow(afficherFormulaireLatLon, new ColumnLayoutData(0.9)); 
406
		htmlPanel.addToRow(afficherFormulaireLatLon, new ColumnLayoutData(0.9)); 
407
		htmlPanel.setBorder(false);
407
		htmlPanel.setBorder(false);
408
		htmlPanel.setId("x-coord-panel");
408
		htmlPanel.setId("x-coord-panel");
409
			
409
			
410
		panneauPremierColonne.add(htmlPanel);
410
		panneauPremierColonne.add(htmlPanel);
411
		panneauPremierColonne.add(coordPanel);
411
		panneauPremierColonne.add(coordPanel);
412
	    
412
	    
413
	    date = new DateField("Date", "date", 200);  
413
	    date = new DateField("Date", "date", 200);  
414
	    date.setAllowBlank(true);
414
	    date.setAllowBlank(true);
415
	    formatDate = "d/m/Y";
415
	    formatDate = "d/m/Y";
416
	    date.setFormat(formatDate) ;
416
	    date.setFormat(formatDate) ;
417
	    date.setTitle("Date de l'observation au format jj/mm/aaaa");
417
	    date.setTitle("Date de l'observation au format jj/mm/aaaa");
418
	    //date.setTabIndex(5);
418
	    //date.setTabIndex(5);
419
	    panneauPremierColonne.add(date, new AnchorLayoutData("55%"));  
419
	    panneauPremierColonne.add(date, new AnchorLayoutData("55%"));  
420
	    
420
	    
421
	    
421
	    
422
	    final String champsListeTpl = "<div class=\"x-combo-list-item search-item-tpl\" title=\"{label}\">{label}</div>"; 
422
	    final String champsListeTpl = "<div class=\"x-combo-list-item search-item-tpl\" title=\"{label}\">{label}</div>"; 
423
 	
423
 	
424
	    // Selection d'un référentiel par défaut (le premier spécifié dans la config)
424
	    // Selection d'un référentiel par défaut (le premier spécifié dans la config)
425
	    referentielTaxo = Configuration.getReferentielsDispos().get(0).getCode();
425
	    referentielTaxo = Configuration.getReferentielsDispos().get(0).getCode();
426
	    selecteurReferentielTaxo = new ComboBox();
426
	    selecteurReferentielTaxo = new ComboBox();
427
	    selecteurReferentielTaxo.setCls("champ-separation");
427
	    selecteurReferentielTaxo.setCls("champ-separation");
428
	    selecteurReferentielTaxo.setLabel("Référentiel");
428
	    selecteurReferentielTaxo.setLabel("Référentiel");
429
	    selecteurReferentielTaxo.setStore(Ontologies.getValeursReferentiel());
429
	    selecteurReferentielTaxo.setStore(Ontologies.getValeursReferentiel());
430
	    selecteurReferentielTaxo.setValue(referentielTaxo);
430
	    selecteurReferentielTaxo.setValue(referentielTaxo);
431
	    selecteurReferentielTaxo.setDisplayField("label") ;
431
	    selecteurReferentielTaxo.setDisplayField("label") ;
432
	    selecteurReferentielTaxo.setValueField("valeur");
432
	    selecteurReferentielTaxo.setValueField("valeur");
433
	    selecteurReferentielTaxo.setEditable(false);
433
	    selecteurReferentielTaxo.setEditable(false);
434
	    selecteurReferentielTaxo.setHideTrigger(false);
434
	    selecteurReferentielTaxo.setHideTrigger(false);
435
	    selecteurReferentielTaxo.setForceSelection(true);
435
	    selecteurReferentielTaxo.setForceSelection(true);
436
	    selecteurReferentielTaxo.setTpl(champsListeTpl);
436
	    selecteurReferentielTaxo.setTpl(champsListeTpl);
437
	    	    
437
	    	    
438
		espece=new ComboBox("Espèce","nom");  
438
		espece=new ComboBox("Espèce","nom");  
439
		final String resultTplEspece = "<div class=\"search-item-espece {indicateurNomRetenu}\">{nom}</div>";  
439
		final String resultTplEspece = "<div class=\"search-item-espece {indicateurNomRetenu}\">{nom}</div>";  
440
		
440
		
441
		espece.setTpl(resultTplEspece);
441
		espece.setTpl(resultTplEspece);
442
		espece.setMode(ComboBox.REMOTE);
442
		espece.setMode(ComboBox.REMOTE);
443
		espece.setItemSelector("div.search-item-espece");
443
		espece.setItemSelector("div.search-item-espece");
444
		espece.setTypeAhead(true);  
444
		espece.setTypeAhead(true);  
445
		espece.setLoadingText("Recherche...");  
445
		espece.setLoadingText("Recherche...");  
446
		  
446
		  
447
		espece.setHideTrigger(true);
447
		espece.setHideTrigger(true);
448
 
448
 
449
	    Panel panelSeparationPp = new Panel();
449
	    Panel panelSeparationPp = new Panel();
450
	    panelSeparationPp.setHeight(15);
450
	    panelSeparationPp.setHeight(15);
451
	    panelSeparationPp.setBorder(false);
451
	    panelSeparationPp.setBorder(false);
452
	    
452
	    
453
	    panneauPremierColonne.add(panelSeparationPp);
453
	    panneauPremierColonne.add(panelSeparationPp);
454
	    panneauPremierColonne.add(selecteurReferentielTaxo, new AnchorLayoutData("50%")); 
454
	    panneauPremierColonne.add(selecteurReferentielTaxo, new AnchorLayoutData("85%")); 
455
	    panneauPremierColonne.add(espece, new AnchorLayoutData("95%"));    
455
	    panneauPremierColonne.add(espece, new AnchorLayoutData("95%"));    
456
	    
456
	    
457
	    selecteurAbondance = new ComboBox();
457
	    selecteurAbondance = new ComboBox();
458
	    selecteurAbondance.setCls("champ-separation");
458
	    selecteurAbondance.setCls("champ-separation");
459
	    selecteurAbondance.setLabel("Abondance");
459
	    selecteurAbondance.setLabel("Abondance");
460
	    selecteurAbondance.setStore(Ontologies.getValeursAbondance());
460
	    selecteurAbondance.setStore(Ontologies.getValeursAbondance());
461
	    selecteurAbondance.setDisplayField("label") ;
461
	    selecteurAbondance.setDisplayField("label") ;
462
	    selecteurAbondance.setValueField("valeur");
462
	    selecteurAbondance.setValueField("valeur");
463
	    selecteurAbondance.setEditable(true);
463
	    selecteurAbondance.setEditable(true);
464
	    selecteurAbondance.setHideTrigger(false);
464
	    selecteurAbondance.setHideTrigger(false);
465
	    selecteurAbondance.setForceSelection(false);
465
	    selecteurAbondance.setForceSelection(false);
466
	    selecteurAbondance.setTpl(champsListeTpl);
466
	    selecteurAbondance.setTpl(champsListeTpl);
467
	    panneauPremierColonne.add(selecteurAbondance,  new AnchorLayoutData("65%"));   
467
	    panneauPremierColonne.add(selecteurAbondance,  new AnchorLayoutData("95%"));   
468
	    	    
468
	    	    
469
	    lieudit = new AutoCompletionRefComboBox("Lieu-dit", "lieudit",observationMediateur,TypesReferentiels.REFERENTIEL_LIEU_DIT) {
469
	    lieudit = new AutoCompletionRefComboBox("Lieu-dit", "lieudit",observationMediateur,TypesReferentiels.REFERENTIEL_LIEU_DIT) {
470
 
470
 
471
			@Override
471
			@Override
472
			public void onModificationValeur() {
472
			public void onModificationValeur() {
473
				lieuDitModifie = true;			
473
				lieuDitModifie = true;			
474
			}
474
			}
475
 
475
 
476
			@Override
476
			@Override
477
			public void onValidationSaisie() {
477
			public void onValidationSaisie() {
478
				validerSaisie(Champs.LIEUDIT);
478
				validerSaisie(Champs.LIEUDIT);
479
			}
479
			}
480
	    };
480
	    };
481
	    panneauSecondeColonne.add(lieudit,  new AnchorLayoutData("95%"));  
481
	    panneauSecondeColonne.add(lieudit,  new AnchorLayoutData("95%"));  
482
	       	    
482
	       	    
483
	    milieu = new AutoCompletionRefComboBox("Milieu","milieu",observationMediateur,TypesReferentiels.REFERENTIEL_MILIEU) {
483
	    milieu = new AutoCompletionRefComboBox("Milieu","milieu",observationMediateur,TypesReferentiels.REFERENTIEL_MILIEU) {
484
 
484
 
485
			@Override
485
			@Override
486
			public void onModificationValeur() {
486
			public void onModificationValeur() {
487
				milieuModifie = true;
487
				milieuModifie = true;
488
			}
488
			}
489
 
489
 
490
			@Override
490
			@Override
491
			public void onValidationSaisie() {
491
			public void onValidationSaisie() {
492
				validerSaisie(Champs.MILIEU);
492
				validerSaisie(Champs.MILIEU);
493
			}
493
			}
494
	    	
494
	    	
495
	    };
495
	    };
496
	    panneauSecondeColonne.add(milieu,  new AnchorLayoutData("95%"));
496
	    panneauSecondeColonne.add(milieu,  new AnchorLayoutData("95%"));
497
	    
497
	    
498
	    comment = new TextArea("Notes", "comment");  
498
	    comment = new TextArea("Notes", "comment");  
499
	    comment.setAllowBlank(true);
499
	    comment.setAllowBlank(true);
500
	    comment.setHeight(50);
500
	    comment.setHeight(50);
501
	    
501
	    
502
	    panneauSecondeColonne.add(comment, new AnchorLayoutData("95%") );
502
	    panneauSecondeColonne.add(comment, new AnchorLayoutData("95%") );
503
	    
503
	    
504
	    Panel panelSeparationPs = new Panel();
504
	    Panel panelSeparationPs = new Panel();
505
	    panelSeparationPs.setHeight(39);
505
	    panelSeparationPs.setHeight(39);
506
	    panelSeparationPs.setBorder(false);
506
	    panelSeparationPs.setBorder(false);
507
	    
507
	    
508
	    panneauSecondeColonne.add(panelSeparationPs);
508
	    panneauSecondeColonne.add(panelSeparationPs);
509
	    
509
	    
510
	    selecteurCertitude = new ComboBox();
510
	    selecteurCertitude = new ComboBox();
511
	    selecteurCertitude.setLabel("Identification");
511
	    selecteurCertitude.setLabel("Identification");
512
	    selecteurCertitude.setStore(Ontologies.getValeursCertitude());
512
	    selecteurCertitude.setStore(Ontologies.getValeursCertitude());
513
	    selecteurCertitude.setDisplayField("label") ;
513
	    selecteurCertitude.setDisplayField("label") ;
514
	    selecteurCertitude.setValueField("valeur");
514
	    selecteurCertitude.setValueField("valeur");
515
	    selecteurCertitude.setEditable(true);
515
	    selecteurCertitude.setEditable(true);
516
	    selecteurCertitude.setHideTrigger(false);
516
	    selecteurCertitude.setHideTrigger(false);
517
	    selecteurCertitude.setForceSelection(false);
517
	    selecteurCertitude.setForceSelection(false);
518
	    selecteurCertitude.setTpl(champsListeTpl);
518
	    selecteurCertitude.setTpl(champsListeTpl);
519
	    panneauSecondeColonne.add(selecteurCertitude, new AnchorLayoutData("55%"));   
519
	    panneauSecondeColonne.add(selecteurCertitude, new AnchorLayoutData("95%"));   
520
	    
520
	    
521
	    selecteurStadePheno = new ComboBox();
521
	    selecteurStadePheno = new ComboBox();
522
	    selecteurStadePheno.setLabel("Phénologie");
522
	    selecteurStadePheno.setLabel("Phénologie");
523
	    selecteurStadePheno.setStore(Ontologies.getValeursPhenologie());
523
	    selecteurStadePheno.setStore(Ontologies.getValeursPhenologie());
524
	    selecteurStadePheno.setDisplayField("label") ;
524
	    selecteurStadePheno.setDisplayField("label") ;
525
	    selecteurStadePheno.setValueField("valeur");
525
	    selecteurStadePheno.setValueField("valeur");
526
	    selecteurStadePheno.setEditable(true);
526
	    selecteurStadePheno.setEditable(true);
527
	    selecteurStadePheno.setHideTrigger(false);
527
	    selecteurStadePheno.setHideTrigger(false);
528
	    selecteurStadePheno.setForceSelection(false);
528
	    selecteurStadePheno.setForceSelection(false);
529
	    selecteurStadePheno.setTpl(champsListeTpl);
529
	    selecteurStadePheno.setTpl(champsListeTpl);
530
	    panneauSecondeColonne.add(selecteurStadePheno, new AnchorLayoutData("95%"));   
530
	    panneauSecondeColonne.add(selecteurStadePheno, new AnchorLayoutData("95%"));   
531
	    
531
	    
532
	    if (Window.getClientWidth() > Window.getClientHeight() || Window.getClientWidth() < 800) {
532
	    if (Window.getClientWidth() > Window.getClientHeight() || Window.getClientWidth() < 800) {
533
			panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
533
			panneauIntermediaire.add(panneauPremierColonne, new ColumnLayoutData(.5));
534
			panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
534
			panneauIntermediaire.add(panneauSecondeColonne, new ColumnLayoutData(.5));
535
	    }
535
	    }
536
	    else {
536
	    else {
537
			panneauIntermediaire.add(panneauPremierColonne);
537
			panneauIntermediaire.add(panneauPremierColonne);
538
			panneauIntermediaire.add(panneauSecondeColonne);   	
538
			panneauIntermediaire.add(panneauSecondeColonne);   	
539
	    }
539
	    }
540
			
540
			
541
		panneauFormulaire.add(panneauIntermediaire);
541
		panneauFormulaire.add(panneauIntermediaire);
542
		
542
		
543
		Object[][] mode = {{"création",false} , {"modification", true} };
543
		Object[][] mode = {{"création",false} , {"modification", true} };
544
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
544
		storeMode = new SimpleStore(new String[] { "nom_mode", "mode" },
545
				mode);
545
				mode);
546
		storeMode.load();
546
		storeMode.load();
547
		selecteurMode.setStore(storeMode);
547
		selecteurMode.setStore(storeMode);
548
		selecteurMode.setDisplayField("nom_mode") ;
548
		selecteurMode.setDisplayField("nom_mode") ;
549
		selecteurMode.setLabel("mode ") ;
549
		selecteurMode.setLabel("mode ") ;
550
		selecteurMode.setForceSelection(true) ;
550
		selecteurMode.setForceSelection(true) ;
551
		selecteurMode.setValue("création") ;
551
		selecteurMode.setValue("création") ;
552
		selecteurMode.setEditable(false) ;
552
		selecteurMode.setEditable(false) ;
553
		selecteurMode.setCls("x-selec-crea") ;
553
		selecteurMode.setCls("x-selec-crea") ;
554
		
554
		
555
		bt = new Toolbar() ;
555
		bt = new Toolbar() ;
556
		bt.addSpacer() ;
556
		bt.addSpacer() ;
557
		bt.addText("Mode de saisie ") ;
557
		bt.addText("Mode de saisie ") ;
558
		bt.addField(selecteurMode) ;
558
		bt.addField(selecteurMode) ;
559
			
559
			
560
		if (Ext.isIE()) {
560
		if (Ext.isIE()) {
561
			panneauPremierColonne.setButtonAlign(Position.RIGHT);
561
			panneauPremierColonne.setButtonAlign(Position.RIGHT);
562
			panneauPremierColonne.addButton(boutonOK);
562
			panneauPremierColonne.addButton(boutonOK);
563
			panneauSecondeColonne.setButtonAlign(Position.LEFT);
563
			panneauSecondeColonne.setButtonAlign(Position.LEFT);
564
			panneauPremierColonne.addButton(boutonAnnuler);
564
			panneauPremierColonne.addButton(boutonAnnuler);
565
		}
565
		}
566
		else {	
566
		else {	
567
			panneauFormulaire.addButton(boutonOK);
567
			panneauFormulaire.addButton(boutonOK);
568
			panneauFormulaire.addButton(boutonAnnuler);		
568
			panneauFormulaire.addButton(boutonAnnuler);		
569
		}
569
		}
570
			
570
			
571
		selecteurMode.addListener(new ComboBoxListenerAdapter() {
571
		selecteurMode.addListener(new ComboBoxListenerAdapter() {
572
			@Override
572
			@Override
573
			public void onSelect(ComboBox comboBox, Record record, int index) {
573
			public void onSelect(ComboBox comboBox, Record record, int index) {
574
				
574
				
575
				// et on met la valeur à jour dans la combobox
575
				// et on met la valeur à jour dans la combobox
576
				comboBox.setValue(record.getAsString("nom_mode"));
576
				comboBox.setValue(record.getAsString("nom_mode"));
577
				setModification(record.getAsString("mode")) ;
577
				setModification(record.getAsString("mode")) ;
578
			}
578
			}
579
		});
579
		});
580
	
580
	
581
		this.add(panneauFormulaire) ;
581
		this.add(panneauFormulaire) ;
582
		this.setTopToolbar(bt) ;
582
		this.setTopToolbar(bt) ;
583
		
583
		
584
		this.setAutoScroll(true);
584
		this.setAutoScroll(true);
585
	
585
	
586
		
586
		
587
		panneauFormulaire.addListener(new PanelListenerAdapter() {
587
		panneauFormulaire.addListener(new PanelListenerAdapter() {
588
	        @Override
588
	        @Override
589
			public void onResize(BoxComponent component, int adjWidth, int adjHeight, int rawWidth, int rawHeight) {
589
			public void onResize(BoxComponent component, int adjWidth, int adjHeight, int rawWidth, int rawHeight) {
590
	        	panneauIntermediaire.setWidth(rawWidth);
590
	        	panneauIntermediaire.setWidth(rawWidth);
591
	        	panneauIntermediaire.setHeight(rawHeight);
591
	        	panneauIntermediaire.setHeight(rawHeight);
592
	        	
592
	        	
593
	        	panneauPremierColonne.doLayout();
593
	        	panneauPremierColonne.doLayout();
594
	        	panneauSecondeColonne.doLayout();
594
	        	panneauSecondeColonne.doLayout();
595
	        		        	
595
	        		        	
596
	        	htmlCommunePanel.doLayout();
596
	        	htmlCommunePanel.doLayout();
597
	        	htmlPanel.doLayout();
597
	        	htmlPanel.doLayout();
598
	        	
598
	        	
599
	        	doLayout();
599
	        	doLayout();
600
	        }
600
	        }
601
	    });
601
	    });
602
		
602
		
603
		// on ajoute les listeners
603
		// on ajoute les listeners
604
		ajouterListeners() ;
604
		ajouterListeners() ;
605
		saisieTabindex();
605
		saisieTabindex();
606
	}
606
	}
607
	
607
	
608
	private void surPremierAffichageCoordPanel(final double largeur) {
608
	private void surPremierAffichageCoordPanel(final double largeur) {
609
		ExtElement lienCoord = Ext.get("lien_coord");
609
		ExtElement lienCoord = Ext.get("lien_coord");
610
		lienCoord.removeAllListeners();
610
		lienCoord.removeAllListeners();
611
		lienCoord.addListener("click", new EventCallback() {
611
		lienCoord.addListener("click", new EventCallback() {
612
			@Override
612
			@Override
613
			public void execute(EventObject e) {
613
			public void execute(EventObject e) {
614
				
614
				
615
				coordPanel.setVisible(!coordPanel.isVisible());
615
				coordPanel.setVisible(!coordPanel.isVisible());
616
				
616
				
617
				if(Ext.isIE()) {
617
				if(Ext.isIE()) {
618
					latitude.focus();
618
					latitude.focus();
619
				}
619
				}
620
				
620
				
621
				CarnetEnLigneMediateur.fireResize();
621
				CarnetEnLigneMediateur.fireResize();
622
			}
622
			}
623
		}) ;
623
		}) ;
624
		
624
		
625
		ExtElement lienCartoCoord = Ext.get("lien_carto_coord");
625
		ExtElement lienCartoCoord = Ext.get("lien_carto_coord");
626
		lienCartoCoord.removeAllListeners();
626
		lienCartoCoord.removeAllListeners();
627
		lienCartoCoord.addListener("click", new EventCallback() {
627
		lienCartoCoord.addListener("click", new EventCallback() {
628
			@Override
628
			@Override
629
			public void execute(EventObject e) {
629
			public void execute(EventObject e) {
630
				obtenirInformationCoord();
630
				obtenirInformationCoord();
631
			}
631
			}
632
		}) ;
632
		}) ;
633
	
633
	
634
		ExtElement lienCarto = Ext.get("lien_carto");
634
		ExtElement lienCarto = Ext.get("lien_carto");
635
		lienCarto.removeAllListeners();
635
		lienCarto.removeAllListeners();
636
		lienCarto.addListener("click", new EventCallback() {
636
		lienCarto.addListener("click", new EventCallback() {
637
 
637
 
638
			@Override
638
			@Override
639
			public void execute(EventObject e) {
639
			public void execute(EventObject e) {
640
				
640
				
641
				if(commune.getValue() != null && !commune.getValue().equals("") && !getDepartement().equals("")) {
641
				if(commune.getValue() != null && !commune.getValue().equals("") && !getDepartement().equals("")) {
642
					obtenirInformationCommune();
642
					obtenirInformationCommune();
643
					longlatAjoutee = true;
643
					longlatAjoutee = true;
644
		
644
		
645
				} else {
645
				} else {
646
					Window.alert("Veuillez renseigner une commune et un numéro de département sous la forme : Commune (departement)");
646
					Window.alert("Veuillez renseigner une commune et un numéro de département sous la forme : Commune (departement)");
647
				}
647
				}
648
			}
648
			}
649
		});
649
		});
650
		
650
		
651
		if(!Ext.isIE() && Window.getClientWidth() < 1200) {
651
		if(!Ext.isIE() && Window.getClientWidth() < 1200) {
652
			
652
			
653
			int largeurN = (int)largeur;
653
			int largeurN = (int)largeur;
654
			
654
			
655
			latitude.setWidth(largeurN+"px");
655
			latitude.setWidth(largeurN+"px");
656
			longitude.setWidth(largeurN+"px");
656
			longitude.setWidth(largeurN+"px");
657
			lienSelectionCommune.setWidth(largeurN+"px");						
657
			lienSelectionCommune.setWidth(largeurN+"px");						
658
		}
658
		}
659
	}
659
	}
660
			
660
			
661
	private void ajouterListeners()
661
	private void ajouterListeners()
662
	{	
662
	{	
663
		// Listener completion communne 
663
		// Listener completion communne 
664
		final Rafraichissable r = this;
664
		final Rafraichissable r = this;
665
		  	        
665
		  	        
666
		ListenerConfig listenerConfigCommune=new ListenerConfig();
666
		ListenerConfig listenerConfigCommune=new ListenerConfig();
667
		listenerConfigCommune.setDelay(200);
667
		listenerConfigCommune.setDelay(200);
668
		listenerConfigCommune.setStopPropagation(false);
668
		listenerConfigCommune.setStopPropagation(false);
669
		listenerConfigCommune.setStopEvent(false);
669
		listenerConfigCommune.setStopEvent(false);
670
 
670
 
671
	    date.addListener(new DatePickerListenerAdapter() {
671
	    date.addListener(new DatePickerListenerAdapter() {
672
 
672
 
673
			@Override
673
			@Override
674
			public void onSelect(DatePicker dataPicker, Date date) {
674
			public void onSelect(DatePicker dataPicker, Date date) {
675
				dateModifiee = true;
675
				dateModifiee = true;
676
			}
676
			}
677
	    });
677
	    });
678
	    
678
	    
679
	    ListenerConfig listenerConfigAutocompletion=new ListenerConfig();
679
	    ListenerConfig listenerConfigAutocompletion=new ListenerConfig();
680
	    listenerConfigAutocompletion.setDelay(200);
680
	    listenerConfigAutocompletion.setDelay(200);
681
	    listenerConfigAutocompletion.setStopPropagation(false);
681
	    listenerConfigAutocompletion.setStopPropagation(false);
682
	    listenerConfigAutocompletion.setStopEvent(false);
682
	    listenerConfigAutocompletion.setStopEvent(false);
683
	    
683
	    
684
		ListenerConfig listenerConfigEspece=new ListenerConfig();
684
		ListenerConfig listenerConfigEspece=new ListenerConfig();
685
		listenerConfigEspece.setDelay(10);
685
		listenerConfigEspece.setDelay(10);
686
		listenerConfigEspece.setStopPropagation(false);
686
		listenerConfigEspece.setStopPropagation(false);
687
		listenerConfigEspece.setStopEvent(false);
687
		listenerConfigEspece.setStopEvent(false);
688
			
688
			
689
		tCoord = new Timer() {
689
		tCoord = new Timer() {
690
 
690
 
691
			@Override
691
			@Override
692
			public void run() {
692
			public void run() {
693
	        	double[] coord = coordonneesValides();
693
	        	double[] coord = coordonneesValides();
694
	        	if(!rechercheCommuneEnCours && coord != null && (longModifiee || latModifiee)) {
694
	        	if(!rechercheCommuneEnCours && coord != null && (longModifiee || latModifiee)) {
695
	        		rechercheCommuneEnCours = true;
695
	        		rechercheCommuneEnCours = true;
696
	        		Ext.get(lienSelectionCommune.getElement()).mask("recherche");
696
	        		Ext.get(lienSelectionCommune.getElement()).mask("recherche");
697
	        		observationMediateur.obtenirInformationCoord(r,LatLng.newInstance(coord[0], coord[1]));
697
	        		observationMediateur.obtenirInformationCoord(r,LatLng.newInstance(coord[0], coord[1]));
698
	        	}
698
	        	}
699
			}
699
			}
700
			
700
			
701
		};
701
		};
702
		
702
		
703
		ajouterListenerChampEvenementsClavier(commune, listenerConfigCommune);
703
		ajouterListenerChampEvenementsClavier(commune, listenerConfigCommune);
704
	    ajouterListenerChampEvenementsClavier(date);
704
	    ajouterListenerChampEvenementsClavier(date);
705
		ajouterListenerChampEvenementsClavier(selecteurReferentielTaxo);
705
		ajouterListenerChampEvenementsClavier(selecteurReferentielTaxo);
706
		ajouterListenerChampEvenementsClavier(espece, listenerConfigEspece);
706
		ajouterListenerChampEvenementsClavier(espece, listenerConfigEspece);
707
		ajouterListenerChampEvenementsClavier(comment);
707
		ajouterListenerChampEvenementsClavier(comment);
708
		ajouterListenerChampEvenementsClavier(latitude);
708
		ajouterListenerChampEvenementsClavier(latitude);
709
		ajouterListenerChampEvenementsClavier(longitude);
709
		ajouterListenerChampEvenementsClavier(longitude);
710
		ajouterListenerChampEvenementsClavier(selecteurAbondance);			
710
		ajouterListenerChampEvenementsClavier(selecteurAbondance);			
711
		ajouterListenerChampEvenementsClavier(selecteurCertitude);			
711
		ajouterListenerChampEvenementsClavier(selecteurCertitude);			
712
		ajouterListenerChampEvenementsClavier(selecteurStadePheno);
712
		ajouterListenerChampEvenementsClavier(selecteurStadePheno);
713
		ajouterListenerChampsCombobox();
713
		ajouterListenerChampsCombobox();
714
		
714
		
715
		boutonOK.addListener(new ButtonListenerAdapter() {
715
		boutonOK.addListener(new ButtonListenerAdapter() {
716
			@Override
716
			@Override
717
			public void onClick(Button button, EventObject e) {	
717
			public void onClick(Button button, EventObject e) {	
718
				if(modification) {
718
				if(modification) {
719
					if(masseModification) {
719
					if(masseModification) {
720
							modifierObservationEnMasse(null);
720
							modifierObservationEnMasse(null);
721
					} else {
721
					} else {
722
						modifierObservation() ;
722
						modifierObservation() ;
723
					}
723
					}
724
				}
724
				}
725
				else {
725
				else {
726
					ajouterObservation();
726
					ajouterObservation();
727
				}
727
				}
728
			}			
728
			}			
729
		});
729
		});
730
	
730
	
731
		boutonAnnuler.addListener(new ButtonListenerAdapter() {	
731
		boutonAnnuler.addListener(new ButtonListenerAdapter() {	
732
			@Override
732
			@Override
733
			public void onClick(Button button, EventObject e) {			
733
			public void onClick(Button button, EventObject e) {			
734
				if(modification)
734
				if(modification)
735
				{
735
				{
736
					supprimerObservation() ;
736
					supprimerObservation() ;
737
				}
737
				}
738
				else
738
				else
739
				{
739
				{
740
					raz();
740
					raz();
741
				}
741
				}
742
			}	
742
			}	
743
		});
743
		});
744
	
744
	
745
		this.addListener(new ContainerListenerAdapter() {
745
		this.addListener(new ContainerListenerAdapter() {
746
			@Override
746
			@Override
747
			public void onAfterLayout(Container self) {
747
			public void onAfterLayout(Container self) {
748
				commune.focus();
748
				commune.focus();
749
			}
749
			}
750
		});		
750
		});		
751
	}
751
	}
752
	
752
	
753
	private void ajouterListenerChampsCombobox() {
753
	private void ajouterListenerChampsCombobox() {
754
		commune.addListener(new ComboBoxListenerAdapter() {  
754
		commune.addListener(new ComboBoxListenerAdapter() {  
755
            @Override
755
            @Override
756
			public void onSelect(ComboBox comboBox, Record record, int index) {  
756
			public void onSelect(ComboBox comboBox, Record record, int index) {  
757
                commune.setValue(record.getAsString("commune"));
757
                commune.setValue(record.getAsString("commune"));
758
                departement=record.getAsString("departement");
758
                departement=record.getAsString("departement");
759
                codeInseeCommune=record.getAsString("codeInsee");
759
                codeInseeCommune=record.getAsString("codeInsee");
760
                selectionCommune=true;
760
                selectionCommune=true;
761
                commune.collapse();
761
                commune.collapse();
762
            }  
762
            }  
763
            
763
            
764
            @Override
764
            @Override
765
			public void onExpand(ComboBox comboBox) {
765
			public void onExpand(ComboBox comboBox) {
766
           	 comboBox.focus();
766
           	 comboBox.focus();
767
            }
767
            }
768
        }); 
768
        }); 
769
		 
769
		 
770
		selecteurReferentielTaxo.addListener(new ComboBoxListenerAdapter() {  
770
		selecteurReferentielTaxo.addListener(new ComboBoxListenerAdapter() {  
771
             @Override
771
             @Override
772
			public void onSelect(ComboBox comboBox, Record record, int index) {  
772
			public void onSelect(ComboBox comboBox, Record record, int index) {  
773
            	 referentielTaxo = record.getAsString("valeur");
773
            	 referentielTaxo = record.getAsString("valeur");
774
                 observationMediateur.setRefTaxSelectionne(index);
774
                 observationMediateur.setRefTaxSelectionne(index);
775
                 referentielTaxoModifie = true;
775
                 referentielTaxoModifie = true;
776
             }  
776
             }  
777
         });  
777
         });  
778
		
778
		
779
		espece.addListener(new ComboBoxListenerAdapter() {  
779
		espece.addListener(new ComboBoxListenerAdapter() {  
780
             @Override
780
             @Override
781
			public void onSelect(ComboBox comboBox, Record record, int index) {  
781
			public void onSelect(ComboBox comboBox, Record record, int index) {  
782
            	 espece.setValue(record.getAsString("nom"));
782
            	 espece.setValue(record.getAsString("nom"));
783
            	 numeroNom=record.getAsString("numeroNom");
783
            	 numeroNom=record.getAsString("numeroNom");
784
                 selectionEspece=true;
784
                 selectionEspece=true;
785
                 observationMediateur.obtenirImageInformationExternes(referentielTaxo, numeroNom);
785
                 observationMediateur.obtenirImageInformationExternes(referentielTaxo, numeroNom);
786
             }  
786
             }  
787
         });  
787
         });  
788
		
788
		
789
		selecteurAbondance.addListener(new ComboBoxListenerAdapter() {  
789
		selecteurAbondance.addListener(new ComboBoxListenerAdapter() {  
790
			@Override
790
			@Override
791
			public void onSelect(ComboBox comboBox, Record record, int index) {  
791
			public void onSelect(ComboBox comboBox, Record record, int index) {  
792
                 selectionAbondance=true;
792
                 selectionAbondance=true;
793
                 abondanceModifiee = true;
793
                 abondanceModifiee = true;
794
             }
794
             }
795
         });
795
         });
796
		
796
		
797
		selecteurCertitude.addListener(new ComboBoxListenerAdapter() {  
797
		selecteurCertitude.addListener(new ComboBoxListenerAdapter() {  
798
 
798
 
799
			@Override
799
			@Override
800
			public void onSelect(ComboBox comboBox, Record record, int index) {  
800
			public void onSelect(ComboBox comboBox, Record record, int index) {  
801
                 selectionCertitude=true;
801
                 selectionCertitude=true;
802
                 certitudeModifiee = true;
802
                 certitudeModifiee = true;
803
             }
803
             }
804
         }); 
804
         }); 
805
		
805
		
806
		selecteurStadePheno.addListener(new ComboBoxListenerAdapter() {  
806
		selecteurStadePheno.addListener(new ComboBoxListenerAdapter() {  
807
			@Override
807
			@Override
808
			public void onSelect(ComboBox comboBox, Record record, int index) {  
808
			public void onSelect(ComboBox comboBox, Record record, int index) {  
809
                 selectionPhenologie=true;
809
                 selectionPhenologie=true;
810
                 phenologieModifiee = true;
810
                 phenologieModifiee = true;
811
             }
811
             }
812
         });  
812
         });  
813
	}
813
	}
814
	
814
	
815
	private void ajouterListenerChampEvenementsClavier(final TextField champ) {
815
	private void ajouterListenerChampEvenementsClavier(final TextField champ) {
816
		champ.addKeyPressListener(new EventCallback() {
816
		champ.addKeyPressListener(new EventCallback() {
817
			@Override
817
			@Override
818
			public void execute(EventObject e) {
818
			public void execute(EventObject e) {
819
				surEvenementClavier(e, champ);
819
				surEvenementClavier(e, champ);
820
			}
820
			}
821
	    });
821
	    });
822
	}
822
	}
823
	
823
	
824
	
824
	
825
	private void ajouterListenerChampEvenementsClavier(final TextField champ, final ListenerConfig config) {
825
	private void ajouterListenerChampEvenementsClavier(final TextField champ, final ListenerConfig config) {
826
		champ.addKeyPressListener(new EventCallback() {
826
		champ.addKeyPressListener(new EventCallback() {
827
			@Override
827
			@Override
828
			public void execute(EventObject e) {
828
			public void execute(EventObject e) {
829
				surEvenementClavier(e, champ);
829
				surEvenementClavier(e, champ);
830
			}
830
			}
831
	    }, config);
831
	    }, config);
832
	}
832
	}
833
	
833
	
834
	private void surEvenementClavier(EventObject e, TextField champ) {
834
	private void surEvenementClavier(EventObject e, TextField champ) {
835
		switch(e.getKey()) { 
835
		switch(e.getKey()) { 
836
			case KEY_ALT:
836
			case KEY_ALT:
837
			case KEY_CTRL:
837
			case KEY_CTRL:
838
			case KEY_DOWN:
838
			case KEY_DOWN:
839
			case KEY_END:
839
			case KEY_END:
840
			case KEY_ESCAPE:
840
			case KEY_ESCAPE:
841
			case KEY_HOME:
841
			case KEY_HOME:
842
			case KEY_LEFT:
842
			case KEY_LEFT:
843
			case KEY_PAGEDOWN:
843
			case KEY_PAGEDOWN:
844
			case KEY_PAGEUP:
844
			case KEY_PAGEUP:
845
			case KEY_RIGHT:
845
			case KEY_RIGHT:
846
			case KEY_SHIFT:
846
			case KEY_SHIFT:
847
			case KEY_TAB:
847
			case KEY_TAB:
848
			case KEY_UP:
848
			case KEY_UP:
849
	        break;
849
	        break;
850
	        
850
	        
851
		    case KEY_ENTER:
851
		    case KEY_ENTER:
852
		    	surEvenementClavierToucheEntree(champ);
852
		    	surEvenementClavierToucheEntree(champ);
853
		    	break;
853
		    	break;
854
	
854
	
855
	        default:
855
	        default:
856
	        	gererEvenementClavierDefaut(champ);
856
	        	gererEvenementClavierDefaut(champ);
857
	        break;
857
	        break;
858
		}
858
		}
859
	}
859
	}
860
	
860
	
861
	private void surEvenementClavierToucheEntree(TextField champ) {
861
	private void surEvenementClavierToucheEntree(TextField champ) {
862
		//TODO: faire un switch ou une enum
862
		//TODO: faire un switch ou une enum
863
		if(champ.equals(selecteurStadePheno)) {
863
		if(champ.equals(selecteurStadePheno)) {
864
			if(!selectionPhenologie) {	
864
			if(!selectionPhenologie) {	
865
  	    		validerSaisie(Champs.PHENOLOGIE); 	
865
  	    		validerSaisie(Champs.PHENOLOGIE); 	
866
	    	} else {
866
	    	} else {
867
	    		selectionPhenologie = false;
867
	    		selectionPhenologie = false;
868
	    	}
868
	    	}
869
		}
869
		}
870
		
870
		
871
		if(champ.equals(selecteurCertitude)) {
871
		if(champ.equals(selecteurCertitude)) {
872
			if(!selectionCertitude) {	
872
			if(!selectionCertitude) {	
873
		    		validerSaisie(Champs.CERTITUDE); 	
873
		    		validerSaisie(Champs.CERTITUDE); 	
874
	    	} else {
874
	    	} else {
875
	    		selectionCertitude = false;
875
	    		selectionCertitude = false;
876
	    	}
876
	    	}
877
		}
877
		}
878
		
878
		
879
		if(champ.equals(selecteurAbondance)) {
879
		if(champ.equals(selecteurAbondance)) {
880
			if(!selectionAbondance) {	
880
			if(!selectionAbondance) {	
881
		    	validerSaisie(Champs.ABONDANCE); 	
881
		    	validerSaisie(Champs.ABONDANCE); 	
882
	    	} else {
882
	    	} else {
883
	    		selectionAbondance = false;
883
	    		selectionAbondance = false;
884
	    	}
884
	    	}
885
		}
885
		}
886
		
886
		
887
		if(champ.equals(longitude)) {
887
		if(champ.equals(longitude)) {
888
			validerSaisie(Champs.LONGITUDE);
888
			validerSaisie(Champs.LONGITUDE);
889
		}
889
		}
890
		
890
		
891
		if(champ.equals(latitude)) {  	    	    	  
891
		if(champ.equals(latitude)) {  	    	    	  
892
	    	validerSaisie(Champs.LATITUDE); 
892
	    	validerSaisie(Champs.LATITUDE); 
893
		}
893
		}
894
		
894
		
895
		if(champ.equals(espece)) {
895
		if(champ.equals(espece)) {
896
			if(selectionEspece) {
896
			if(selectionEspece) {
897
	    		especeModifiee = true;
897
	    		especeModifiee = true;
898
	    		selectionEspece=false;
898
	    		selectionEspece=false;
899
	    	}
899
	    	}
900
	    	else {
900
	    	else {
901
	    		validerSaisie(Champs.ESPECE); 	    	    		 
901
	    		validerSaisie(Champs.ESPECE); 	    	    		 
902
	    	}
902
	    	}
903
		}
903
		}
904
		
904
		
905
		if(champ.equals(selecteurReferentielTaxo)) {
905
		if(champ.equals(selecteurReferentielTaxo)) {
906
			validerSaisie(Champs.REFERENTIELTAXO); 
906
			validerSaisie(Champs.REFERENTIELTAXO); 
907
		}
907
		}
908
		
908
		
909
		if(champ.equals(date)) {
909
		if(champ.equals(date)) {
910
			validerSaisie(Champs.DATE); 
910
			validerSaisie(Champs.DATE); 
911
		}
911
		}
912
		
912
		
913
		if(champ.equals(commune)) {		
913
		if(champ.equals(commune)) {		
914
			if(champ.equals(commune)) {
914
			if(champ.equals(commune)) {
915
				if (selectionCommune) {
915
				if (selectionCommune) {
916
		    		 communeModifiee= true;
916
		    		 communeModifiee= true;
917
		    		 selectionCommune=false;
917
		    		 selectionCommune=false;
918
		    	 }
918
		    	 }
919
		    	else {
919
		    	else {
920
		    		validerSaisie(Champs.COMMUNE);    	    	    		 
920
		    		validerSaisie(Champs.COMMUNE);    	    	    		 
921
		    	 }
921
		    	 }
922
			}
922
			}
923
		}
923
		}
924
	}
924
	}
925
	
925
	
926
	private void gererEvenementClavierDefaut(TextField champ) {
926
	private void gererEvenementClavierDefaut(TextField champ) {
927
		//TODO: faire un switch ou une enum
927
		//TODO: faire un switch ou une enum
928
		if(champ.equals(selecteurStadePheno)) {
928
		if(champ.equals(selecteurStadePheno)) {
929
			selecteurStadePheno.setRawValue(selecteurStadePheno.getRawValue());
929
			selecteurStadePheno.setRawValue(selecteurStadePheno.getRawValue());
930
			selecteurStadePheno.setValue(selecteurStadePheno.getRawValue());
930
			selecteurStadePheno.setValue(selecteurStadePheno.getRawValue());
931
			phenologieModifiee = true;
931
			phenologieModifiee = true;
932
			selectionPhenologie = false;
932
			selectionPhenologie = false;
933
		}
933
		}
934
		
934
		
935
		if(champ.equals(selecteurCertitude)) {
935
		if(champ.equals(selecteurCertitude)) {
936
			selecteurCertitude.setRawValue(selecteurCertitude.getRawValue());
936
			selecteurCertitude.setRawValue(selecteurCertitude.getRawValue());
937
	    	selecteurCertitude.setValue(selecteurCertitude.getRawValue());
937
	    	selecteurCertitude.setValue(selecteurCertitude.getRawValue());
938
	    	certitudeModifiee = true;
938
	    	certitudeModifiee = true;
939
	    	selectionCertitude = false;
939
	    	selectionCertitude = false;
940
		}
940
		}
941
		
941
		
942
		if(champ.equals(selecteurAbondance)) {
942
		if(champ.equals(selecteurAbondance)) {
943
			selecteurAbondance.setRawValue(selecteurAbondance.getRawValue());
943
			selecteurAbondance.setRawValue(selecteurAbondance.getRawValue());
944
	    	selecteurAbondance.setValue(selecteurAbondance.getRawValue());
944
	    	selecteurAbondance.setValue(selecteurAbondance.getRawValue());
945
	    	abondanceModifiee = true;
945
	    	abondanceModifiee = true;
946
	    	selectionAbondance = false;
946
	    	selectionAbondance = false;
947
		}
947
		}
948
		
948
		
949
		if(champ.equals(longitude)) {
949
		if(champ.equals(longitude)) {
950
			longModifiee = true;
950
			longModifiee = true;
951
        	tCoord.cancel();
951
        	tCoord.cancel();
952
        	tCoord.schedule(250);
952
        	tCoord.schedule(250);
953
		}
953
		}
954
		
954
		
955
		if(champ.equals(latitude)) {  	    	    	  
955
		if(champ.equals(latitude)) {  	    	    	  
956
			latModifiee = true;
956
			latModifiee = true;
957
	      	tCoord.cancel();
957
	      	tCoord.cancel();
958
	      	tCoord.schedule(250);
958
	      	tCoord.schedule(250);
959
		}
959
		}
960
		
960
		
961
		if(champ.equals(comment)) {
961
		if(champ.equals(comment)) {
962
			commModifie = true;
962
			commModifie = true;
963
		}
963
		}
964
		
964
		
965
		if(champ.equals(espece)) {
965
		if(champ.equals(espece)) {
966
			numeroNom="";
966
			numeroNom="";
967
	    	obtenirListeReferentielNom();
967
	    	obtenirListeReferentielNom();
968
	    	especeModifiee = true;
968
	    	especeModifiee = true;
969
		}
969
		}
970
		
970
		
971
		if(champ.equals(selecteurReferentielTaxo)) {
971
		if(champ.equals(selecteurReferentielTaxo)) {
972
			referentielTaxoModifie = true;
972
			referentielTaxoModifie = true;
973
		}
973
		}
974
		
974
		
975
		if(champ.equals(date)) {
975
		if(champ.equals(date)) {
976
			dateModifiee = true;
976
			dateModifiee = true;
977
		}
977
		}
978
		
978
		
979
		if(champ.equals(commune)) {
979
		if(champ.equals(commune)) {
980
			departement="";
980
			departement="";
981
	    	commune.collapse();	
981
	    	commune.collapse();	
982
	    	obtenirListeReferentielCommune();
982
	    	obtenirListeReferentielCommune();
983
	    	communeModifiee= true;	
983
	    	communeModifiee= true;	
984
		}
984
		}
985
	}
985
	}
986
 
986
 
987
	/**
987
	/**
988
	 * Validation de la saisie 
988
	 * Validation de la saisie 
989
	 */
989
	 */
990
	
990
	
991
	private void validerSaisie(Champs champs) {
991
	private void validerSaisie(Champs champs) {
992
		
992
		
993
		if(modification) {
993
		if(modification) {
994
			if(masseModification) {
994
			if(masseModification) {
995
				modifierObservationEnMasse(champs);
995
				modifierObservationEnMasse(champs);
996
			} else {
996
			} else {
997
				modifierObservation();
997
				modifierObservation();
998
			}
998
			}
999
			
999
			
1000
			raz(champs);
1000
			raz(champs);
1001
		}
1001
		}
1002
		else {
1002
		else {
1003
			ajouterObservation();
1003
			ajouterObservation();
1004
			raz(champs);
1004
			raz(champs);
1005
		}
1005
		}
1006
	}
1006
	}
1007
	
1007
	
1008
	/**
1008
	/**
1009
	 * Desactive visuellement ce panneau
1009
	 * Desactive visuellement ce panneau
1010
	 */
1010
	 */
1011
	public void desactiverPanneau()
1011
	public void desactiverPanneau()
1012
	{
1012
	{
1013
		this.setDisabled(true) ;
1013
		this.setDisabled(true) ;
1014
	}
1014
	}
1015
	
1015
	
1016
	/**
1016
	/**
1017
	 * Active visuellement ce panneau
1017
	 * Active visuellement ce panneau
1018
	 */
1018
	 */
1019
	public void activerPanneau()
1019
	public void activerPanneau()
1020
	{
1020
	{
1021
		this.setDisabled(false) ;
1021
		this.setDisabled(false) ;
1022
	}
1022
	}
1023
 
1023
 
1024
	@Override
1024
	@Override
1025
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
1025
	public void rafraichir(Object nouvelleDonnees, boolean repandreRaffraichissement) {
1026
		
1026
		
1027
		// si l'on a reçu une liste du referentiel commune (completion referentiel commune)
1027
		// si l'on a reçu une liste du referentiel commune (completion referentiel commune)
1028
			if(nouvelleDonnees instanceof ListeReferentielCommune)
1028
			if(nouvelleDonnees instanceof ListeReferentielCommune)
1029
			{
1029
			{
1030
				ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
1030
				ListeReferentielCommune data = (ListeReferentielCommune) nouvelleDonnees ;
1031
				Object[][] communeData = new Object[data.size()][3];
1031
				Object[][] communeData = new Object[data.size()][3];
1032
				int i = 0 ;
1032
				int i = 0 ;
1033
			
1033
			
1034
				// on la parse et on récupère les informations quiç nous interessent
1034
				// on la parse et on récupère les informations quiç nous interessent
1035
				for (Iterator it = data.keySet().iterator(); it.hasNext();) 
1035
				for (Iterator it = data.keySet().iterator(); it.hasNext();) 
1036
				{					
1036
				{					
1037
					ReferentielCommune ref=data.get(it.next());
1037
					ReferentielCommune ref=data.get(it.next());
1038
					
1038
					
1039
					communeData[i][0]= ref.getCommune();
1039
					communeData[i][0]= ref.getCommune();
1040
					communeData[i][1]= ref.getDepartement();
1040
					communeData[i][1]= ref.getDepartement();
1041
					communeData[i][2]= ref.getCodeInsee();
1041
					communeData[i][2]= ref.getCodeInsee();
1042
					i++ ;
1042
					i++ ;
1043
				}
1043
				}
1044
				
1044
				
1045
				// creation du store
1045
				// creation du store
1046
				FieldDef defCommune = new StringFieldDef("commune");
1046
				FieldDef defCommune = new StringFieldDef("commune");
1047
				FieldDef defDepartement = new StringFieldDef("departement");
1047
				FieldDef defDepartement = new StringFieldDef("departement");
1048
				FieldDef defCodeInsee = new StringFieldDef("codeInsee");
1048
				FieldDef defCodeInsee = new StringFieldDef("codeInsee");
1049
							
1049
							
1050
				FieldDef[] defTab = { defCommune, defDepartement, defCodeInsee};
1050
				FieldDef[] defTab = { defCommune, defDepartement, defCodeInsee};
1051
				
1051
				
1052
				RecordDef rd = new RecordDef(defTab);
1052
				RecordDef rd = new RecordDef(defTab);
1053
				
1053
				
1054
				final MemoryProxy dataProxy = new MemoryProxy(communeData);
1054
				final MemoryProxy dataProxy = new MemoryProxy(communeData);
1055
				final ArrayReader reader = new ArrayReader(rd);		
1055
				final ArrayReader reader = new ArrayReader(rd);		
1056
								
1056
								
1057
				Store store=new Store(dataProxy,reader);	
1057
				Store store=new Store(dataProxy,reader);	
1058
				commune.setStore(store);
1058
				commune.setStore(store);
1059
				store.load();
1059
				store.load();
1060
				
1060
				
1061
			}
1061
			}
1062
			
1062
			
1063
			// si l'on a reçu une liste du référentiel nom (complétion referentiel nom)
1063
			// si l'on a reçu une liste du référentiel nom (complétion referentiel nom)
1064
			if(nouvelleDonnees instanceof ListeReferentielNom)
1064
			if(nouvelleDonnees instanceof ListeReferentielNom)
1065
			{
1065
			{
1066
				ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ;
1066
				ListeReferentielNom data = (ListeReferentielNom) nouvelleDonnees ;
1067
				Object[][] nomData = new Object[data.size()][3];
1067
				Object[][] nomData = new Object[data.size()][3];
1068
				int i = 0 ;
1068
				int i = 0 ;
1069
 
1069
 
1070
				// on la parse et on récupère les informations qui nous interessent
1070
				// on la parse et on récupère les informations qui nous interessent
1071
				for (Iterator it = data.keySet().iterator(); it.hasNext();) 
1071
				for (Iterator it = data.keySet().iterator(); it.hasNext();) 
1072
				{
1072
				{
1073
					
1073
					
1074
					ReferentielNom ref=data.get(it.next());
1074
					ReferentielNom ref=data.get(it.next());
1075
					
1075
					
1076
					nomData[i][0]= ref.getNom();
1076
					nomData[i][0]= ref.getNom();
1077
					nomData[i][1]= ref.getNumeroNom();
1077
					nomData[i][1]= ref.getNumeroNom();
1078
					if (ref.getStatut().equals("3")) {
1078
					if (ref.getStatut().equals("3")) {
1079
						nomData[i][2]="nom_retenu";
1079
						nomData[i][2]="nom_retenu";
1080
					}
1080
					}
1081
					else {
1081
					else {
1082
						nomData[i][2]="";
1082
						nomData[i][2]="";
1083
					}														
1083
					}														
1084
					i++ ;
1084
					i++ ;
1085
				}
1085
				}
1086
 
1086
 
1087
				FieldDef defNom = new StringFieldDef("nom");
1087
				FieldDef defNom = new StringFieldDef("nom");
1088
				FieldDef defNumeroNom = new StringFieldDef("numeroNom");
1088
				FieldDef defNumeroNom = new StringFieldDef("numeroNom");
1089
				FieldDef indicateurNomRetenu = new StringFieldDef("indicateurNomRetenu");
1089
				FieldDef indicateurNomRetenu = new StringFieldDef("indicateurNomRetenu");
1090
						
1090
						
1091
				FieldDef[] defTab = { defNom, defNumeroNom, indicateurNomRetenu};
1091
				FieldDef[] defTab = { defNom, defNumeroNom, indicateurNomRetenu};
1092
				
1092
				
1093
				RecordDef rd = new RecordDef(defTab);
1093
				RecordDef rd = new RecordDef(defTab);
1094
				
1094
				
1095
				final MemoryProxy dataProxy = new MemoryProxy(nomData);
1095
				final MemoryProxy dataProxy = new MemoryProxy(nomData);
1096
				final ArrayReader reader = new ArrayReader(rd);		
1096
				final ArrayReader reader = new ArrayReader(rd);		
1097
				
1097
				
1098
				Store store=new Store(dataProxy,reader);	
1098
				Store store=new Store(dataProxy,reader);	
1099
				espece.setStore(store);
1099
				espece.setStore(store);
1100
				store.load() ;
1100
				store.load() ;
1101
			}
1101
			}
1102
			
1102
			
1103
			// On recoit une observation dont on veut afficher le detail 
1103
			// On recoit une observation dont on veut afficher le detail 
1104
			
1104
			
1105
			if(nouvelleDonnees instanceof Observation)
1105
			if(nouvelleDonnees instanceof Observation)
1106
			{
1106
			{
1107
				Observation obs = (Observation)nouvelleDonnees ;
1107
				Observation obs = (Observation)nouvelleDonnees ;
1108
				afficherDetailsObservation(obs) ;
1108
				afficherDetailsObservation(obs) ;
1109
			}
1109
			}
1110
			
1110
			
1111
			if(nouvelleDonnees instanceof ListeObservation) {
1111
			if(nouvelleDonnees instanceof ListeObservation) {
1112
				
1112
				
1113
				ListeObservation listeObs = (ListeObservation)nouvelleDonnees;
1113
				ListeObservation listeObs = (ListeObservation)nouvelleDonnees;
1114
				calculerAfficherDifferences(listeObs);
1114
				calculerAfficherDifferences(listeObs);
1115
			}
1115
			}
1116
			
1116
			
1117
			if(nouvelleDonnees instanceof String)
1117
			if(nouvelleDonnees instanceof String)
1118
			{
1118
			{
1119
				String str = (String)nouvelleDonnees ;
1119
				String str = (String)nouvelleDonnees ;
1120
				observationMediateur.obtenirNombreObservation() ;
1120
				observationMediateur.obtenirNombreObservation() ;
1121
			}
1121
			}
1122
			
1122
			
1123
			if(nouvelleDonnees instanceof String[]) {
1123
			if(nouvelleDonnees instanceof String[]) {
1124
				String[] anumNom = (String[])nouvelleDonnees ;
1124
				String[] anumNom = (String[])nouvelleDonnees ;
1125
				numeroNom = anumNom[1];
1125
				numeroNom = anumNom[1];
1126
				espece.setValue(anumNom[0]);
1126
				espece.setValue(anumNom[0]);
1127
				setModification("false");
1127
				setModification("false");
1128
			}
1128
			}
1129
			
1129
			
1130
			if(nouvelleDonnees instanceof EntiteGeographiqueObservation)
1130
			if(nouvelleDonnees instanceof EntiteGeographiqueObservation)
1131
			{
1131
			{
1132
				EntiteGeographiqueObservation infosComm = (EntiteGeographiqueObservation)nouvelleDonnees ;
1132
				EntiteGeographiqueObservation infosComm = (EntiteGeographiqueObservation)nouvelleDonnees ;
1133
				if(rechercheCommuneEnCours) {
1133
				if(rechercheCommuneEnCours) {
1134
					afficherIndicationCommune(infosComm);
1134
					afficherIndicationCommune(infosComm);
1135
				} else {
1135
				} else {
1136
					rafraichirCommuneEtCoord(infosComm);
1136
					rafraichirCommuneEtCoord(infosComm);
1137
				}
1137
				}
1138
			}
1138
			}
1139
 
1139
 
1140
	}
1140
	}
1141
	
1141
	
1142
	
1142
	
1143
	private void afficherIndicationCommune(
1143
	private void afficherIndicationCommune(
1144
			final EntiteGeographiqueObservation infosCom) {
1144
			final EntiteGeographiqueObservation infosCom) {
1145
		
1145
		
1146
		String nCommune = "";
1146
		String nCommune = "";
1147
		if(infosCom != null && !infosCom.getZoneGeo().trim().equals("")){
1147
		if(infosCom != null && !infosCom.getZoneGeo().trim().equals("")){
1148
			nCommune += infosCom.getZoneGeo();
1148
			nCommune += infosCom.getZoneGeo();
1149
			if(!infosCom.getIdZoneGeo().trim().equals(""))
1149
			if(!infosCom.getIdZoneGeo().trim().equals(""))
1150
			nCommune += " ("+Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo())+")";
1150
			nCommune += " ("+Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo())+")";
1151
			
1151
			
1152
			lienSelectionCommune.setHtml("<a id=\"lien_selection_commune\" tabindex=\"9\">"+nCommune+"</a>");
1152
			lienSelectionCommune.setHtml("<a id=\"lien_selection_commune\" tabindex=\"9\">"+nCommune+"</a>");
1153
			lienSelectionCommune.setStyleName("img-curseur-depl");
1153
			lienSelectionCommune.setStyleName("img-curseur-depl");
1154
			
1154
			
1155
			Ext.get("lien_selection_commune").addListener("click",new EventCallback() {
1155
			Ext.get("lien_selection_commune").addListener("click",new EventCallback() {
1156
				@Override
1156
				@Override
1157
				public void execute(EventObject e) {
1157
				public void execute(EventObject e) {
1158
					rafraichirCommune(infosCom);
1158
					rafraichirCommune(infosCom);
1159
				}			
1159
				}			
1160
			});
1160
			});
1161
			
1161
			
1162
			Ext.get("lien_selection_commune").addListener("keypress",new EventCallback() {
1162
			Ext.get("lien_selection_commune").addListener("keypress",new EventCallback() {
1163
				@Override
1163
				@Override
1164
				public void execute(EventObject e) {
1164
				public void execute(EventObject e) {
1165
					if(e.getCharCode() == KEY_ENTER) {
1165
					if(e.getCharCode() == KEY_ENTER) {
1166
						rafraichirCommune(infosCom);
1166
						rafraichirCommune(infosCom);
1167
					}
1167
					}
1168
				}			
1168
				}			
1169
			});
1169
			});
1170
			
1170
			
1171
			Ext.get("lien_selection_commune").addListener("focus",new EventCallback() {
1171
			Ext.get("lien_selection_commune").addListener("focus",new EventCallback() {
1172
				@Override
1172
				@Override
1173
				public void execute(EventObject e) {
1173
				public void execute(EventObject e) {
1174
					Ext.get("lien_selection_commune").toggleClass("lien_sel");
1174
					Ext.get("lien_selection_commune").toggleClass("lien_sel");
1175
				}			
1175
				}			
1176
			});
1176
			});
1177
			
1177
			
1178
			Ext.get("lien_selection_commune").addListener("blur",new EventCallback() {
1178
			Ext.get("lien_selection_commune").addListener("blur",new EventCallback() {
1179
				@Override
1179
				@Override
1180
				public void execute(EventObject e) {
1180
				public void execute(EventObject e) {
1181
					Ext.get("lien_selection_commune").toggleClass("lien_sel");
1181
					Ext.get("lien_selection_commune").toggleClass("lien_sel");
1182
				}			
1182
				}			
1183
			});
1183
			});
1184
			
1184
			
1185
		} else {
1185
		} else {
1186
			if(rechercheCommuneEnCours) {
1186
			if(rechercheCommuneEnCours) {
1187
				lienSelectionCommune.setHtml("<span id=\"aucune_selection_commune\"> Erreur de localisation </span>");
1187
				lienSelectionCommune.setHtml("<span id=\"aucune_selection_commune\"> Erreur de localisation </span>");
1188
			} else {
1188
			} else {
1189
				lienSelectionCommune.setHtml("<span id=\"aucune_selection_commune\"> </span>");
1189
				lienSelectionCommune.setHtml("<span id=\"aucune_selection_commune\"> </span>");
1190
			}
1190
			}
1191
		}
1191
		}
1192
 
1192
 
1193
		Ext.get(lienSelectionCommune.getElement()).unmask();
1193
		Ext.get(lienSelectionCommune.getElement()).unmask();
1194
		rechercheCommuneEnCours = false;
1194
		rechercheCommuneEnCours = false;
1195
	}
1195
	}
1196
	
1196
	
1197
	private void rafraichirCommune(EntiteGeographiqueObservation infosCom) {
1197
	private void rafraichirCommune(EntiteGeographiqueObservation infosCom) {
1198
		String nCommune = "";
1198
		String nCommune = "";
1199
	
1199
	
1200
		if(infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().equals("")) {
1200
		if(infosCom.getZoneGeo() != null && !infosCom.getZoneGeo().equals("")) {
1201
			nCommune += infosCom.getZoneGeo();
1201
			nCommune += infosCom.getZoneGeo();
1202
		}
1202
		}
1203
		
1203
		
1204
		if(infosCom.getIdZoneGeo() != null && !infosCom.getIdZoneGeo().equals("")) {
1204
		if(infosCom.getIdZoneGeo() != null && !infosCom.getIdZoneGeo().equals("")) {
1205
			String codeGeoFormate = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
1205
			String codeGeoFormate = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
1206
			nCommune += " ("+codeGeoFormate+")";
1206
			nCommune += " ("+codeGeoFormate+")";
1207
			departement = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
1207
			departement = Util.convertirChaineZoneGeoVersDepartement(infosCom.getIdZoneGeo());
1208
		}
1208
		}
1209
		commune.setValue(nCommune);
1209
		commune.setValue(nCommune);
1210
		communeModifiee = true;
1210
		communeModifiee = true;
1211
	}
1211
	}
1212
 
1212
 
1213
	private void rafraichirCommuneEtCoord(EntiteGeographiqueObservation infosCom) {
1213
	private void rafraichirCommuneEtCoord(EntiteGeographiqueObservation infosCom) {
1214
		// on ne remplace la commune que si le champ était vide
1214
		// on ne remplace la commune que si le champ était vide
1215
		if(commune.getRawValue() == null || commune.getRawValue().equals("")) {
1215
		if(commune.getRawValue() == null || commune.getRawValue().equals("")) {
1216
			rafraichirCommune(infosCom);
1216
			rafraichirCommune(infosCom);
1217
		} 
1217
		} 
1218
 
1218
 
1219
		if(infosCom.getLat() != null && !infosCom.getLat().equals("")) {
1219
		if(infosCom.getLat() != null && !infosCom.getLat().equals("")) {
1220
			latitude.setValue(infosCom.getLat());
1220
			latitude.setValue(infosCom.getLat());
1221
		}
1221
		}
1222
 
1222
 
1223
		if(infosCom.getLon() != null && !infosCom.getLon().equals("")) {
1223
		if(infosCom.getLon() != null && !infosCom.getLon().equals("")) {
1224
			longitude.setValue(infosCom.getLon());
1224
			longitude.setValue(infosCom.getLon());
1225
		}
1225
		}
1226
		
1226
		
1227
		latModifiee = true;
1227
		latModifiee = true;
1228
		longModifiee = true;
1228
		longModifiee = true;
1229
		
1229
		
1230
		coordPanel.setVisible(true);
1230
		coordPanel.setVisible(true);
1231
	}
1231
	}
1232
 
1232
 
1233
	public void obtenirListeReferentielCommune() {
1233
	public void obtenirListeReferentielCommune() {
1234
		
1234
		
1235
	 String com=commune.getText();
1235
	 String com=commune.getText();
1236
	 com=com.replaceAll("%","");
1236
	 com=com.replaceAll("%","");
1237
		  
1237
		  
1238
	 observationMediateur.obtenirListeReferentielCommune(this,com);
1238
	 observationMediateur.obtenirListeReferentielCommune(this,com);
1239
	 
1239
	 
1240
	}
1240
	}
1241
	
1241
	
1242
	public void obtenirListeReferentielNom() {	 
1242
	public void obtenirListeReferentielNom() {	 
1243
	  String esp=espece.getText().replaceAll(" ","/*");
1243
	  String esp=espece.getText().replaceAll(" ","/*");
1244
	  esp=esp.replaceAll("%","");
1244
	  esp=esp.replaceAll("%","");
1245
	  String referentiel = this.referentielTaxo;
1245
	  String referentiel = this.referentielTaxo;
1246
		
1246
		
1247
	  observationMediateur.obtenirListeReferentielNom(this,referentiel ,esp);	 
1247
	  observationMediateur.obtenirListeReferentielNom(this,referentiel ,esp);	 
1248
	}
1248
	}
1249
		
1249
		
1250
	protected void obtenirReferentielStation() {		
1250
	protected void obtenirReferentielStation() {		
1251
		observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_STATION,station.getText());
1251
		observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_STATION,station.getText());
1252
	}
1252
	}
1253
	
1253
	
1254
	protected void obtenirListeReferentielMilieu() {
1254
	protected void obtenirListeReferentielMilieu() {
1255
		observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_MILIEU,milieu.getText());
1255
		observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_MILIEU,milieu.getText());
1256
	}
1256
	}
1257
 
1257
 
1258
	protected void obtenirReferentielLieuDit() {
1258
	protected void obtenirReferentielLieuDit() {
1259
		observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_LIEU_DIT,lieudit.getText());
1259
		observationMediateur.obtenirListeReferentielPerso(this,TypesReferentiels.REFERENTIEL_LIEU_DIT,lieudit.getText());
1260
	}
1260
	}
1261
   
1261
   
1262
	public void ajouterObservation() {
1262
	public void ajouterObservation() {
1263
		
1263
		
1264
		if(!Util.verifierDateFormatCel(date.getRawValue()) && !date.getRawValue().equals("")) {
1264
		if(!Util.verifierDateFormatCel(date.getRawValue()) && !date.getRawValue().equals("")) {
1265
			Window.alert("Attention la date saisie est invalide, la date doit être au format jj/mm/aaaa");
1265
			Window.alert("Attention la date saisie est invalide, la date doit être au format jj/mm/aaaa");
1266
			date.setInvalidText("Date invalide");
1266
			date.setInvalidText("Date invalide");
1267
			return;
1267
			return;
1268
		}
1268
		}
1269
		
1269
		
1270
		if(departement != null) {
1270
		if(departement != null) {
1271
			if(departement.equals("000null") || departement.equals("")) {
1271
			if(departement.equals("000null") || departement.equals("")) {
1272
				String[] depCom = commune.getText().split(" ");
1272
				String[] depCom = commune.getText().split(" ");
1273
				if(depCom.length > 1) {
1273
				if(depCom.length > 1) {
1274
					String dep = depCom[1].replace('(', ' ');
1274
					String dep = depCom[1].replace('(', ' ');
1275
					dep =dep.replace(')', ' ');
1275
					dep =dep.replace(')', ' ');
1276
					dep = dep.trim();
1276
					dep = dep.trim();
1277
					dep = dep.replace('\\',' ');
1277
					dep = dep.replace('\\',' ');
1278
					dep = dep.trim();
1278
					dep = dep.trim();
1279
					
1279
					
1280
					try
1280
					try
1281
					{
1281
					{
1282
						int nDep = Integer.parseInt(dep);
1282
						int nDep = Integer.parseInt(dep);
1283
						if(nDep > 0 && nDep < 110) {
1283
						if(nDep > 0 && nDep < 110) {
1284
							departement = dep ;
1284
							departement = dep ;
1285
						}
1285
						}
1286
					}
1286
					}
1287
					catch(NumberFormatException e)
1287
					catch(NumberFormatException e)
1288
					{
1288
					{
1289
						departement = "" ;
1289
						departement = "" ;
1290
					}
1290
					}
1291
				}
1291
				}
1292
			}
1292
			}
1293
		}
1293
		}
1294
 
1294
 
1295
		String dateObs = Util.remplacerSeparateursDateFormatCel(date.getRawValue());
1295
		String dateObs = Util.remplacerSeparateursDateFormatCel(date.getRawValue());
1296
 
1296
 
1297
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);	
1297
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);	
1298
		
1298
		
1299
		String[] coords = getValeurCoordonnees();
1299
		String[] coords = getValeurCoordonnees();
1300
		obs.setLatitude(coords[0]);
1300
		obs.setLatitude(coords[0]);
1301
		obs.setLongitude(coords[1]);
1301
		obs.setLongitude(coords[1]);
1302
 
1302
 
1303
		obs.setAbondance(getAbondance());
1303
		obs.setAbondance(getAbondance());
1304
		obs.setCertitude(getCertitude());
1304
		obs.setCertitude(getCertitude());
1305
		obs.setPhenologie(getPhenologie());
1305
		obs.setPhenologie(getPhenologie());
1306
		
1306
		
1307
		obs.setReferentielTaxo(Ontologies.getInfosReferentielNomParCode(referentielTaxo).getCodeVersionComplet());
1307
		obs.setReferentielTaxo(Ontologies.getInfosReferentielNomParCode(referentielTaxo).getCodeVersionComplet());
1308
		
1308
		
1309
		observationMediateur.ajouterObservation(obs);
1309
		observationMediateur.ajouterObservation(obs);
1310
	}
1310
	}
1311
 
1311
 
1312
	private void modifierObservation() {
1312
	private void modifierObservation() {
1313
		
1313
		
1314
		if(!Util.verifierDateFormatCel(date.getRawValue()) && !date.getRawValue().equals("")) {
1314
		if(!Util.verifierDateFormatCel(date.getRawValue()) && !date.getRawValue().equals("")) {
1315
			Window.alert("Attention la date saisie est invalide, la date doit être au format jj/mm/aaaa");
1315
			Window.alert("Attention la date saisie est invalide, la date doit être au format jj/mm/aaaa");
1316
			date.setInvalidText("Date invalide");
1316
			date.setInvalidText("Date invalide");
1317
			return;
1317
			return;
1318
		}
1318
		}
1319
		
1319
		
1320
		if(departement.equals("000null") || departement.equals("")) {
1320
		if(departement.equals("000null") || departement.equals("")) {
1321
			String[] depCom = commune.getText().split(" ");
1321
			String[] depCom = commune.getText().split(" ");
1322
			if(depCom.length > 1) {
1322
			if(depCom.length > 1) {
1323
				String dep = depCom[1].replace('(', ' ');
1323
				String dep = depCom[1].replace('(', ' ');
1324
				dep =dep.replace(')', ' ');
1324
				dep =dep.replace(')', ' ');
1325
				dep = dep.trim();
1325
				dep = dep.trim();
1326
				dep = dep.replace('\\',' ');
1326
				dep = dep.replace('\\',' ');
1327
				dep = dep.trim();
1327
				dep = dep.trim();
1328
				
1328
				
1329
				try
1329
				try
1330
				{
1330
				{
1331
					int nDep = Integer.parseInt(dep);
1331
					int nDep = Integer.parseInt(dep);
1332
					if(nDep > 0 && nDep < 110) {
1332
					if(nDep > 0 && nDep < 110) {
1333
						departement = dep ;
1333
						departement = dep ;
1334
					}
1334
					}
1335
				}
1335
				}
1336
				catch(NumberFormatException e)
1336
				catch(NumberFormatException e)
1337
				{
1337
				{
1338
					departement = "" ;
1338
					departement = "" ;
1339
				}
1339
				}
1340
			}
1340
			}
1341
		}
1341
		}
1342
		
1342
		
1343
		String dateObs = Util.remplacerSeparateursDateFormatCel(date.getRawValue());
1343
		String dateObs = Util.remplacerSeparateursDateFormatCel(date.getRawValue());
1344
		
1344
		
1345
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);
1345
		Observation obs=new Observation(espece.getText(),numeroNom,commune.getText(),departement,lieudit.getText(),station.getText(),milieu.getText(), comment.getText(),dateObs);
1346
		obs.setNumeroOrdre(numeroOrdre);
1346
		obs.setNumeroOrdre(numeroOrdre);
1347
		
1347
		
1348
		String[] coords = getValeurCoordonnees();
1348
		String[] coords = getValeurCoordonnees();
1349
		
1349
		
1350
		obs.setLatitude(coords[0]);
1350
		obs.setLatitude(coords[0]);
1351
		obs.setLongitude(coords[1]);
1351
		obs.setLongitude(coords[1]);
1352
		
1352
		
1353
		obs.setAbondance(getAbondance());
1353
		obs.setAbondance(getAbondance());
1354
		obs.setCertitude(getCertitude());
1354
		obs.setCertitude(getCertitude());
1355
		obs.setPhenologie(getPhenologie());
1355
		obs.setPhenologie(getPhenologie());
1356
		obs.setReferentielTaxo(getReferentielTaxo());
1356
		obs.setReferentielTaxo(getReferentielTaxo());
1357
		
1357
		
1358
		observationMediateur.modifierObservation(obs);
1358
		observationMediateur.modifierObservation(obs);
1359
 
1359
 
1360
		selecteurMode.setValue("création");
1360
		selecteurMode.setValue("création");
1361
		setModification("false");
1361
		setModification("false");
1362
	}
1362
	}
1363
	
1363
	
1364
	private void modifierObservationEnMasse(Champs champModifie) {
1364
	private void modifierObservationEnMasse(Champs champModifie) {
1365
		
1365
		
1366
		//TODO: factoriser
1366
		//TODO: factoriser
1367
		String communeM = null;
1367
		String communeM = null;
1368
		String departementM = null;
1368
		String departementM = null;
1369
		String numNomSelM = null;
1369
		String numNomSelM = null;
1370
		String lieuDitM = null;
1370
		String lieuDitM = null;
1371
		String stationM = null;
1371
		String stationM = null;
1372
		String milieuM = null;
1372
		String milieuM = null;
1373
		String dateM = null;
1373
		String dateM = null;
1374
		String especeM = null;
1374
		String especeM = null;
1375
		String commM = null; 
1375
		String commM = null; 
1376
		String latM = null;
1376
		String latM = null;
1377
		String longM = null;
1377
		String longM = null;
1378
		String abondanceM = null;
1378
		String abondanceM = null;
1379
		String certitudeM = null;
1379
		String certitudeM = null;
1380
		String referentielTaxoM = null;
1380
		String referentielTaxoM = null;
1381
		String phenologieM = null;
1381
		String phenologieM = null;
1382
		
1382
		
1383
		String champs = modeleMessageModif;
1383
		String champs = modeleMessageModif;
1384
			
1384
			
1385
		if(communeModifiee) {
1385
		if(communeModifiee) {
1386
			communeM = commune.getText();
1386
			communeM = commune.getText();
1387
			
1387
			
1388
			if(departement.equals("000null") || departement.equals("")) {
1388
			if(departement.equals("000null") || departement.equals("")) {
1389
				String[] depCom = commune.getText().split(" ");
1389
				String[] depCom = commune.getText().split(" ");
1390
				if(depCom.length > 1) {
1390
				if(depCom.length > 1) {
1391
					String dep = depCom[1].replace('(', ' ');
1391
					String dep = depCom[1].replace('(', ' ');
1392
					dep =dep.replace(')', ' ');
1392
					dep =dep.replace(')', ' ');
1393
					dep = dep.trim();
1393
					dep = dep.trim();
1394
					dep = dep.replace('\\',' ');
1394
					dep = dep.replace('\\',' ');
1395
					dep = dep.trim();
1395
					dep = dep.trim();
1396
					
1396
					
1397
					try
1397
					try
1398
					{
1398
					{
1399
						int nDep = Integer.parseInt(dep);
1399
						int nDep = Integer.parseInt(dep);
1400
						if(nDep > 0 && nDep < 110) {
1400
						if(nDep > 0 && nDep < 110) {
1401
							departement = dep ;
1401
							departement = dep ;
1402
						}
1402
						}
1403
					}
1403
					}
1404
					catch(NumberFormatException e)
1404
					catch(NumberFormatException e)
1405
					{
1405
					{
1406
						departement = "" ;
1406
						departement = "" ;
1407
					}
1407
					}
1408
				}
1408
				}
1409
			}
1409
			}
1410
			
1410
			
1411
			departementM = departement;
1411
			departementM = departement;
1412
		} else {
1412
		} else {
1413
			champs = champs.replaceAll("commune", "");
1413
			champs = champs.replaceAll("commune", "");
1414
		}
1414
		}
1415
		
1415
		
1416
		if(lieuDitModifie) {
1416
		if(lieuDitModifie) {
1417
			lieuDitM = lieudit.getText();
1417
			lieuDitM = lieudit.getText();
1418
		}else {
1418
		}else {
1419
			champs = champs.replaceAll(":lieu-dit", "");
1419
			champs = champs.replaceAll(":lieu-dit", "");
1420
		}
1420
		}
1421
		
1421
		
1422
		if(stationModifiee) {
1422
		if(stationModifiee) {
1423
			stationM = station.getText();
1423
			stationM = station.getText();
1424
		}else {
1424
		}else {
1425
			champs = champs.replaceAll(":station", "");
1425
			champs = champs.replaceAll(":station", "");
1426
		}
1426
		}
1427
 
1427
 
1428
		if(milieuModifie) {
1428
		if(milieuModifie) {
1429
			milieuM = milieu.getText();
1429
			milieuM = milieu.getText();
1430
		}else {
1430
		}else {
1431
			champs = champs.replaceAll(":milieu", "");
1431
			champs = champs.replaceAll(":milieu", "");
1432
		}
1432
		}
1433
 
1433
 
1434
		if(dateModifiee && !date.getRawValue().equals(VALEURS_MULTIPLES)) {
1434
		if(dateModifiee && !date.getRawValue().equals(VALEURS_MULTIPLES)) {
1435
			dateM = date.getRawValue();
1435
			dateM = date.getRawValue();
1436
			dateM = Util.remplacerSeparateursDateFormatCel(dateM);
1436
			dateM = Util.remplacerSeparateursDateFormatCel(dateM);
1437
		}else {
1437
		}else {
1438
			champs = champs.replaceAll(":date", "");
1438
			champs = champs.replaceAll(":date", "");
1439
		}
1439
		}
1440
 
1440
 
1441
		if(especeModifiee) {
1441
		if(especeModifiee) {
1442
			especeM = espece.getText();
1442
			especeM = espece.getText();
1443
			numNomSelM = numeroNom;
1443
			numNomSelM = numeroNom;
1444
		}else {
1444
		}else {
1445
			champs = champs.replaceAll(":espece", "");
1445
			champs = champs.replaceAll(":espece", "");
1446
		}
1446
		}
1447
 
1447
 
1448
		if(commModifie) {
1448
		if(commModifie) {
1449
			commM = comment.getText();
1449
			commM = comment.getText();
1450
		}else {
1450
		}else {
1451
			champs = champs.replaceAll(":commentaire", "");
1451
			champs = champs.replaceAll(":commentaire", "");
1452
		}
1452
		}
1453
		
1453
		
1454
		if(latModifiee) {
1454
		if(latModifiee) {
1455
			latM = latitude.getText();
1455
			latM = latitude.getText();
1456
		}else {
1456
		}else {
1457
			champs = champs.replaceAll(":latitude", "");
1457
			champs = champs.replaceAll(":latitude", "");
1458
		}
1458
		}
1459
		
1459
		
1460
		if(longModifiee) {
1460
		if(longModifiee) {
1461
			longM = longitude.getText();
1461
			longM = longitude.getText();
1462
		}else {
1462
		}else {
1463
			champs = champs.replaceAll(":longitude", "");
1463
			champs = champs.replaceAll(":longitude", "");
1464
		}
1464
		}
1465
		
1465
		
1466
		if(abondanceModifiee && !selecteurAbondance.getRawValue().equals(VALEURS_MULTIPLES)) {
1466
		if(abondanceModifiee && !selecteurAbondance.getRawValue().equals(VALEURS_MULTIPLES)) {
1467
			abondanceM = getAbondance();
1467
			abondanceM = getAbondance();
1468
		} else {
1468
		} else {
1469
			champs = champs.replaceAll(":abondance", "");
1469
			champs = champs.replaceAll(":abondance", "");
1470
		}
1470
		}
1471
		
1471
		
1472
		if(certitudeModifiee && !selecteurCertitude.getRawValue().equals(VALEURS_MULTIPLES)) {
1472
		if(certitudeModifiee && !selecteurCertitude.getRawValue().equals(VALEURS_MULTIPLES)) {
1473
			certitudeM = getCertitude();
1473
			certitudeM = getCertitude();
1474
		} else {
1474
		} else {
1475
			champs = champs.replaceAll(":identification", "");
1475
			champs = champs.replaceAll(":identification", "");
1476
		}
1476
		}
1477
		
1477
		
1478
		if(referentielTaxoModifie && !selecteurReferentielTaxo.getRawValue().equals(VALEURS_MULTIPLES)) {
1478
		if(referentielTaxoModifie && !selecteurReferentielTaxo.getRawValue().equals(VALEURS_MULTIPLES)) {
1479
			referentielTaxoM = getReferentielTaxo();
1479
			referentielTaxoM = getReferentielTaxo();
1480
		} else {
1480
		} else {
1481
			champs = champs.replaceAll(":referentiel", "");
1481
			champs = champs.replaceAll(":referentiel", "");
1482
		}
1482
		}
1483
		
1483
		
1484
		if(phenologieModifiee && !selecteurStadePheno.getRawValue().equals(VALEURS_MULTIPLES)) {
1484
		if(phenologieModifiee && !selecteurStadePheno.getRawValue().equals(VALEURS_MULTIPLES)) {
1485
			phenologieM = getPhenologie();
1485
			phenologieM = getPhenologie();
1486
		} else {
1486
		} else {
1487
			champs = champs.replaceAll(":phenologie", "");
1487
			champs = champs.replaceAll(":phenologie", "");
1488
		}
1488
		}
1489
		
1489
		
1490
		champs = champs.replaceAll(":",", ");
1490
		champs = champs.replaceAll(":",", ");
1491
		if(champs.startsWith(",")) {
1491
		if(champs.startsWith(",")) {
1492
			champs = champs.replaceFirst(",", "");
1492
			champs = champs.replaceFirst(",", "");
1493
		}
1493
		}
1494
		
1494
		
1495
		String message = "Voulez vous modifier le(s) champ(s) suivant(s) : "+champs+"   pour les observations selectionnées ?" ;
1495
		String message = "Voulez vous modifier le(s) champ(s) suivant(s) : "+champs+"   pour les observations selectionnées ?" ;
1496
		
1496
		
1497
		if(champs.trim().equals("")) {
1497
		if(champs.trim().equals("")) {
1498
			Window.alert("Aucun champ n'a été modifié");
1498
			Window.alert("Aucun champ n'a été modifié");
1499
		} else {
1499
		} else {
1500
			Observation obs = new Observation(especeM,numNomSelM,communeM,departementM,lieuDitM,stationM,milieuM, commM,dateM);
1500
			Observation obs = new Observation(especeM,numNomSelM,communeM,departementM,lieuDitM,stationM,milieuM, commM,dateM);
1501
			obs.setNumeroOrdre(numeroOrdre);
1501
			obs.setNumeroOrdre(numeroOrdre);
1502
			obs.setLatitude(latM);
1502
			obs.setLatitude(latM);
1503
			obs.setLongitude(longM);
1503
			obs.setLongitude(longM);
1504
			obs.setAbondance(abondanceM);
1504
			obs.setAbondance(abondanceM);
1505
			obs.setCertitude(certitudeM);
1505
			obs.setCertitude(certitudeM);
1506
			obs.setReferentielTaxo(referentielTaxoM);
1506
			obs.setReferentielTaxo(referentielTaxoM);
1507
			obs.setPhenologie(phenologieM);
1507
			obs.setPhenologie(phenologieM);
1508
			if(Window.confirm(message)) {
1508
			if(Window.confirm(message)) {
1509
				observationMediateur.modifierObservationEnMasse(obs);
1509
				observationMediateur.modifierObservationEnMasse(obs);
1510
				reinitialiserValeurModifiees();
1510
				reinitialiserValeurModifiees();
1511
			}
1511
			}
1512
		}
1512
		}
1513
	}
1513
	}
1514
	
1514
	
1515
	private void supprimerObservation() {		
1515
	private void supprimerObservation() {		
1516
		observationMediateur.supprimerObservation(this, numeroOrdre);
1516
		observationMediateur.supprimerObservation(this, numeroOrdre);
1517
	}
1517
	}
1518
	
1518
	
1519
	public void afficherDetailsObservation(Observation obs)
1519
	public void afficherDetailsObservation(Observation obs)
1520
	{
1520
	{
1521
		raz() ;
1521
		raz() ;
1522
		String idLoc ;
1522
		String idLoc ;
1523
		if(obs.getIdentifiantLocalite() != VALEURS_MULTIPLES) {
1523
		if(obs.getIdentifiantLocalite() != VALEURS_MULTIPLES) {
1524
			idLoc = obs.getIdentifiantLocalite().replaceAll(" ","/");
1524
			idLoc = obs.getIdentifiantLocalite().replaceAll(" ","/");
1525
			idLoc = idLoc.replaceAll("%","");
1525
			idLoc = idLoc.replaceAll("%","");
1526
			idLoc = idLoc.replaceAll("\"","");
1526
			idLoc = idLoc.replaceAll("\"","");
1527
			idLoc = idLoc.replace('\\',' ');
1527
			idLoc = idLoc.replace('\\',' ');
1528
			idLoc = idLoc.trim();
1528
			idLoc = idLoc.trim();
1529
			if(idLoc.length() == 5) {
1529
			if(idLoc.length() == 5) {
1530
				idLoc = idLoc.substring(0,2);
1530
				idLoc = idLoc.substring(0,2);
1531
			}
1531
			}
1532
		} else {
1532
		} else {
1533
			idLoc = obs.getIdentifiantLocalite();
1533
			idLoc = obs.getIdentifiantLocalite();
1534
			if(idLoc.length() == 5) {
1534
			if(idLoc.length() == 5) {
1535
				idLoc = idLoc.substring(0,2);
1535
				idLoc = idLoc.substring(0,2);
1536
			}
1536
			}
1537
		}
1537
		}
1538
		
1538
		
1539
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null") && !obs.getDate().equals(VALEURS_MULTIPLES)) {
1539
		if(!obs.getDate().equals("null") && !obs.getDate().equals("000null") && !obs.getDate().equals(VALEURS_MULTIPLES)) {
1540
			String[] dateEtHeure = obs.getDate().split(" ", 2);
1540
			String[] dateEtHeure = obs.getDate().split(" ", 2);
1541
			if(verifierFormatDate(dateEtHeure[0])) {
1541
			if(verifierFormatDate(dateEtHeure[0])) {
1542
				date.setValue(dateEtHeure[0]) ;
1542
				date.setValue(dateEtHeure[0]) ;
1543
			}
1543
			}
1544
			else
1544
			else
1545
			{
1545
			{
1546
				date.setRawValue(""); 
1546
				date.setRawValue(""); 
1547
			}
1547
			}
1548
		} else {
1548
		} else {
1549
			date.setRawValue(VALEURS_MULTIPLES);
1549
			date.setRawValue(VALEURS_MULTIPLES);
1550
			date.clearInvalid();
1550
			date.clearInvalid();
1551
		}
1551
		}
1552
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
1552
		if(!obs.getLieudit().equals("null") && !obs.getLieudit().equals("000null")) {
1553
			lieudit.setValue(obs.getLieudit()) ;
1553
			lieudit.setValue(obs.getLieudit()) ;
1554
		}
1554
		}
1555
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
1555
		if(!obs.getStation().equals("null") && !obs.getStation().equals("000null")) {
1556
			station.setValue(obs.getStation()) ;
1556
			station.setValue(obs.getStation()) ;
1557
		}
1557
		}
1558
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
1558
		if(!obs.getMilieu().equals("null") && !obs.getMilieu().equals("000null")) {
1559
			milieu.setValue(obs.getMilieu()) ;
1559
			milieu.setValue(obs.getMilieu()) ;
1560
		}
1560
		}
1561
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
1561
		if(!obs.getCommentaire().equals("null") && !obs.getCommentaire().equals("000null")) {
1562
 
1562
 
1563
			comment.setRawValue(Util.remplacerSautsDeligneMalEncodes(obs.getCommentaire()));
1563
			comment.setRawValue(Util.remplacerSautsDeligneMalEncodes(obs.getCommentaire()));
1564
			
1564
			
1565
		}
1565
		}
1566
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
1566
		if(!obs.getLocalite().equals("null") && !obs.getLocalite().equals("000null")) {
1567
			if(!idLoc.equals("000null") && !idLoc.equals("")) {
1567
			if(!idLoc.equals("000null") && !idLoc.equals("")) {
1568
				if(!idLoc.equals(VALEURS_MULTIPLES)) {
1568
				if(!idLoc.equals(VALEURS_MULTIPLES)) {
1569
					commune.setValue(obs.getLocalite()+" ("+idLoc+")") ;
1569
					commune.setValue(obs.getLocalite()+" ("+idLoc+")") ;
1570
				} else {
1570
				} else {
1571
					commune.setValue(VALEURS_MULTIPLES);
1571
					commune.setValue(VALEURS_MULTIPLES);
1572
				}
1572
				}
1573
			}
1573
			}
1574
			else
1574
			else
1575
			{
1575
			{
1576
				commune.setValue(obs.getLocalite());
1576
				commune.setValue(obs.getLocalite());
1577
			}
1577
			}
1578
		}
1578
		}
1579
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
1579
		if(!obs.getIdentifiantLocalite().equals("null") && !obs.getIdentifiantLocalite().equals("000null")) {
1580
			departement = idLoc;
1580
			departement = idLoc;
1581
		}
1581
		}
1582
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
1582
		if(!obs.getNomSaisi().equals("null") && !obs.getNomSaisi().equals("000null")) {
1583
			espece.setValue(obs.getNomSaisi()) ;
1583
			espece.setValue(obs.getNomSaisi()) ;
1584
		}
1584
		}
1585
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
1585
		if(!obs.getNumeroNomenclaturalSaisi().equals("null") && !obs.getNumeroNomenclaturalSaisi().equals("000null")) {
1586
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
1586
			numeroNom = obs.getNumeroNomenclaturalSaisi() ;
1587
		}
1587
		}
1588
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000null")) {
1588
		if(!obs.getNumeroOrdre().equals("null") && !obs.getNumeroOrdre().equals("000null")) {
1589
			numeroOrdre = obs.getNumeroOrdre() ;
1589
			numeroOrdre = obs.getNumeroOrdre() ;
1590
		}
1590
		}
1591
		
1591
		
1592
		if(!obs.getLatitude().equals("null") && !obs.getLatitude().equals("000null")
1592
		if(!obs.getLatitude().equals("null") && !obs.getLatitude().equals("000null")
1593
				&& !obs.getLongitude().equals("null") && !obs.getLongitude().equals("000null")) {
1593
				&& !obs.getLongitude().equals("null") && !obs.getLongitude().equals("000null")) {
1594
			latitude.setValue(obs.getLatitude()) ;
1594
			latitude.setValue(obs.getLatitude()) ;
1595
			longitude.setValue(obs.getLongitude()) ;
1595
			longitude.setValue(obs.getLongitude()) ;
1596
		}
1596
		}
1597
		
1597
		
1598
		selecteurAbondance.getStore().load();
1598
		selecteurAbondance.getStore().load();
1599
		selecteurAbondance.setValue(obs.getAbondance());
1599
		selecteurAbondance.setValue(obs.getAbondance());
1600
		
1600
		
1601
		selecteurCertitude.getStore().load();
1601
		selecteurCertitude.getStore().load();
1602
		selecteurCertitude.setValue(obs.getCertitude());
1602
		selecteurCertitude.setValue(obs.getCertitude());
1603
		
1603
		
1604
		selecteurStadePheno.getStore().load();
1604
		selecteurStadePheno.getStore().load();
1605
		selecteurStadePheno.setValue(obs.getPhenologie());
1605
		selecteurStadePheno.setValue(obs.getPhenologie());
1606
		
1606
		
1607
		selecteurReferentielTaxo.getStore().load();
1607
		selecteurReferentielTaxo.getStore().load();
1608
		if(obs.getReferentielTaxo() != VALEURS_MULTIPLES) {
1608
		if(obs.getReferentielTaxo() != VALEURS_MULTIPLES) {
1609
			referentielTaxo = obs.getCodeCourtReferentielTaxo();
1609
			referentielTaxo = obs.getCodeCourtReferentielTaxo();
-
 
1610
			if(referentielTaxo == null || referentielTaxo.isEmpty()) {
-
 
1611
			    referentielTaxo = Configuration.getReferentielsDispos().get(0).getCode();
-
 
1612
			}
1610
			selecteurReferentielTaxo.setValue(referentielTaxo);
1613
			selecteurReferentielTaxo.setValue(referentielTaxo);
1611
		} else {
1614
		} else {
1612
			referentielTaxo = "";
1615
			referentielTaxo = "";
1613
			selecteurReferentielTaxo.setRawValue(VALEURS_MULTIPLES);
1616
			selecteurReferentielTaxo.setRawValue(VALEURS_MULTIPLES);
1614
		}
1617
		}
1615
	}
1618
	}
1616
	
1619
	
1617
	
1620
	
1618
	public void raz()
1621
	public void raz()
1619
	{
1622
	{
1620
		raz(Champs.TOUT);
1623
		raz(Champs.TOUT);
1621
		
1624
		
1622
	}
1625
	}
1623
	public void raz(Champs champs)
1626
	public void raz(Champs champs)
1624
	{
1627
	{
1625
		switch (champs) {
1628
		switch (champs) {
1626
			case DATE:
1629
			case DATE:
1627
				date.reset() ;
1630
				date.reset() ;
1628
				break;
1631
				break;
1629
		
1632
		
1630
			case LIEUDIT:
1633
			case LIEUDIT:
1631
				lieudit.reset() ;
1634
				lieudit.reset() ;
1632
				break;
1635
				break;
1633
		
1636
		
1634
			case STATION:
1637
			case STATION:
1635
				station.reset() ;
1638
				station.reset() ;
1636
				break;
1639
				break;
1637
		
1640
		
1638
			case MILIEU:
1641
			case MILIEU:
1639
				milieu.reset() ;
1642
				milieu.reset() ;
1640
				break;
1643
				break;
1641
		
1644
		
1642
			case COMMENT:
1645
			case COMMENT:
1643
				comment.reset() ;
1646
				comment.reset() ;
1644
				break;
1647
				break;
1645
 
1648
 
1646
			case COMMUNE:
1649
			case COMMUNE:
1647
				commune.reset() ;
1650
				commune.reset() ;
1648
				departement ="";
1651
				departement ="";
1649
				latitude.reset();
1652
				latitude.reset();
1650
				longitude.reset();
1653
				longitude.reset();
1651
				break;
1654
				break;
1652
				
1655
				
1653
			case ESPECE:
1656
			case ESPECE:
1654
				espece.reset();
1657
				espece.reset();
1655
				numeroNom = "" ;
1658
				numeroNom = "" ;
1656
				numeroOrdre = "";
1659
				numeroOrdre = "";
1657
				break;
1660
				break;
1658
				
1661
				
1659
			case LATITUDE:
1662
			case LATITUDE:
1660
				latitude.reset();
1663
				latitude.reset();
1661
				afficherIndicationCommune(null);
1664
				afficherIndicationCommune(null);
1662
				break;
1665
				break;
1663
				
1666
				
1664
			case LONGITUDE:
1667
			case LONGITUDE:
1665
				longitude.reset();
1668
				longitude.reset();
1666
				afficherIndicationCommune(null);
1669
				afficherIndicationCommune(null);
1667
				break;
1670
				break;
1668
				
1671
				
1669
			case ABONDANCE:
1672
			case ABONDANCE:
1670
				selecteurAbondance.setValue("");
1673
				selecteurAbondance.setValue("");
1671
				break;
1674
				break;
1672
				
1675
				
1673
			case CERTITUDE:
1676
			case CERTITUDE:
1674
				selecteurCertitude.setValue("");
1677
				selecteurCertitude.setValue("");
1675
				break;
1678
				break;
1676
				
1679
				
1677
			case REFERENTIELTAXO:
1680
			case REFERENTIELTAXO:
1678
				selecteurReferentielTaxo.setValue("");
1681
				selecteurReferentielTaxo.setValue("");
1679
				break;
1682
				break;
1680
			
1683
			
1681
			case PHENOLOGIE:
1684
			case PHENOLOGIE:
1682
				selecteurStadePheno.setValue("");
1685
				selecteurStadePheno.setValue("");
1683
				break;
1686
				break;
1684
				
1687
				
1685
			case TOUT:
1688
			case TOUT:
1686
				commune.reset();
1689
				commune.reset();
1687
				date.reset() ;
1690
				date.reset() ;
1688
				lieudit.reset() ;
1691
				lieudit.reset() ;
1689
				station.reset() ;
1692
				station.reset() ;
1690
				milieu.reset() ;
1693
				milieu.reset() ;
1691
				comment.reset() ;
1694
				comment.reset() ;
1692
				milieu.reset() ;
1695
				milieu.reset() ;
1693
				latitude.reset();
1696
				latitude.reset();
1694
				longitude.reset();
1697
				longitude.reset();
1695
				departement ="";
1698
				departement ="";
1696
				espece.reset();
1699
				espece.reset();
1697
				selecteurAbondance.clearValue();
1700
				selecteurAbondance.clearValue();
1698
				selecteurCertitude.clearValue();
1701
				selecteurCertitude.clearValue();
1699
				selecteurReferentielTaxo.clearValue();
1702
				selecteurReferentielTaxo.clearValue();
1700
				selecteurStadePheno.clearValue();
1703
				selecteurStadePheno.clearValue();
1701
				referentielTaxo = "";
1704
				referentielTaxo = "";
1702
				numeroNom = "" ;
1705
				numeroNom = "" ;
1703
				numeroOrdre = "";
1706
				numeroOrdre = "";
1704
				afficherIndicationCommune(null);
1707
				afficherIndicationCommune(null);
1705
				break;
1708
				break;
1706
 
1709
 
1707
		}
1710
		}
1708
		
1711
		
1709
	}
1712
	}
1710
	
1713
	
1711
	private void setModification(String mode)
1714
	private void setModification(String mode)
1712
	{
1715
	{
1713
		if(mode.equals("true")) {
1716
		if(mode.equals("true")) {
1714
 
1717
 
1715
			boutonOK.setText("Modifier") ;
1718
			boutonOK.setText("Modifier") ;
1716
			setTitle("Modification") ;
1719
			setTitle("Modification") ;
1717
			boutonAnnuler.setText("Supprimer") ;
1720
			boutonAnnuler.setText("Supprimer") ;
1718
			modification = true ;
1721
			modification = true ;
1719
			selecteurMode.removeClass("x-selec-crea") ;
1722
			selecteurMode.removeClass("x-selec-crea") ;
1720
			selecteurMode.setCls("x-selec-modif") ;
1723
			selecteurMode.setCls("x-selec-modif") ;
1721
			observationMediateur.onModeModification();
1724
			observationMediateur.onModeModification();
1722
		}
1725
		}
1723
		else
1726
		else
1724
		{
1727
		{
1725
			boutonOK.setText("Créer") ;
1728
			boutonOK.setText("Créer") ;
1726
			setTitle("Saisir") ;
1729
			setTitle("Saisir") ;
1727
			boutonAnnuler.setText("Réinitialiser") ;
1730
			boutonAnnuler.setText("Réinitialiser") ;
1728
			modification = false ;
1731
			modification = false ;
1729
			selecteurMode.removeClass("x-selec-modif") ;
1732
			selecteurMode.removeClass("x-selec-modif") ;
1730
			selecteurMode.setCls("x-selec-crea") ;
1733
			selecteurMode.setCls("x-selec-crea") ;
1731
			observationMediateur.onModeCreation();
1734
			observationMediateur.onModeCreation();
1732
		}	
1735
		}	
1733
	}
1736
	}
1734
	
1737
	
1735
	/**
1738
	/**
1736
	 * renvoie vrai si on est en mode modification, faux si on est en mode création
1739
	 * renvoie vrai si on est en mode modification, faux si on est en mode création
1737
	 * @return
1740
	 * @return
1738
	 */
1741
	 */
1739
	public boolean getModification()
1742
	public boolean getModification()
1740
	{
1743
	{
1741
		return modification ;
1744
		return modification ;
1742
	}
1745
	}
1743
	
1746
	
1744
	/**
1747
	/**
1745
	 * renvoie vrai si on est en mode modification de masse, faux sinon
1748
	 * renvoie vrai si on est en mode modification de masse, faux sinon
1746
	 * @return
1749
	 * @return
1747
	 */
1750
	 */
1748
	public boolean getMasseModification()
1751
	public boolean getMasseModification()
1749
	{
1752
	{
1750
		return masseModification ;
1753
		return masseModification ;
1751
	}
1754
	}
1752
	
1755
	
1753
	public boolean verifierFormatDate(String date) {
1756
	public boolean verifierFormatDate(String date) {
1754
		
1757
		
1755
		String regex = "[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}" ;
1758
		String regex = "[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}" ;
1756
		if(date.matches(regex) && !date.equals("0000-00-00")) {
1759
		if(date.matches(regex) && !date.equals("0000-00-00")) {
1757
			return true ;
1760
			return true ;
1758
		}
1761
		}
1759
		else {
1762
		else {
1760
			return false;
1763
			return false;
1761
		}
1764
		}
1762
	}
1765
	}
1763
 
1766
 
1764
	public void setMasseModification(boolean masseModification) {
1767
	public void setMasseModification(boolean masseModification) {
1765
		this.masseModification = masseModification;
1768
		this.masseModification = masseModification;
1766
		if(masseModification) {
1769
		if(masseModification) {
1767
			reinitialiserValeurModifiees();
1770
			reinitialiserValeurModifiees();
1768
		}
1771
		}
1769
	}
1772
	}
1770
	
1773
	
1771
	private void calculerAfficherDifferences(ListeObservation listeObs) {
1774
	private void calculerAfficherDifferences(ListeObservation listeObs) {
1772
		
1775
		
1773
		String departement = null;
1776
		String departement = null;
1774
		String commune = null;
1777
		String commune = null;
1775
		String lieuDit = null;
1778
		String lieuDit = null;
1776
		String station = null;
1779
		String station = null;
1777
		String milieu = null;
1780
		String milieu = null;
1778
		String espece = null;
1781
		String espece = null;
1779
		String date = null;
1782
		String date = null;
1780
		String notes = null;
1783
		String notes = null;
1781
		String lat = null;
1784
		String lat = null;
1782
		String lon = null;
1785
		String lon = null;
1783
		String abondance = null;
1786
		String abondance = null;
1784
		String certitude = null;
1787
		String certitude = null;
1785
		String referentielTaxo = null;
1788
		String referentielTaxo = null;
1786
		String phenologie = null;
1789
		String phenologie = null;
1787
		
1790
		
1788
		String ordreObs = "";
1791
		String ordreObs = "";
1789
		
1792
		
1790
		for(Iterator<String> it = listeObs.keySet().iterator();it.hasNext();) {
1793
		for(Iterator<String> it = listeObs.keySet().iterator();it.hasNext();) {
1791
			Observation obsEnCours = listeObs.get(it.next());
1794
			Observation obsEnCours = listeObs.get(it.next());
1792
			departement = comparerDifferencesChamps(departement, obsEnCours.getIdentifiantLocalite());
1795
			departement = comparerDifferencesChamps(departement, obsEnCours.getIdentifiantLocalite());
1793
			commune = comparerDifferencesChamps(commune, obsEnCours.getLocalite());
1796
			commune = comparerDifferencesChamps(commune, obsEnCours.getLocalite());
1794
			lieuDit = comparerDifferencesChamps(lieuDit, obsEnCours.getLieudit());
1797
			lieuDit = comparerDifferencesChamps(lieuDit, obsEnCours.getLieudit());
1795
			station = comparerDifferencesChamps(station, obsEnCours.getStation());
1798
			station = comparerDifferencesChamps(station, obsEnCours.getStation());
1796
			milieu = comparerDifferencesChamps(milieu, obsEnCours.getMilieu());
1799
			milieu = comparerDifferencesChamps(milieu, obsEnCours.getMilieu());
1797
			espece = comparerDifferencesChamps(espece, obsEnCours.getNomSaisi()); 
1800
			espece = comparerDifferencesChamps(espece, obsEnCours.getNomSaisi()); 
1798
			date = comparerDifferencesChamps(date, obsEnCours.getDate());
1801
			date = comparerDifferencesChamps(date, obsEnCours.getDate());
1799
			notes = comparerDifferencesChamps(notes, obsEnCours.getCommentaire());
1802
			notes = comparerDifferencesChamps(notes, obsEnCours.getCommentaire());
1800
			lat = comparerDifferencesChamps(lat, obsEnCours.getLatitude());
1803
			lat = comparerDifferencesChamps(lat, obsEnCours.getLatitude());
1801
			lon = comparerDifferencesChamps(lon, obsEnCours.getLongitude());
1804
			lon = comparerDifferencesChamps(lon, obsEnCours.getLongitude());
1802
			abondance = comparerDifferencesChamps(abondance, obsEnCours.getAbondance());
1805
			abondance = comparerDifferencesChamps(abondance, obsEnCours.getAbondance());
1803
			certitude = comparerDifferencesChamps(certitude, obsEnCours.getCertitude());
1806
			certitude = comparerDifferencesChamps(certitude, obsEnCours.getCertitude());
1804
			referentielTaxo = comparerDifferencesChamps(referentielTaxo, obsEnCours.getReferentielTaxo());
1807
			referentielTaxo = comparerDifferencesChamps(referentielTaxo, obsEnCours.getReferentielTaxo());
1805
			phenologie = comparerDifferencesChamps(phenologie, obsEnCours.getPhenologie());
1808
			phenologie = comparerDifferencesChamps(phenologie, obsEnCours.getPhenologie());
1806
			
1809
			
1807
			ordreObs += obsEnCours.getNumeroOrdre()+",";
1810
			ordreObs += obsEnCours.getNumeroOrdre()+",";
1808
		}
1811
		}
1809
		
1812
		
1810
		Observation obs=new Observation(espece,numeroNom,commune,departement,lieuDit,station,milieu, notes,date);
1813
		Observation obs=new Observation(espece,numeroNom,commune,departement,lieuDit,station,milieu, notes,date);
1811
		obs.setNumeroOrdre(ordreObs);
1814
		obs.setNumeroOrdre(ordreObs);
1812
		obs.setLatitude(lat);
1815
		obs.setLatitude(lat);
1813
		obs.setLongitude(lon);
1816
		obs.setLongitude(lon);
1814
		obs.setAbondance(abondance);
1817
		obs.setAbondance(abondance);
1815
		obs.setCertitude(certitude);
1818
		obs.setCertitude(certitude);
1816
		obs.setReferentielTaxo(referentielTaxo);
1819
		obs.setReferentielTaxo(referentielTaxo);
1817
		obs.setPhenologie(phenologie);
1820
		obs.setPhenologie(phenologie);
1818
		rafraichir(obs, false);	
1821
		rafraichir(obs, false);	
1819
	}
1822
	}
1820
	
1823
	
1821
	private String comparerDifferencesChamps(String valeurActuelle, String nouvelleValeur) {
1824
	private String comparerDifferencesChamps(String valeurActuelle, String nouvelleValeur) {
1822
		
1825
		
1823
		String retour = "000null";
1826
		String retour = "000null";
1824
		
1827
		
1825
			if(valeurActuelle == null) {
1828
			if(valeurActuelle == null) {
1826
				retour = nouvelleValeur;
1829
				retour = nouvelleValeur;
1827
			} else {
1830
			} else {
1828
				if(valeurActuelle.equals(nouvelleValeur)) {
1831
				if(valeurActuelle.equals(nouvelleValeur)) {
1829
					retour = valeurActuelle;
1832
					retour = valeurActuelle;
1830
				} else {
1833
				} else {
1831
					retour = VALEURS_MULTIPLES;
1834
					retour = VALEURS_MULTIPLES;
1832
				}
1835
				}
1833
			}
1836
			}
1834
		return retour;
1837
		return retour;
1835
	}
1838
	}
1836
	
1839
	
1837
	private void reinitialiserValeurModifiees() {	
1840
	private void reinitialiserValeurModifiees() {	
1838
		communeModifiee = false;
1841
		communeModifiee = false;
1839
		lieuDitModifie = false;
1842
		lieuDitModifie = false;
1840
		stationModifiee = false;
1843
		stationModifiee = false;
1841
		milieuModifie = false;
1844
		milieuModifie = false;
1842
		dateModifiee = false;
1845
		dateModifiee = false;
1843
		especeModifiee = false;
1846
		especeModifiee = false;
1844
		commModifie = false;
1847
		commModifie = false;
1845
		latModifiee = false;
1848
		latModifiee = false;
1846
		longModifiee = false;
1849
		longModifiee = false;
1847
		abondanceModifiee = false;
1850
		abondanceModifiee = false;
1848
		certitudeModifiee = false;
1851
		certitudeModifiee = false;
1849
		referentielTaxoModifie = false;
1852
		referentielTaxoModifie = false;
1850
		phenologieModifiee = false;
1853
		phenologieModifiee = false;
1851
	}
1854
	}
1852
	
1855
	
1853
	public void saisieTabindex()
1856
	public void saisieTabindex()
1854
	{
1857
	{
1855
		
1858
		
1856
		selecteurMode.setTabIndex(0);
1859
		selecteurMode.setTabIndex(0);
1857
		commune.setTabIndex(1);
1860
		commune.setTabIndex(1);
1858
		lieudit.setTabIndex(3);
1861
		lieudit.setTabIndex(3);
1859
		station.setTabIndex(4);
1862
		station.setTabIndex(4);
1860
		milieu.setTabIndex(5);
1863
		milieu.setTabIndex(5);
1861
		coordonnees.setTabIndex(-1);
1864
		coordonnees.setTabIndex(-1);
1862
		coordonnees.addListener(new TextFieldListenerAdapter() {
1865
		coordonnees.addListener(new TextFieldListenerAdapter() {
1863
 
1866
 
1864
			@Override
1867
			@Override
1865
			public void onFocus(Field field) {
1868
			public void onFocus(Field field) {
1866
				if(coordPanel.isVisible()) {
1869
				if(coordPanel.isVisible()) {
1867
					latitude.focus();
1870
					latitude.focus();
1868
				} else {
1871
				} else {
1869
					Ext.get("lien_carto").focus();
1872
					Ext.get("lien_carto").focus();
1870
				}
1873
				}
1871
			}	
1874
			}	
1872
		});
1875
		});
1873
			
1876
			
1874
		latitude.setTabIndex(8);
1877
		latitude.setTabIndex(8);
1875
		longitude.setTabIndex(9);
1878
		longitude.setTabIndex(9);
1876
		comment.setTabIndex(10);
1879
		comment.setTabIndex(10);
1877
		date.setTabIndex(11);
1880
		date.setTabIndex(11);
1878
		espece.setTabIndex(12);
1881
		espece.setTabIndex(12);
1879
		selecteurCertitude.setTabIndex(13);
1882
		selecteurCertitude.setTabIndex(13);
1880
		selecteurAbondance.setTabIndex(14);
1883
		selecteurAbondance.setTabIndex(14);
1881
		selecteurStadePheno.setTabIndex(15);
1884
		selecteurStadePheno.setTabIndex(15);
1882
		boutonOK.setTabIndex(16);
1885
		boutonOK.setTabIndex(16);
1883
		boutonAnnuler.setTabIndex(17);
1886
		boutonAnnuler.setTabIndex(17);
1884
		
1887
		
1885
	}
1888
	}
1886
	
1889
	
1887
	private void obtenirInformationCoord() {
1890
	private void obtenirInformationCoord() {
1888
		if(coordonneesValides() != null) {
1891
		if(coordonneesValides() != null) {
1889
			observationMediateur.obtenirInformationCoord(LatLng.newInstance(coordonneesValides()[0],coordonneesValides()[1]));
1892
			observationMediateur.obtenirInformationCoord(LatLng.newInstance(coordonneesValides()[0],coordonneesValides()[1]));
1890
		} else {
1893
		} else {
1891
			observationMediateur.afficherFenetreCarto();
1894
			observationMediateur.afficherFenetreCarto();
1892
		}
1895
		}
1893
 
1896
 
1894
	}
1897
	}
1895
	
1898
	
1896
	private void obtenirInformationCommune() {
1899
	private void obtenirInformationCommune() {
1897
		observationMediateur.obtenirInformationCommune(getCommuneSansDepartement(), Util.obtenirDepartementAPartirChaineCommune(departement, commune.getText()));
1900
		observationMediateur.obtenirInformationCommune(getCommuneSansDepartement(), Util.obtenirDepartementAPartirChaineCommune(departement, commune.getText()));
1898
	}
1901
	}
1899
	
1902
	
1900
	public double[] coordonneesValides() {
1903
	public double[] coordonneesValides() {
1901
		
1904
		
1902
		try {
1905
		try {
1903
						
1906
						
1904
			double lat = Double.parseDouble(latitude.getValueAsString().replaceAll(",", "."));
1907
			double lat = Double.parseDouble(latitude.getValueAsString().replaceAll(",", "."));
1905
			double lon = Double.parseDouble(longitude.getValueAsString().replaceAll(",", "."));
1908
			double lon = Double.parseDouble(longitude.getValueAsString().replaceAll(",", "."));
1906
			
1909
			
1907
			double[] coord = {lat, lon};
1910
			double[] coord = {lat, lon};
1908
			return coord;
1911
			return coord;
1909
			
1912
			
1910
		} catch (NumberFormatException ne) {
1913
		} catch (NumberFormatException ne) {
1911
			return null;
1914
			return null;
1912
		}
1915
		}
1913
	}
1916
	}
1914
	
1917
	
1915
	private String[] getValeurCoordonnees() {
1918
	private String[] getValeurCoordonnees() {
1916
		double[] coDouble = coordonneesValides();
1919
		double[] coDouble = coordonneesValides();
1917
		
1920
		
1918
		if(coDouble != null) {
1921
		if(coDouble != null) {
1919
			String[] coord = {coDouble[0]+"",coDouble[1]+""};
1922
			String[] coord = {coDouble[0]+"",coDouble[1]+""};
1920
			return coord;
1923
			return coord;
1921
		} else {
1924
		} else {
1922
			String[] coord = {"000null","000null" };
1925
			String[] coord = {"000null","000null" };
1923
			return coord;
1926
			return coord;
1924
		}
1927
		}
1925
	}
1928
	}
1926
	
1929
	
1927
	public String getCommune() {
1930
	public String getCommune() {
1928
		
1931
		
1929
		String valeurCommune = "";
1932
		String valeurCommune = "";
1930
		
1933
		
1931
		if(commune.getValue() != null) {
1934
		if(commune.getValue() != null) {
1932
			valeurCommune = commune.getValue(); 
1935
			valeurCommune = commune.getValue(); 
1933
		}
1936
		}
1934
		return valeurCommune;
1937
		return valeurCommune;
1935
	}
1938
	}
1936
	
1939
	
1937
	public String getDepartement() {
1940
	public String getDepartement() {
1938
		return Util.obtenirDepartementAPartirChaineCommune(departement, commune.getText());
1941
		return Util.obtenirDepartementAPartirChaineCommune(departement, commune.getText());
1939
	}
1942
	}
1940
	 
1943
	 
1941
	public String getCommuneSansDepartement() {
1944
	public String getCommuneSansDepartement() {
1942
		return Util.supprimerNumDepartementChaineLocalite(getCommune());
1945
		return Util.supprimerNumDepartementChaineLocalite(getCommune());
1943
	}
1946
	}
1944
	
1947
	
1945
	private String getValeurChampListeLibre(ComboBox champ) {
1948
	private String getValeurChampListeLibre(ComboBox champ) {
1946
		String valeurChamp = champ.getValue();
1949
		String valeurChamp = champ.getValue();
1947
		String valeurChampBrute = champ.getRawValue();
1950
		String valeurChampBrute = champ.getRawValue();
1948
		
1951
		
1949
		// Test idiot qui permet de savoir si l'on utilise la valeur saisie directement ou bien la valeur
1952
		// Test idiot qui permet de savoir si l'on utilise la valeur saisie directement ou bien la valeur
1950
		// selectionnee car lors du setValue sur le keypress, gwtext ne prends pas en compte le dernier 
1953
		// selectionnee car lors du setValue sur le keypress, gwtext ne prends pas en compte le dernier 
1951
		// caractère
1954
		// caractère
1952
		
1955
		
1953
		if(valeurChampBrute.trim().length() == 0) {
1956
		if(valeurChampBrute.trim().length() == 0) {
1954
			valeurChamp = "";
1957
			valeurChamp = "";
1955
		} else {
1958
		} else {
1956
			if(valeurChamp != null && valeurChamp.length() > 0) {
1959
			if(valeurChamp != null && valeurChamp.length() > 0) {
1957
				if(valeurChamp.equals(valeurChampBrute.substring(0, valeurChampBrute.length() -1))) {
1960
				if(valeurChamp.equals(valeurChampBrute.substring(0, valeurChampBrute.length() -1))) {
1958
					valeurChamp = champ.getRawValue();
1961
					valeurChamp = champ.getRawValue();
1959
				}
1962
				}
1960
			}
1963
			}
1961
		}
1964
		}
1962
		return valeurChamp;
1965
		return valeurChamp;
1963
	}
1966
	}
1964
 
1967
 
1965
	public String getAbondance() {
1968
	public String getAbondance() {
1966
		return getValeurChampListeLibre(selecteurAbondance);
1969
		return getValeurChampListeLibre(selecteurAbondance);
1967
	}
1970
	}
1968
	
1971
	
1969
	public String getCertitude() {
1972
	public String getCertitude() {
1970
		return getValeurChampListeLibre(selecteurCertitude);
1973
		return getValeurChampListeLibre(selecteurCertitude);
1971
	}
1974
	}
1972
	
1975
	
1973
	public String getPhenologie() {
1976
	public String getPhenologie() {
1974
		return getValeurChampListeLibre(selecteurStadePheno);
1977
		return getValeurChampListeLibre(selecteurStadePheno);
1975
	}
1978
	}
1976
	
1979
	
1977
	public String getReferentielTaxo() {
1980
	public String getReferentielTaxo() {
1978
		String codeCourt = getValeurChampListeLibre(selecteurReferentielTaxo);
1981
		String codeCourt = getValeurChampListeLibre(selecteurReferentielTaxo);
1979
		return Ontologies.getInfosReferentielNomParCode(codeCourt).getCodeVersionComplet();
1982
		return Ontologies.getInfosReferentielNomParCode(codeCourt).getCodeVersionComplet();
1980
	}
1983
	}
1981
 
1984
 
1982
	public boolean communeInitialisee() {
1985
	public boolean communeInitialisee() {
1983
		return communeModifiee;
1986
		return communeModifiee;
1984
	}
1987
	}
1985
	
1988
	
1986
	public void redimensionnerFormulaire() {
1989
	public void redimensionnerFormulaire() {
1987
		afficherFormulaireLatLon.setWidth(panneauIntermediaire.getWidth()+"px");
1990
		afficherFormulaireLatLon.setWidth(panneauIntermediaire.getWidth()+"px");
1988
		panneauPremierColonne.doLayout();
1991
		panneauPremierColonne.doLayout();
1989
		panneauSecondeColonne.doLayout();
1992
		panneauSecondeColonne.doLayout();
1990
		panneauIntermediaire.doLayout();
1993
		panneauIntermediaire.doLayout();
1991
		
1994
		
1992
		doLayout();
1995
		doLayout();
1993
	}
1996
	}
1994
}
1997
}