Subversion Repositories eFlore/Applications.cel

Rev

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

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