Subversion Repositories eFlore/Applications.cel

Rev

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

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