Subversion Repositories eFlore/Applications.cel

Rev

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

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